A tool message carries the result of an external tool invocation back to the LLM. It extends a conversation beyond the initial user request, giving the model additional context for its final answer. section 6.1.2 section 3.3
A tool-driven exchange proceeds as follows:
- The LLM returns an assistant message containing a tool call rather than a completed answer. section 6.1.2
- The application invokes the requested tool, such as getCurrentTime, and obtains its result. section 6.1.2
- The application sends the original user message, assistant tool call, and tool message together for reconsideration. section 6.1.2
- The LLM uses the tool content to produce a final assistant response with a stop finish reason. section 6.1.2
Current time lookup
For a question about the current time in Jal, New Mexico, the tool message contains the returned timestamp and identifies getCurrentTime through its tool_call_id. The LLM then answers with the localized time and date.
Figure 6.1 Tool invocation involves a multipart conversation between the application and the LLM.
Trace the multipart conversation among the application, LLM, assistant tool call, and tool result. section 6.1.2
