-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Problem
When codex-acp creates a new session via new_session(), the Codex internal thread ID is used as the ACP sessionId in NewSessionResponse::new(session_id). However, ACP session managers like acpx extract the agent's internal session identifier from _meta.agentSessionId or _meta.sessionId — not from the top-level sessionId field.
This means the agent's internal thread ID is available but not surfaced through _meta, so ACP orchestrators cannot link back to the Codex session logs on disk.
Context
The ACP session identity model (as implemented by acpx v0.1.15) defines three distinct IDs:
| Field | Semantics |
|---|---|
acpxRecordId |
Stable session manager record key |
acpSessionId |
ACP wire session ID (the sessionId from NewSessionResponse) |
agentSessionId |
Agent's internal session/thread ID — extracted from _meta |
acpx extracts agentSessionId via:
const AGENT_SESSION_ID_META_KEYS = ["agentSessionId", "sessionId"];
function extractAgentSessionId(meta) {
// looks at result._meta.agentSessionId or result._meta.sessionId
}Currently codex-acp does not set _meta on NewSessionResponse, so agentSessionId is always undefined.
Proposed Fix
In src/codex_agent.rs, add .meta() to the NewSessionResponse:
// current (line ~371):
Ok(NewSessionResponse::new(session_id)
.modes(load.modes)
.models(load.models)
.config_options(load.config_options))
// proposed:
Ok(NewSessionResponse::new(session_id.clone())
.meta(serde_json::json!({"sessionId": session_id.0}))
.modes(load.modes)
.models(load.models)
.config_options(load.config_options))Similarly for load_session().
Use Case
We use OpenClaw + acpx to orchestrate Codex as an ACP sub-agent. With agentSessionId populated, we can:
- Link ACP session records to Codex's native session logs (
~/.codex/sessions/) - Provide end-to-end session debugging and conversation history transparency
- Correlate Codex thread IDs in SQLite with ACP session metadata
Without this, the only linking method is UUIDv7 timestamp heuristics between acpxRecordId and Codex thread.id, which is unreliable in retry scenarios.
Version
Tested against @zed-industries/[email protected] + [email protected].