Skip to main content

RunEvent

Enum RunEvent 

Source
#[non_exhaustive]
pub enum RunEvent {
Show 14 variants Started { run_id: String, }, Session { run_id: String, session_id: Option<String>, model: Option<String>, }, Text { run_id: String, delta: String, }, Thinking { run_id: String, delta: String, }, ToolStart { run_id: String, tool_call_id: String, title: String, tool_kind: ToolKind, locations: Vec<ToolLocation>, raw_input: Option<String>, }, ToolEnd { run_id: String, tool_call_id: String, ok: bool, content: Option<String>, raw_output: Option<String>, locations: Vec<ToolLocation>, }, SuggestedEdits { run_id: String, edits: Vec<SuggestedEdit>, }, Activity { run_id: String, message: String, }, Usage { run_id: String, input_tokens: Option<u64>, output_tokens: Option<u64>, total_tokens: Option<u64>, cache_read_tokens: Option<u64>, cache_write_tokens: Option<u64>, cost_usd: Option<f64>, }, AskQuestion { run_id: String, request_id: String, questions: Vec<Question>, }, Plan { run_id: String, entries: Vec<PlanEntry>, }, SessionInfoUpdate { run_id: String, title: Option<String>, updated_at: Option<String>, }, Error { run_id: String, message: String, }, Exited { run_id: String, exit_code: Option<i32>, cancelled: bool, },
}
Expand description

The normalized event stream. #[serde(tag = "kind")] + camelCase mirrors the existing ProcessEvent wire contract the TS store already reads (event.kind, event.runId, …), so the front-end consumes one shape regardless of which harness produced it.

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

Started

First event, before any output. UI shows “thinking…”. Fired the instant the process spawns — before the CLI reports its session/model, which arrive separately as RunEvent::Session.

Fields

§run_id: String
§

Session

The agent session is established — its id and the model in use. Distinct from Started because it arrives a beat later, in the CLI’s first output line (bob’s init, Claude’s system/init, codex’s thread.started); keeping Started instant matters for the “thinking…” feedback. Either field may be absent when the CLI doesn’t report it (e.g. codex gives a thread id but no model). Constructible out-of-tree: any Harness (in-tree, or a third-party crate like openai-compatible) mints this directly, so it is not variant-#[non_exhaustive] — sealing it would break the open-producer contract (see the note on RunEvent::Exited).

Fields

§run_id: String
§session_id: Option<String>
§

Text

A chunk of assistant text. Appended to the active message.

Fields

§run_id: String
§delta: String
§

Thinking

A chunk of model reasoning (“thinking”), rendered distinctly from Text so the UI can show reasoning without mixing it into the answer (e.g. Claude’s thinking_delta).

Fields

§run_id: String
§delta: String
§

ToolStart

A tool call started — render a state-ful card keyed by id. Mirrors ACP’s ToolCall: title + kind + locations (files it touches) + the raw arguments (raw_input, omitted when streamed separately, e.g. Claude).

Fields

§run_id: String
§tool_call_id: String
§title: String
§tool_kind: ToolKind
§locations: Vec<ToolLocation>
§raw_input: Option<String>
§

ToolEnd

A tool call finished (matched to its start by id). Mirrors ACP’s tool result: content (human-readable, flattened to text) + raw_output (structured JSON) + the locations it touched. ok reduces ACP’s terminal Completed/Failed status to a flag.

Fields

§run_id: String
§tool_call_id: String
§ok: bool
§content: Option<String>
§raw_output: Option<String>
§locations: Vec<ToolLocation>
§

SuggestedEdits

One or more proposed edits. The app prepares + previews them.

Fields

§run_id: String
§

Activity

A human-readable status line (tool call, file touch, edit count). Replaces the message’s transient activity text.

Fields

§run_id: String
§message: String
§

Usage

Token accounting for the run, emitted near its end (from the CLI’s result / turn.completed). Neutral tokens only — harness-specific costs/credits (bob’s coins) are NOT here; a consumer that wants them reads the harness’s own output. Any field may be absent when the CLI doesn’t break usage down.

cache_read_tokens / cache_write_tokens are the prompt-cache counters reported separately from input_tokens (Claude’s cache_read_input_tokens / cache_creation_input_tokens) — not folded into input_tokens, and omitted from the wire when the CLI doesn’t report caching.

Fields

§run_id: String
§input_tokens: Option<u64>
§output_tokens: Option<u64>
§total_tokens: Option<u64>
§cache_read_tokens: Option<u64>

Prompt-cache tokens served from cache this run (~0.1x input cost).

§cache_write_tokens: Option<u64>

Prompt-cache tokens written to cache this run (~1.25x input cost).

§cost_usd: Option<f64>

Estimated cost in USD for this run, when the adapter knows per-token rates (openai-compatible via with_model_cost); None otherwise.

§

AskQuestion

The agent is asking the user one or more multiple-choice questions (Claude’s AskUserQuestion, Codex’s tool/requestUserInput). The host renders the options as selectable chips; the user’s pick is sent back as their next message on the existing chat path (which resumes the session), so the agent continues with the answer in hand. Carrying the questions as a neutral event keeps the harness-specific tool shape in the adapter — the host never name-checks AskUserQuestion (cf. ToolKind).

Fields

§run_id: String
§request_id: String

Identifies this question instance (the harness’s tool-call id), so the host can tie the answer + clear the chips for the right one.

§questions: Vec<Question>
§

Plan

The agent’s current task plan / todo list (Claude’s TodoWrite, Codex’s plan items), replacing any prior plan for this run. The host renders a checklist without knowing the harness’s native plan tool. The neutral plan vocabulary adapters map onto — the acp adapter from ACP plan, and openai-compatible from its todowrite tool.

Fields

§run_id: String
§entries: Vec<PlanEntry>
§

SessionInfoUpdate

A live update to the session’s display metadata — its title and/or last-updated time — emitted mid-run when the agent (re)names the conversation. Maps field-for-field onto ACP session_info_update (title + updatedAt); lets a sessions list show a meaningful title before the run ends. Both fields optional (a partial update).

Fields

§run_id: String
§updated_at: Option<String>

ISO-8601 timestamp of the update, when the harness reports one (ACP updatedAt). Omitted from the wire when absent.

§

Error

Spawn / IO / parse failure. Terminal — followed by Exited.

Fields

§run_id: String
§message: String
§

Exited

The run finished. Sent exactly once. Like every RunEvent variant it is constructible out-of-tree: harnesses live in their own crates (the Registry is open — openai-compatible, plus examples/custom_harness.rs), so no produced variant is variant-#[non_exhaustive] — that would close the producer door. The enum itself stays #[non_exhaustive], which protects consumers (a new variant just needs a _ arm) without blocking construction of the existing ones.

Fields

§run_id: String
§exit_code: Option<i32>
§cancelled: bool

Trait Implementations§

Source§

impl Clone for RunEvent

Source§

fn clone(&self) -> RunEvent

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 RunEvent

Source§

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

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

impl PartialEq for RunEvent

Source§

fn eq(&self, other: &RunEvent) -> 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 RunEvent

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 RunEvent

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.

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.