Skip to main content

Module session

Module session 

Source
Expand description

Stateful multi-turn session manager for the Codex CLI.

Session wraps a Codex client and automatically threads conversation state across turns. The first call to send dispatches via ExecCommand; subsequent calls use ExecResumeCommand with the captured thread_id.

§Example

use std::sync::Arc;
use codex_wrapper::{Codex, Session};

let codex = Arc::new(Codex::builder().build()?);
let mut session = Session::new(codex);

let events = session.send("create a hello world program").await?;
println!("turn 1: {} events", events.len());

let events = session.send("now add error handling").await?;
println!("turn 2: {} events, thread_id={:?}", events.len(), session.id());

Structs§

Session
Stateful multi-turn session manager.
TurnRecord
A record of a single turn within a session.