liveBook · Manning

Tool usage

As explained in Building Reliable AI Systems

An AI capability in which a model invokes external tools to obtain information or perform actions.

Tool usage lets an AI assistant obtain information or take actions through external functions, APIs, and services. It raises the stakes: a mistaken weather answer is inconvenient, while a mistaken booking or database deletion can cause lasting harm. Multi-step workflows also compound errors, so a successful tool call is not the same as a reliable end-to-end agent. section 1.4.2 section 2.9

For information retrieval, separate language understanding from factual lookup. The model identifies that it needs data and requests a function call; application code executes the function and returns its result; the model then writes a response using that result. A weather assistant can therefore answer from current API data rather than inventing conditions from its training data. This reduces hallucination risk but still depends on choosing an authoritative source and handling failures. section 2.8 section 2.8.3

A practical integration has three parts:

  • Define a function and describe its parameters with a JSON schema so the model can request a structured call. section 2.8.3
  • Inspect returned tool calls, execute the requested function in application code, and append each result to the conversation with its tool-call ID. section 2.8.3
  • Request a final response after supplying the result; for agents that act across services, add consistent error handling, traceability, and failure containment. section 2.8.3 section 1.4.2

Current weather

A user asks whether it is raining in Seattle. The assistant requests current conditions through a weather function, receives the result, and answers that it is 10°C and raining. The model handles the question and phrasing; the external service supplies the weather facts. section 2.8.3

const tools = [
  new DynamicTool({
    name: "travel_knowledge",
    description: "Useful for answering questions about travel destinations,
        landmarks, and tourist attractions",
    func: async (input: string) => {
      const result = await retrievalChain.run(input);    #1
      return result;
    },
  }),
  new DynamicTool({
    name: "weather_service",
    description: "Get the current weather conditions for a specific location
        or city",
    func: async (location: string) => {
      return await getWeather(location);                #2
    },
  }),
];

Two named tools show how an agent can route destination questions to a retrieval chain and current-weather questions to a weather service. Their descriptions make the intended use of each tool explicit. section 6.3.4

How Building Reliable AI Systems covers it

How deep it goes
Works through function definition, JSON schema, API invocation, tool-result handling, and final response; sketches broader agent safeguards rather than implementing them.
Examples
Uses a Python weather assistant, Seattle and New York queries, and specialized travel-retrieval and weather tools.
What it assumes
Introduces function definitions, JSON schema, and chatbot integration; does not specify a broader prerequisite list.
What you can do after
Build it from scratch: connect a conversational assistant to a weather API through structured function calls and returned tool results.
How it connects
Connects function calling with retrieval-augmented generation, hallucination reduction, agent architectures, and the Model Context Protocol.

Also explained in

Compare how 13 books explain tool usage →

Related concepts

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