pub struct ToolCallReceivedContext {
pub turn: usize,
pub tool: String,
pub call_id: String,
pub input: Value,
}Expand description
Context for LoopObserver::on_tool_call_received.
Fired once per tool call after the streaming response has been accumulated
and before dispatch of that call begins — strictly earlier than
ToolPreContext. Use this to surface a pending indicator the moment the
model decides to call a tool, before execution starts.
Unlike ToolPreContext, this context also carries the call’s input,
because the input is fully known at accumulation time and downstream
consumers may want to render it before execution. It fires exactly once per
call regardless of how many recovery retries the call later undergoes.
§Examples
use loopctl::observer::ToolCallReceivedContext;
let ctx = ToolCallReceivedContext {
turn: 0,
tool: "edit".to_string(),
call_id: "call_1".to_string(),
input: serde_json::json!({"path": "/tmp/a"}),
};
assert_eq!(ctx.tool, "edit");
assert_eq!(ctx.call_id, "call_1");Fields§
§turn: usizeTurn number (0-indexed).
Matches the value passed to the corresponding on_response and
on_tool_pre for the same assistant message.
tool: StringTool name.
Matches the name the tool was registered under. Same value as
ToolPreContext::tool for the same call.
call_id: StringTool call ID assigned by the API.
Correlates with ToolPreContext::tool_call_id for the same call.
input: ValueJSON input the model supplied for this call.
The full input object, as accumulated from the stream. Not present on
ToolPreContext (which fires later but omits input).
Trait Implementations§
Source§impl Clone for ToolCallReceivedContext
impl Clone for ToolCallReceivedContext
Source§fn clone(&self) -> ToolCallReceivedContext
fn clone(&self) -> ToolCallReceivedContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more