Skip to main content

CodexStreamParser

Struct CodexStreamParser 

Source
pub struct CodexStreamParser { /* private fields */ }
Expand description

Stateful per-run wrapper over parse_codex_line that resolves codex’s preamble-vs-answer ambiguity and drops its stderr noise. One per run.

Codex emits several complete agent_message items in a turn: short preambles before tool calls (“I’ll read the file first”) and a final answer. Nothing on the item distinguishes them — the only signal is position: the last agent_message before turn.completed is the answer; every earlier one is a preamble. So we hold the latest agent_message and classify it by what follows — another item means it was a preamble (→ RunEvent::Activity, transient narration), turn.completed (or stream end) means it was the answer (→ RunEvent::Text). Without this the preambles concatenate onto the answer in the bubble.

It also drops codex’s stderr: in --json mode codex writes only tracing logs there (“Reading additional input…”, internal ERROR codex_core::… lines) and reports real failures as stdout error items — so stderr is pure noise, not status.

Implementations§

Source§

impl CodexStreamParser

Source

pub fn new() -> Self

Source

pub fn on_process_event(&mut self, event: ProcessEvent) -> Vec<RunEvent>

Normalize one raw process event, applying the agent_message state machine to stdout and dropping stderr noise.

Trait Implementations§

Source§

impl Debug for CodexStreamParser

Source§

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

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

impl Default for CodexStreamParser

Source§

fn default() -> CodexStreamParser

Returns the “default value” for a type. Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.