#[non_exhaustive]pub struct ThreadSnapshot {Show 14 fields
pub version: u32,
pub thread_id: ThreadId,
pub protocol_version: Option<String>,
pub messages: Vec<Message>,
pub state: Value,
pub reasoning: Vec<ReasoningMessage>,
pub subagents: Vec<Subagent>,
pub interrupts: Vec<Interrupt>,
pub decided_interrupt_tool_call_ids: Vec<ToolCallId>,
pub abandoned: Vec<MessageId>,
pub submission: Option<ResumeSubmission>,
pub run_ids: Vec<RunId>,
pub last_run_end: Option<RunEnd>,
pub active_run_id: Option<RunId>,
}Expand description
A versioned local snapshot. It contains conversation data, never a transport,
observer or running future. Validate it through restore before using it.
The fields are public: an application that reconciles a conversation with
its server edits a snapshot and restores it. The struct is
#[non_exhaustive], so one is made by Thread::snapshot, by
deserializing, or by ThreadSnapshot::new, and not by a struct literal.
use ag_ui::Message;
use ag_ui::client::{Thread, ThreadSnapshot, transport::ReplayTransport};
let mut snapshot = ThreadSnapshot::new("thread-1");
snapshot.messages = vec![Message::user("u-1", "Hello")];
let thread = Thread::<_>::restore(ReplayTransport::new([]), snapshot)?;
assert_eq!(thread.messages().len(), 1);A struct literal does not compile outside this crate, so a field added later breaks no caller:
use ag_ui::client::ThreadSnapshot;
let snapshot = ThreadSnapshot {
version: 2,
thread_id: "thread-1".into(),
protocol_version: None,
messages: Vec::new(),
state: serde_json::json!({}),
reasoning: Vec::new(),
subagents: Vec::new(),
interrupts: Vec::new(),
decided_interrupt_tool_call_ids: Vec::new(),
abandoned: Vec::new(),
submission: None,
run_ids: Vec::new(),
last_run_end: None,
active_run_id: None,
};Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.version: u32Snapshot format version (currently 2). Version 1 is still restored.
thread_id: ThreadIdThe remote conversation identifier.
protocol_version: Option<String>Protocol version this thread declares to its peer. None pins a
legacy peer; snapshots predating this field restore the current version.
messages: Vec<Message>Materialized conversation, reasoning and activity messages included.
state: ValueCurrent raw shared state.
reasoning: Vec<ReasoningMessage>Version 1 only: the reasoning that format kept apart from messages.
A snapshot of the current version leaves it empty and does not write
it. Thread::restore moves a version 1 list into the conversation.
subagents: Vec<Subagent>Announced subagent lifecycle state.
interrupts: Vec<Interrupt>Questions which have not been confirmed as answered.
decided_interrupt_tool_call_ids: Vec<ToolCallId>Tool calls whose interrupt decisions were accepted by a later run.
abandoned: Vec<MessageId>The tool messages Thread::abandon_tool_call made: each stands in
for a result nobody produced.
Thread::merge_messages_from reads it to tell such a message from a
result. Not written when empty.
The field is optional and the format version stays 2. A version 1
snapshot, and a version 2 snapshot written before the field existed,
restore with nothing recorded, so every tool message they hold counts
as a result. An id that names no tool message of messages is
dropped on restore.
submission: Option<ResumeSubmission>A submitted decision whose acceptance has not been confirmed.
run_ids: Vec<RunId>Previously dispatched local run IDs, used to prevent reuse.
last_run_end: Option<RunEnd>The last locally observed termination, if any.
active_run_id: Option<RunId>A dispatched local run which had not ended when this snapshot was taken.