Skip to main content

Module types

Module types 

Source
Expand description

Agent message shapes.

AgentMessage is the canonical typed conversation transcript. Apps that need richer shapes either extend the Custom variant (kind-tagged JSON payload) or wrap the entire enum in their own outer enum. The loop never peeks into Custom — it’s pass-through context.

The discriminator lives on the role tag, content is typed, and the loop avoids Value walking via field-name strings.

Structs§

AgentContext
Snapshot of agent state passed into the loop.
AssistantContent
Assistant-message content. Carries text, hidden reasoning blocks, and tool call requests in source order.
ImageContent
ReasoningDetailsContent
Persistent envelope for provider-native reasoning items on an assistant turn. The wire shape is Vec<Value> matching OpenRouter’s reasoning_details[] schema (the broadest typed surface across providers); as_items lifts it to typed crate::reasoning::ReasoningItems for codec operations and from_items projects typed items back. The details field stays the source of truth so persisted trajectories round-trip byte-exact, even when a future provider sends shapes the typed enum doesn’t yet recognize.
RunIdentity
Identity of one agent run.
TextContent
ToolResultContent
Tool result content. Multiple blocks support image-returning tools.
Usage
Provider-reported token accounting for one LLM call.

Enums§

AgentMessage
One message in the conversation transcript.
AssistantBlock
Blocks an assistant message can carry.
StopReason
Why an assistant turn ended.
ToolResultBlock
UserBlock
UserContent
User-message content. Plain text is the common case; the block form supports images, attachments, and other multimodal inputs.