Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Mistralai Client python Tool Result Submission

From Leeroopedia
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:

  1. Model generates tool_calls in response
  2. User executes functions and collects results
  3. Results are wrapped in ToolMessage objects with matching tool_call_ids
  4. A new chat.complete() call includes: original messages + assistant message + tool messages
  5. Model generates a natural language response incorporating tool results

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment