pub struct ToolCall {
pub id: String,
pub name: String,
pub arguments: Value,
pub reasoning_state: Option<ReasoningState>,
}Expand description
A request from the model to execute a tool.
This represents an “intent” to call a tool - the tool has NOT been executed. The consumer is responsible for:
- Looking up the tool by name
- Parsing and validating arguments
- Executing the tool
- Returning results to the model
Fields§
§id: StringUnique identifier for this tool call.
Used to correlate tool results with their requests when continuing the conversation.
name: StringName of the tool to execute.
arguments: ValueArguments to pass to the tool, as a JSON value.
The structure depends on the tool’s schema.
reasoning_state: Option<ReasoningState>Provider reasoning state bound to this specific call.
Gemini attaches a thought signature to each function call rather than to
the turn, so it lives here; providers that scope reasoning to the whole
turn use Message::assistant_with_reasoning instead.
Implementations§
Source§impl ToolCall
impl ToolCall
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
arguments: Value,
) -> Self
pub fn new( id: impl Into<String>, name: impl Into<String>, arguments: Value, ) -> Self
Creates a new tool call.
Sourcepub fn with_reasoning_state(self, state: ReasoningState) -> Self
pub fn with_reasoning_state(self, state: ReasoningState) -> Self
Binds provider reasoning state to this call.
Used by providers that sign each function call individually, so the signature travels with the call it belongs to instead of the turn.
Sourcepub fn arguments_json(&self) -> String
pub fn arguments_json(&self) -> String
Returns the arguments as a JSON string.