Skip to main content

Update

Enum Update 

Source
#[non_exhaustive]
pub enum Update<S = Value> { Message(MessageUpdate), Messages(Vec<Message>), State(S), Reasoning(ReasoningUpdate), Subagent(SubagentUpdate), Interrupt(Interrupt), Error(Error), Warning(String), RunEnded(RunSummary), Done(RunEnd), }
Available on crate feature client only.
Expand description

Something a view should react to.

One Update is one redraw. S is the caller’s state type; it is serde_json::Value unless a Thread is asked for something better.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Message(MessageUpdate)

A message was created, appended to, or completed.

§

Messages(Vec<Message>)

MESSAGES_SNAPSHOT replaced the conversation. Messages may have disappeared, so redraw all of it.

§

State(S)

The application state changed, and here it is in the caller’s type.

Carries no association with whatever was open when it arrived — a tool call, a message — because the wire carries none either. Where it lands in the stream is the only nesting there is; see the module docs.

§

Reasoning(ReasoningUpdate)

A reasoning message was created, appended to, or completed. It is in Thread::messages like any other message, and is announced here and not as an Update::Message, so a view can draw reasoning apart from the reply, or leave it out.

The span around reasoning messages, REASONING_START to REASONING_END, opens no message and yields no update. An application that needs to know one is open reads those two events in Thread::on_event.

§

Subagent(SubagentUpdate)

A subagent was announced, resumed, finished, suspended or failed.

The lifecycle only: what a subagent says arrives as ordinary Update::Messages and Update::Reasonings whose messages carry its subagent_run_id, so a view groups by that and uses this for the group’s header and status. See Thread::subagents.

§

Interrupt(Interrupt)

The run paused and needs a human. Answer it with Thread::resume — one update per pending interrupt.

Only for interrupts that became pending on the thread: those of the requested run, or of a run after it, which replace the requested run’s. A replayed run’s are history, and are in its RunSummary only. Thread::interrupts holds what is pending once the stream has ended.

§

Error(Error)

Something went wrong: a malformed stream, a patch that would not apply, a transport failure, a RUN_ERROR.

Not necessarily fatal — a run survives a patch it could not apply, and a stream goes on after a RUN_ERROR, which fails one run and may be followed by the next. When it ends the stream, the matching Update::Done follows.

§

Warning(String)

Not an error: the stream was accepted, with a correction or an omission the application may want to log. An unrecognised field, enum member or event was dropped, a retired THINKING_* event was translated, a deprecated null was read as omitted, or the producer declared a newer protocol version. The run is unaffected. So is it in two more cases: a run after the requested one finished, and the pending interrupts were not replaced because a resume submission is still unconfirmed; or a REASONING_ENCRYPTED_VALUE was dropped because the thread holds no message or tool call by its entityId that can store it.

Each text is delivered once per run and repeats at most 64 characters of input, with control characters escaped. RunReport::diagnostics keeps it with kind warning.

§

RunEnded(RunSummary)

One run on the stream ended, and how.

A stream carries the run the request asked for, and AG-UI 1.0 lets runs the producer replays precede it. Each run gets one of these, the only run of a stream included, once nothing can change how it ended: at its RUN_ERROR, or for a run that reported RUN_FINISHED at whatever follows it — the next RUN_STARTED, a late RUN_ERROR, the end of the stream. A RUN_ERROR that opens the stream is reported at whatever follows it as well, because that decides whether it was the requested run; its Update::Error comes when it arrives. Update::Done follows the last one.

§

Done(RunEnd)

The stream ended, and how the request went: the RunEnd of the requested run — of the last run on the stream, should the producer have gone on after it — or how reading stopped before any such run ended. Always the last update, on every path out: the agent finishing, the agent failing, and the transport dying mid-sentence.

It arrives when the stream ends, not at a terminal event: another run may follow RUN_FINISHED or RUN_ERROR.

Trait Implementations§

Source§

impl<S: Debug> Debug for Update<S>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<S = Value> !RefUnwindSafe for Update<S>

§

impl<S = Value> !UnwindSafe for Update<S>

§

impl<S> Forget for Update<S>

§

impl<S> Freeze for Update<S>
where S: Freeze,

§

impl<S> Move for Update<S>

§

impl<S> Send for Update<S>
where S: Send,

§

impl<S> Sync for Update<S>
where S: Sync,

§

impl<S> Unpin for Update<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Update<S>
where S: UnsafeUnpin,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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