Tool calling, explained: how a language model uses software

    When an assistant checks the weather, books a slot, or looks up an order, it can feel like the model reached out and did it. It didn’t. A language model only produces text. Tool calling is a convention for making that text useful.

    The loop

    You describe the tools available: a name, what it does, and what inputs it takes. The model, reading a request, may reply with a structured message saying which tool it wants and with what inputs. Your code reads that message, runs the tool, and sends the result back. The model then continues with that result in front of it.

    Figure 1 · One round of tool calling

    User asksModelasks for a toolYour coderuns the toolResult goes backModel answers
    The highlighted step is where all the real action, and all the real risk, sits. It is code you control.

    Why this matters

    • You decide what is possible. The model can only ask for tools you listed. It can’t run anything you didn’t wire up.
    • Permissions live in your code. Check inputs, limit access, and require approval before irreversible actions. We say more in the note on prompt injection.
    • Descriptions are instructions. A vague tool description produces wrong calls. Write them like you would brief a new colleague.

    Common problems

    1. Too many tools. The more options, the more wrong picks. Start with a few.
    2. Errors with no explanation. If a tool fails, return a clear message so the model can try something else.
    3. Endless loops. Cap the number of rounds, so a confused agent stops instead of running up a bill.
    4. No record. Log every call and result, or you will not be able to explain a bad outcome later.

    Standards like MCP make tools easier to share between apps, and the harness is the layer that runs this loop and enforces the rules around it.

    Want help putting this into practice?

    Book a free consultation and tell us about your team or school.

    Book a free consultation