pub enum ConversationStreamEvent {
Show 23 variants
ChatStarted(ChatStartedPayload),
WorkflowStarted(WorkflowStartedPayload),
Message(MessagePayload),
Ping,
ThinkingStarted(ThinkingStartedPayload),
ThinkingFinished(ThinkingFinishedPayload),
NodeToolUseStarted(NodeToolUseStartedPayload),
NodeToolUseFinished(NodeToolUseFinishedPayload),
SubagentStarted(SubagentStartedPayload),
SubagentProgress(SubagentProgressPayload),
SubagentFinished(SubagentFinishedPayload),
AgentToolStarted(AgentToolStartedPayload),
AgentToolProgress(AgentToolProgressPayload),
AgentToolFinished(AgentToolFinishedPayload),
HumanInteractionRequired(ConversationResponse),
QueryMasked(QueryMaskedPayload),
PlanChanged(PlanChangedPayload),
ContextCompressStarted(ContextCompressStartedPayload),
ContextCompressFinished(ContextCompressFinishedPayload),
ChatFinished(ChatFinishedPayload),
WorkflowFinished(ConversationResponse),
ChatTitleUpdated(ChatTitleUpdatedPayload),
Other {
event: String,
data: Value,
},
}Expand description
One event observed while streaming
crate::AgentContext::conversation_streamed
or crate::AgentContext::continue_conversation_streamed.
A run always begins with ChatStarted and ends with ChatFinished. What
happens in between depends on the outcome:
- Succeeded:
ChatStarted→WorkflowStarted→ThinkingStarted→Message(message_type == "think") … →NodeToolUseStarted/NodeToolUseFinished… →ThinkingFinished→Message(message_type == "answer") … →WorkflowFinished(status == "succeeded") →ChatFinished - Interrupted (the Agent needs your input; resume via
crate::AgentContext::continue_conversation_streamed):ChatStarted→WorkflowStarted→ … →HumanInteractionRequired→ChatFinished. An interrupted run does not emitWorkflowFinished, and resuming it does not emitWorkflowStartedagain. - Failed:
ChatStarted→WorkflowStarted→ … →WorkflowFinished(status == "failed") →ChatFinished
For a plain question-and-answer integration you only need to handle four
variants — everything else is optional progress display: Message with
message_type == "answer" (append text to the answer being displayed),
HumanInteractionRequired (show the questions and call
continue_conversation/continue_conversation_streamed with the
answers), WorkflowFinished (read the final outcome), and ChatFinished
(the stream is over).
Variants§
ChatStarted(ChatStartedPayload)
The run has started
WorkflowStarted(WorkflowStartedPayload)
Observed right after ChatStarted on every run seen so far, see
WorkflowStartedPayload’s docs. Not emitted when resuming an
interrupted run.
Message(MessagePayload)
An incremental piece of the answer
Ping
A heartbeat with no payload, observed at arbitrary points in the
stream (including in between Message chunks)
ThinkingStarted(ThinkingStartedPayload)
The Agent has entered the reasoning phase
ThinkingFinished(ThinkingFinishedPayload)
The reasoning phase is over
NodeToolUseStarted(NodeToolUseStartedPayload)
An ordinary tool call has started
NodeToolUseFinished(NodeToolUseFinishedPayload)
An ordinary tool call has ended
SubagentStarted(SubagentStartedPayload)
The Agent has spawned a subagent to work on a sub-task
SubagentProgress(SubagentProgressPayload)
The subagent has called one of its own tools
SubagentFinished(SubagentFinishedPayload)
The subagent has finished its sub-task
AgentToolStarted(AgentToolStartedPayload)
The Agent has delegated to another Agent as a tool
AgentToolProgress(AgentToolProgressPayload)
The delegated Agent has called one of its own tools
AgentToolFinished(AgentToolFinishedPayload)
The delegated Agent’s run has finished
HumanInteractionRequired(ConversationResponse)
The run is paused: the Agent needs more information or confirmation
from you, carrying the interrupt to resume from via
crate::AgentContext::continue_conversation_streamed. Unlike
WorkflowFinished, this is emitted instead of (never alongside)
WorkflowFinished for the same run.
QueryMasked(QueryMaskedPayload)
Sensitive content in the user query was masked before processing
PlanChanged(PlanChangedPayload)
The Agent created or updated its task plan
ContextCompressStarted(ContextCompressStartedPayload)
A context-compression pass has started (long conversations trigger this)
ContextCompressFinished(ContextCompressFinishedPayload)
The context-compression pass has finished
ChatFinished(ChatFinishedPayload)
Observed once all Message events for this round have been sent, see
ChatFinishedPayload’s docs
WorkflowFinished(ConversationResponse)
The run finished successfully, with a failure, or stopped by the
user, carrying the run’s outcome. Never emitted for an interrupted
run — see ConversationStreamEvent::HumanInteractionRequired for
that case. Not necessarily the last event of the stream — the server
may still emit a few more housekeeping events (e.g.
ConversationStreamEvent::ChatTitleUpdated) before actually
closing the connection.
ChatTitleUpdated(ChatTitleUpdatedPayload)
The server auto-generating a short title for the conversation, see
ChatTitleUpdatedPayload’s docs. Can arrive before or after
ConversationStreamEvent::WorkflowFinished.
Other
An event type not recognized by this SDK version, carried as raw JSON
so callers aren’t broken by future additions to the API. event is
the SSE envelope’s discriminator string, so callers can at least tell
these apart instead of getting an opaque blob.
Trait Implementations§
Source§impl Clone for ConversationStreamEvent
impl Clone for ConversationStreamEvent
Source§fn clone(&self) -> ConversationStreamEvent
fn clone(&self) -> ConversationStreamEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ConversationStreamEvent
impl RefUnwindSafe for ConversationStreamEvent
impl Send for ConversationStreamEvent
impl Sync for ConversationStreamEvent
impl Unpin for ConversationStreamEvent
impl UnsafeUnpin for ConversationStreamEvent
impl UnwindSafe for ConversationStreamEvent
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more