#[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),
}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
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.