Skip to main content

Streaming Text

TextDelta

OutputChunk::TextDelta(String)
Streaming text token. Append to display.

TextComplete

OutputChunk::TextComplete(String)
Full text response (non-streaming mode).

Extended Thinking

ThinkingDelta

OutputChunk::ThinkingDelta(String)
Streaming thinking token.

ThinkingComplete

OutputChunk::ThinkingComplete(String)
Complete thinking block.

Tool Execution

ToolStart

OutputChunk::ToolStart {
    id: String,
    name: String,
    input: Value,
}
Tool execution starting.

ToolProgress

OutputChunk::ToolProgress {
    id: String,
    output: String,
}
Tool progress update.

ToolEnd

OutputChunk::ToolEnd {
    id: String,
    result: ToolResult,
}
Tool execution complete.

Permissions

PermissionRequest

OutputChunk::PermissionRequest {
    tool_name: String,
    action: String,
    input: Value,
    details: Option<String>,
}
Permission needed for tool.

Subagents

SubAgentSpawned

OutputChunk::SubAgentSpawned {
    session_id: String,
    agent_type: String,
}
Subagent created.

SubAgentOutput

OutputChunk::SubAgentOutput {
    session_id: String,
    chunk: Box<OutputChunk>,
}
Subagent output forwarded.

SubAgentComplete

OutputChunk::SubAgentComplete {
    session_id: String,
    result: Option<String>,
}
Subagent finished.

State & Control

StateChange

OutputChunk::StateChange(AgentState)
Agent state transition.

Status

OutputChunk::Status(String)
Status message.

Error

OutputChunk::Error(String)
Error occurred.

Done

OutputChunk::Done
Turn complete.

Ask User Questions

AskUserQuestion

OutputChunk::AskUserQuestion {
    request_id: String,
    questions: Vec<UserQuestion>,
}
Agent asking multiple-choice questions.

Usage

while let Ok(chunk) = rx.recv().await {
    match chunk {
        OutputChunk::TextDelta(text) => print!("{}", text),
        OutputChunk::ToolStart { name, .. } => println!("\nUsing {}", name),
        OutputChunk::PermissionRequest { tool_name, action, .. } => {
            show_permission_dialog(tool_name, action);
        }
        OutputChunk::Done => break,
        _ => {}
    }
}