Tool calling (also called function calling) lets a large language model use external functions. The application describes each tool with a JSON schema; the model answers with a structured request to call one; the application runs it and returns the result. This is the core mechanism behind Agentic AI.

Loop

Steps:

  • the application sends the conversation plus a list of tools, each with a name, a description and a JSON schema for its arguments
  • the model replies with text, or with one or more tool calls: a tool name and arguments that follow the schema
  • the application validates each call and runs it
  • the application sends back a tool result for every call, linked by its call id
  • the model reads the results and decides the next call, asks a question, or gives a final answer
  • repeat until done, with a limit on the number of turns

Example Schema

{
  "name": "pick",
  "description": "Grasp the object at a position and lift it.",
  "input_schema": {
    "type": "object",
    "properties": {
      "xyz": {"type": "array", "items": {"type": "number"},
              "minItems": 3, "maxItems": 3}
    },
    "required": ["xyz"]
  }
}

Model Does Not Run Anything

  • it only produces a request, and the application decides whether to run it
  • so every call must be checked: the tool exists, the arguments are allowed and complete, the types are right, and values are safe (for example a position inside a robot's workspace)
  • a rejected call can be returned with the reason, so the model can correct it

Design Tips

  • write descriptions that say when to use and when not to use each tool
  • a "question" tool (for example ask_user) lets the model ask instead of guessing when a request is ambiguous
  • keep schemas and the real function signatures in sync, and check this at start-up
  • return useful results ("position below table by 3 cm"), not just "failed", so the model can recover
  • a strict schema mode guarantees that calls match the schema
  • forcing a structured answer through a single tool is a reliable way to get JSON output, for example a list of object names

Risks

  • the model can invent arguments, such as coordinates of objects it was never told about, so it must be told to use only given values
  • long loops cost time and money, so cap the turns