Skip to main content

Module tool

Module tool 

Source
Expand description

Tool invocation state machine.

Tool calls have a lifecycle: streaming → waiting_confirmation → executing → completed (with cancelled as a terminal alternative). Each transition arrives as a SessionMessageDelta with a tool_state_update field carrying the whole next state, not a patch.

§Wire format

Variant names serialize as snake_case to match the TS ToolPhase union ("streaming" / "waiting_confirmation" / "executing" / "completed" / "cancelled"). Inline variant fields serialize as camelCase to match the TS interface shape (partialInput, approvalId, elapsedMs, confirmedBy). The per-variant rename_all = "camelCase" attribute handles the latter — a bare rename_all on the enum only affects variant names, not their fields.

Structs§

ToolInfo
Metadata for an in-flight or finished tool invocation, attached to a SessionMessage when role = tool_call.

Enums§

CancelReason
ConfirmedBy
ToolPhase
Phase name — useful as a lightweight discriminator when you don’t need the full state payload (e.g. to pick an icon).
ToolState
Tool state — a full replacement on each transition, never a delta.