Principle:Mistralai Client python Tool Result Submission
| Knowledge Sources | |
|---|---|
| Domains | Function_Calling, API_Design |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
A multi-turn conversation pattern that submits function execution results back to the language model for incorporation into the final response.
Description
Tool Result Submission is the process of packaging function execution results into ToolMessage objects and sending them back to the model in a follow-up chat completion request. Each ToolMessage must include the tool_call_id (matching the original ToolCall.id) so the model can associate results with the corresponding function call. The follow-up request includes the full conversation history: original messages, the assistant's tool-calling message, and the tool result messages.
Usage
Use this principle after executing functions dispatched by tool calls. Create a ToolMessage for each tool call result and send a new chat completion request with the full conversation history.
Theoretical Basis
The multi-turn tool calling loop:
- Model generates tool_calls in response
- User executes functions and collects results
- Results are wrapped in ToolMessage objects with matching tool_call_ids
- A new chat.complete() call includes: original messages + assistant message + tool messages
- Model generates a natural language response incorporating tool results