pub enum StreamChunk {
TextDelta(String),
ThinkingDelta {
text: String,
redacted: Option<String>,
},
ToolLifecycle {
phase: ToolPhase,
call_id: String,
tool_name: String,
},
ToolOutput {
call_id: String,
tool_name: String,
content: String,
is_error: bool,
duration: Duration,
},
}Expand description
数据面事件 — 高频、数据透传。
统一流式协议,所有 Node(LLM、Tool、MCP、Workflow)共享。
Tool 并发 emit 协议:
- Start 保证顺序 — 严格按照 ToolCall 顺序发射(A, B, C)
- End 允许乱序 — 并发执行完成后按实际顺序发射(B, A, C),通过 call_id 关联
Variants§
TextDelta(String)
文本输出(LLM 生成的文本 token)
ThinkingDelta
思考内容(LLM 的 reasoning/thinking block)
redacted 为审查后的敏感推理内容(如 Anthropic thinking_redacted)。
Graph 层保留完整信息,UI 层决定是否展示。
ToolLifecycle
工具生命周期事件(Queued / Started / Finished)
ToolOutput
工具执行结果(展示用,content 为 String,前端直接展示)
与 State Plane 的 Message::ToolResult 分离。
State 保存完整 Message(含 content_blocks, metadata, raw_response)。
此变体仅用于实时展示。
Trait Implementations§
Source§impl Clone for StreamChunk
impl Clone for StreamChunk
Source§fn clone(&self) -> StreamChunk
fn clone(&self) -> StreamChunk
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for StreamChunk
impl RefUnwindSafe for StreamChunk
impl Send for StreamChunk
impl Sync for StreamChunk
impl Unpin for StreamChunk
impl UnsafeUnpin for StreamChunk
impl UnwindSafe for StreamChunk
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more