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.
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.
{
"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"]
}
}
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.