pub struct SessionStore { /* private fields */ }Expand description
Maps response_id → accumulated message history for that session.
Codex uses previous_response_id to continue a conversation; we maintain
the full messages[] here so each Chat Completions call is self-contained.
Also maintains call_id → reasoning_content so that thinking-capable models (e.g. kimi-k2.6) can have their reasoning_content round-tripped back when Codex replays tool-call history in subsequent requests.
For assistant messages without tool calls (pure text), reasoning_content
is indexed by a fingerprint of the prior messages + assistant content,
so it can be recovered when Codex replays the full conversation in input
without using previous_response_id.
Implementations§
Source§impl SessionStore
impl SessionStore
pub fn new() -> Self
Sourcepub fn store_reasoning(&self, call_id: String, reasoning: String)
pub fn store_reasoning(&self, call_id: String, reasoning: String)
Store reasoning_content keyed by the tool call_id so it can be injected back when the same call_id appears in a subsequent request.
Sourcepub fn get_reasoning(&self, call_id: &str) -> Option<String>
pub fn get_reasoning(&self, call_id: &str) -> Option<String>
Look up stored reasoning_content for a call_id.
Sourcepub fn store_turn_reasoning(
&self,
_prior: &[ChatMessage],
assistant: &ChatMessage,
reasoning: String,
)
pub fn store_turn_reasoning( &self, _prior: &[ChatMessage], assistant: &ChatMessage, reasoning: String, )
Store reasoning_content for an assistant turn, keyed by a fingerprint of the assistant message content and tool calls.
Sourcepub fn get_turn_reasoning(
&self,
_prior: &[ChatMessage],
assistant: &ChatMessage,
) -> Option<String>
pub fn get_turn_reasoning( &self, _prior: &[ChatMessage], assistant: &ChatMessage, ) -> Option<String>
Look up reasoning_content for an assistant turn by its text content.
Sourcepub fn get_history(&self, response_id: &str) -> Vec<ChatMessage>
pub fn get_history(&self, response_id: &str) -> Vec<ChatMessage>
Retrieve history for a prior response_id, or empty vec if not found.
Sourcepub fn new_id(&self) -> String
pub fn new_id(&self) -> String
Allocate a fresh response_id without storing anything yet. Use with save_with_id() for the streaming path.
Sourcepub fn save_with_id(&self, id: String, messages: Vec<ChatMessage>)
pub fn save_with_id(&self, id: String, messages: Vec<ChatMessage>)
Store under a pre-allocated response_id (streaming path).
Sourcepub fn save(&self, messages: Vec<ChatMessage>) -> String
pub fn save(&self, messages: Vec<ChatMessage>) -> String
Allocate an id and store atomically (non-streaming path).
Trait Implementations§
Source§impl Clone for SessionStore
impl Clone for SessionStore
Source§fn clone(&self) -> SessionStore
fn clone(&self) -> SessionStore
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more