What happened?
Under the codex_app_server runtime (openai_runtime: codex_app_server), multi-turn conversations on the gateway lose the Codex thread's working context between messages.
The runtime is documented to keep "one Codex thread per Hermes session" (agent/transports/codex_app_server_session.py), but the gateway builds a fresh AIAgent per inbound message, so agent._codex_session is None at the start of every turn and ensure_started() issues a brand-new thread/start. Because a Codex thread's working context (files read, command output, plan state, long-running task state) lives inside the thread — turn/start only sends the latest user message — every follow-up message hands the model an empty thread and silently loses all prior work.
Steps to reproduce
- Enable
openai_runtime: codex_app_server.
- On a gateway platform (Discord/Telegram), message 1: "read file X".
- Message 2: "what did you just read?"
Observed: the model has no memory of message 1 (a fresh thread/start ran). Agent logs show distinct codex thread ids per message within one session.
Expected
The session resumes the same Codex thread across turns (codex app-server exposes thread/resume {threadId}, which reloads the persisted rollout from disk), preserving context until the conversation is explicitly reset (/new).
Environment
- Codex CLI 0.133.0
- Runtime:
codex_app_server, gateway (Discord)
What happened?
Under the
codex_app_serverruntime (openai_runtime: codex_app_server), multi-turn conversations on the gateway lose the Codex thread's working context between messages.The runtime is documented to keep "one Codex thread per Hermes session" (
agent/transports/codex_app_server_session.py), but the gateway builds a freshAIAgentper inbound message, soagent._codex_sessionisNoneat the start of every turn andensure_started()issues a brand-newthread/start. Because a Codex thread's working context (files read, command output, plan state, long-running task state) lives inside the thread —turn/startonly sends the latest user message — every follow-up message hands the model an empty thread and silently loses all prior work.Steps to reproduce
openai_runtime: codex_app_server.Observed: the model has no memory of message 1 (a fresh
thread/startran). Agent logs show distinct codex thread ids per message within one session.Expected
The session resumes the same Codex thread across turns (codex app-server exposes
thread/resume {threadId}, which reloads the persisted rollout from disk), preserving context until the conversation is explicitly reset (/new).Environment
codex_app_server, gateway (Discord)