Skip to main content

ConversationStreamEvent

Enum ConversationStreamEvent 

Source
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: ChatStartedWorkflowStartedThinkingStartedMessage (message_type == "think") … → NodeToolUseStarted / NodeToolUseFinished … → ThinkingFinishedMessage (message_type == "answer") … → WorkflowFinished (status == "succeeded") → ChatFinished
  • Interrupted (the Agent needs your input; resume via crate::AgentContext::continue_conversation_streamed): ChatStartedWorkflowStarted → … → HumanInteractionRequiredChatFinished. An interrupted run does not emit WorkflowFinished, and resuming it does not emit WorkflowStarted again.
  • Failed: ChatStartedWorkflowStarted → … → 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.

Fields

§event: String

The SSE envelope’s event field (the event type name)

§data: Value

The SSE envelope’s data field

Trait Implementations§

Source§

impl Clone for ConversationStreamEvent

Source§

fn clone(&self) -> ConversationStreamEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConversationStreamEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,