pub struct QueryResult {
pub result: String,
pub session_id: Option<String>,
pub thread_id: Option<String>,
pub usage: Option<TokenUsage>,
pub events: Vec<JsonLineEvent>,
}Expand description
A typed summary of a completed codex exec run, assembled from the JSONL
event stream.
This mirrors the shape of claude-wrapper’s QueryResult so a downstream
abstraction can treat both wrappers uniformly. The full parsed event stream
is retained in events as an escape hatch for fields
not surfaced here.
Fields§
§result: StringAssistant text, concatenated from the turn’s agent-message items.
Empty when the turn produced no agent message. A failed turn can still carry text produced before its terminal failure; native rollout-budget exhaustion is one observed example.
session_id: Option<String>The session_id captured from the event stream, if any.
Observed live runs carry only thread_id, so this is usually None.
Retained because it costs nothing and the field may exist under auth
modes not yet observed.
thread_id: Option<String>The thread_id captured from the event stream, if any.
Codex’s native identifier for resuming a conversation, emitted on
thread.started.
usage: Option<TokenUsage>Token counts from the terminal turn.completed event, if present.
The CLI reports tokens, not money. There is no cost field to read; see
TokenUsage.
events: Vec<JsonLineEvent>The full parsed event stream this result was assembled from.
The escape hatch for anything not surfaced above, including whatever this parser gets wrong.
Implementations§
Source§impl QueryResult
impl QueryResult
Sourcepub fn from_events(events: Vec<JsonLineEvent>) -> Self
pub fn from_events(events: Vec<JsonLineEvent>) -> Self
Assemble a QueryResult from a parsed JSONL event stream.
usage comes from the last turn.completed event; result is every
agent-message item concatenated in order; session_id and thread_id
are the first occurrences in the stream.
Trait Implementations§
Source§impl Clone for QueryResult
impl Clone for QueryResult
Source§fn clone(&self) -> QueryResult
fn clone(&self) -> QueryResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more