Skip to main content

Event

Enum Event 

Source
#[non_exhaustive]
pub enum Event { Init { session_id: String, harness: String, api_schema: String, model: String, cwd: String, max_turns: Option<u32>, preamble: Vec<Message>, tools: Vec<Value>, }, Message { message: Message, }, MessageDelta { text: String, }, MessageDeltaReset { reason: String, }, Result { report: Report, }, Error { message: String, }, Approval { tool_use_id: String, tool_name: String, decision: String, wait_ms: u64, }, }
Expand description

One event in the stream-json trajectory (one JSON object per line).

The stream is a self-sufficient, replayable source of the whole run: Init carries the base prompt + tool specs + model, and each Event::Message carries a full turn — so reconstruct_conversation rebuilds the entire history with nothing else. (Claude Code’s stream omits system/tools, forcing a proxy capture to recover them; Init closes that gap.) #[non_exhaustive] so events can be added (e.g. per-turn markers) without a breaking change.

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

Init

Emitted once at the start — everything needed to reconstruct context.

Fields

§session_id: String

The session identifier.

§harness: String

The harness pack in use (e.g. grok).

§api_schema: String

The wire schema in use (e.g. anthropic) — the provider’s api_schema().

§model: String

The model id.

§cwd: String

The working directory.

§max_turns: Option<u32>

The max-turns ceiling; absent = unlimited (the default — ADR-0005 amendment 2026-07-18).

§preamble: Vec<Message>

The base System + Developer messages (prompt + capabilities).

§tools: Vec<Value>

The tool specs offered to the model (name + JSON schema), as JSON values.

§

Message

A full message appended to the history (the trace): role + content blocks.

Fields

§message: Message

The appended message.

§

MessageDelta

An incremental assistant-text fragment during a streaming turn (ADR-0021). Display-only: the whole Message is still appended at turn end, so deltas are not part of the reconstructed history (the trace stays whole-message — Q1). Emitted only when the engine runs in streaming mode; consumers that want a whole-message trace drop this variant.

Fields

§text: String

One assistant-text fragment — append to the live buffer.

§

MessageDeltaReset

The in-flight streamed message was abandoned, and every Event::MessageDelta emitted since the last Event::Message is void.

The engine resamples a turn after a retryable provider error, re-running the same request — so a stream that failed part-way is followed by a second stream of the same reply from the start. Without this marker a consumer that buffers deltas shows the reply twice. Discard the buffer and start it over; the turn itself is not lost.

Consumers that ignore Event::MessageDelta (the whole-message trace) can ignore this too — the eventual Event::Message is unaffected.

A caveat this event cannot fix: text a UI has already committed to the terminal’s scrollback cannot be withdrawn, so a long partial reply may still be visible above the re-streamed one.

Fields

§reason: String

Why the stream was abandoned — the provider error, for the trace.

§

Result

The terminal event: the final report (identical to --output-format json).

Fields

§report: Report

The run’s report envelope.

§

Error

A non-terminal error note (e.g. a retry); terminal errors ride in Event::Result.

Fields

§message: String

A human-readable message.

§

Approval

An approver resolution at the dispatch gate (ADR-0017) — grok’s journal shape (PermissionResolved). Emitted for every consulted call, allowed or denied, so interactive traces are complete; wait_ms (human decision latency) is unrecoverable from any other artifact.

Fields

§tool_use_id: String

The tool_use id the decision applies to.

§tool_name: String

The client-facing tool name.

§decision: String

The resolution: "allow" or "deny".

§wait_ms: u64

Milliseconds spent awaiting the approver (human decision latency).

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

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 Event

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnsafeUnpin for Event

§

impl UnwindSafe for Event

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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