Skip to main content
Generative AI Intermediate Scenario-Based Topic: Tool Calling & Agents

What are AI Agents and Tool Calling, and how do you secure write actions?

Quick Summary: Tool calling lets an LLM emit validated JSON arguments matching a declared function schema so your backend—not the model directly—executes safe APIs; AI agents loop observe-think-act with stateful orchestration and Human-in-the-Loop checkpoints on high-risk actions.

Written by Ravi Shankar Mishra (Founder & Lead Systems Architect, MockAttempt Academy) Reviewed by MockAttempt Engineering Editorial Desk
Last verified:

Direct Interview Answer

An LLM never executes SQL or HTTP calls inside weights. With Tool Calling (Function Calling), developers pass typed schemas; the model returns a structured tool_call request, your server validates inputs and authorization, runs the tool, and feeds the result back.

An AI Agent wraps multiple tool steps in a stateful loop (e.g., LangGraph) to plan, retry, and verify completion.

Detailed Technical Explanation

Crucial security principle: guard against Indirect Prompt Injection where malicious ticket text tries tricking an agent into calling a refund/delete tool. Enforce server-side RBAC, least-privilege schemas, and mandatory Human-in-the-Loop (HITL) confirmation before mutating state.

Practical Walkthrough

Strict JSON schema tool definition paired with server-side validation.

Code Example — JSON
{
  "name": "lookup_order_status",
  "description": "Read-only order tracking lookup by order ID",
  "parameters": {
    "type": "object",
    "properties": {
      "order_id": { "type": "string", "pattern": "^ORD-[0-9]{4,10}$" }
    },
    "required": ["order_id"]
  }
}
Expected Output / Verification
Only read-only regex-validated order IDs accepted before backend DB lookup.

Real-World Production Use Case

Customer support agents, automated DevOps incident triage, and MCP server developer assistants.

Common Interview Mistakes to Avoid

  • Letting an agent generate raw arbitrary SQL against production databases.
  • Omitting step budgets (max_iterations), allowing infinite retry loops and runaway API bills.
Topics: #generative-ai #tool-calling #agents #mcp #security
Learn. Practise. Prove. Get Career-Ready.

Ready to Build Your IT Career?

Explore industry-led programmes and develop practical skills through training, assessments and interview preparation.