liveBook · Manning

Tool use

As explained in Designing AI Systems

tool_calls is a message field containing an assistant's requested tool or function invocations.

Tool use lets an assistant request external function calls rather than only generate text. The model selects a function and supplies arguments; a workflow executes the request and returns the result to the conversation. The request itself is not execution. section 3.1.6 section 6.0

A model request supplies tool definitions with a function name, description, and JSON Schema parameters. The response can contain text, tool calls, or both. Each call has an ID, a type, a function name, and JSON-encoded arguments. section 3.1.6 section 10.6

{
  "role": "assistant",
  "content": null,
  "tool_calls": [{
    "id": "call_abc123",
    "type": "function",
    "function": {
      "name": "check_availability",
      "arguments": "{\"date\": \"2024-01-16\"}"
    }
  }]
}
 

An assistant message requests an availability check through its tool_calls field; the arguments are encoded as a JSON string. section 4.1

A typical agent loop coordinates the model and the Tool Service:

  • Discover registered tools and pass their model-ready definitions with the conversation. section 6.1.3 section 10.6
  • Preserve the assistant message, parse each requested function's arguments, and execute the call through the Tool Service. section 2.1.5 section 10.6
  • Append each result as a tool-role message with the matching tool call ID. The ID associates results with requests when multiple calls are made. section 4.1
  • Send the updated conversation back to the model; repeat until it produces a final response or the workflow reaches its iteration limit. section 10.6

Checking appointment availability

A patient asks about openings. The assistant requests check_availability with a date; the workflow executes it and records available slots in a tool message linked to the call ID. The assistant then uses those slots in its answer. section 4.1

Production tool use requires more than a function schema. A registry supports discovery and reuse; credential references keep secrets out of application code. Authentication, parameter validation, rate limits, error recovery, and response formatting belong at the service boundary. section 2.1.5 section 6.0 section 1.4

Actions can change external state. Marking tools as read-only or non-idempotent informs guardrail decisions: repeating a calendar or ticket creation call can produce duplicate results. Limits and business policies help contain the consequences of repeated or inappropriate calls. section 6.0 section 10.6

How Designing AI Systems covers it

How deep it goes
Explains tool schemas, message linkage, registration, execution, and iterative orchestration with production controls.
Examples
Uses appointment availability checks, calendar event creation, ticket creation, and web search to illustrate tool requests and actions.
What you can do after
Apply it via the platform SDK to register and discover tools, execute model requests, and return results in an agent loop.
How it connects
Connects function calling to session management, workflow orchestration, guardrails, and credential isolation.

Also explained in

Compare how 18 books explain tool use →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Designing AI Systems. The section links point to the parts of the book it draws on.