liveBook · Manning

Tool usage

As explained in Spring AI in Action

A tool call is a model-generated request for an application to invoke an external callable capability.

Tool use lets a model-generated request reach application logic that supplies otherwise unavailable data or performs an action, such as invoking an API or updating data. Spring AI provides a consistent way to expose tools across supported model providers. section 6.1

A tool-driven interaction proceeds as a multipart conversation:

  • The application sends the user request together with a tool definition, including its name, description, and input schema. section 6.1
  • The model returns a tool call rather than a final answer, selecting the tool and providing arguments such as a time zone. section 6.1.2
  • Spring AI invokes the tool, adds the result to the conversation with a tool role, and sends the expanded request back to the model. section 6.1.2
  • The model uses the returned data to produce the final response, changing the completion reason from tool_calls to stop. section 6.1.2

Current time in Jal, New Mexico

For a question about Jal, New Mexico, the model identifies the America/Denver time zone and requests getCurrentTime with that argument. After the application returns the timestamp, the model answers with the local date and time. section 6.1.2

How Spring AI in Action covers it

How deep it goes
Traces tool schemas, generated arguments, automatic invocation, tool-result messages, and final completion responses.
Examples
Demonstrates getCurrentTime answering a time-zone question through generated JSON arguments and a returned timestamp.
What it assumes
Assumes an LLM-backed application and a callable application capability that can receive the model’s requested input.
What you can do after
Operate tool interactions through Spring AI’s consistent provider abstraction and interpret the resulting conversation messages.
How it connects
Connects tool use with retrieval-augmented generation, APIs, LLMs, memory, workflows, and agents.

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 Spring AI in Action. The section links point to the parts of the book it draws on.