Everyone's talking about AI adoption. Almost nobody has the real numbers. Help us change that — and get the full report 👉 Engineers | Leaders

Understanding Tool Calling

Master how LLMs invoke external tools — from JSON Schema definitions and model decision-making to agent loops, security, and production monitoring.


Foundations

What tool calling is and how tools are defined for language models.

  • [ ] What Is Tool Calling? [text] free
    • Define tool calling and how it differs from plain text generation
    • Describe the request/response loop between model and tool
    • Identify when tool calling is appropriate versus direct generation
    • Write a JSON Schema tool definition with parameters and types
    • Explain how the model uses tool descriptions to decide what to call
    • Apply constraints like required fields and enums to tool parameters

How Models Decide

How language models select tools and how their output is parsed and validated.

    • Explain how a model decides which tool to call from available options
    • Describe the role of tool descriptions in guiding selection
    • Identify scenarios where the model should not call any tool
    • Extract structured tool call data from model output
    • Validate tool call arguments against their JSON Schema
    • Implement error handling for malformed or invalid tool calls

Advanced Patterns

Multi-turn tool use, parallel calls, and building agent loops.

    • Chain multiple tool calls across conversation turns
    • Feed tool results back into the conversation context
    • Maintain state and context across a multi-turn tool sequence
    • Distinguish between parallel and dependent tool call patterns
    • Execute multiple independent tool calls simultaneously
    • Manage dependencies between tool calls that require ordering
    • Implement the observe-think-act cycle for an agent loop
    • Define exit conditions that prevent infinite tool call loops
    • Manage agent state across multiple iterations

Security and Production

Defending tool calls against attacks, adding guardrails, and monitoring in production.

    • Identify common prompt injection vectors that target tool calls
    • Explain how adversarial inputs can manipulate tool execution
    • Apply defence strategies to mitigate tool-based injection attacks
    • Implement rate limiting and allowlists for tool access
    • Design human-in-the-loop confirmation flows for sensitive operations
    • Scope tool permissions by user role and context
    • Set up structured logging for tool calls in production
    • Trace multi-step tool chains to diagnose failures
    • Track and optimize token usage and API costs