Summary
Implement an AgentAdapter for OpenAI's Codex using the app-server JSON-RPC protocol defined in the Symphony spec. This adapter speaks the same protocol Symphony uses.
Parent issue: #408
Motivation
OpenAI's Codex has a well-defined app-server protocol (JSON-RPC over stdio) that Symphony already documents in detail (spec Section 10). Implementing this adapter makes CodeFrame compatible with the Codex ecosystem and any future agent that speaks this protocol.
Scope
New module: core/engines/codex.py
CodexAdapter implementing AgentAdapter:
class CodexAdapter:
name = "codex"
requires_api_key = {"OPENAI_API_KEY": "OpenAI API key"}
def execute(self, task_prompt, workspace_path, context, timeout_ms):
# 1. Launch codex app-server subprocess
# 2. Send initialize → initialized → thread/start → turn/start
# 3. Stream turn events
# 4. Handle turn/completed, turn/failed, turn/cancelled
# 5. Return AgentResult
...
-
App-server protocol implementation (per Symphony spec Section 10):
- JSON-RPC message framing over stdio
- Startup handshake:
initialize → initialized → thread/start → turn/start
- Turn streaming: read line-delimited JSON events
- Completion detection:
turn/completed, turn/failed, turn/cancelled
- Approval handling: auto-approve by default (configurable)
- Timeout:
turn_timeout_ms, read_timeout_ms, stall_timeout_ms
-
Configuration:
codex_command: path to Codex binary (default: codex app-server)
approval_policy: auto-approve, require-approval
sandbox_mode: configurable per Symphony spec
turn_timeout_ms: default 3600000 (1 hour)
-
Event mapping:
- Codex
session_started → AgentEvent(type="progress")
- Codex
turn_completed → AgentEvent(type="completed")
- Codex
notification → AgentEvent(type="progress")
- Token usage extraction from Codex events
Acceptance Criteria
Dependencies
Summary
Implement an
AgentAdapterfor OpenAI's Codex using the app-server JSON-RPC protocol defined in the Symphony spec. This adapter speaks the same protocol Symphony uses.Parent issue: #408
Motivation
OpenAI's Codex has a well-defined app-server protocol (JSON-RPC over stdio) that Symphony already documents in detail (spec Section 10). Implementing this adapter makes CodeFrame compatible with the Codex ecosystem and any future agent that speaks this protocol.
Scope
New module:
core/engines/codex.pyCodexAdapterimplementingAgentAdapter:App-server protocol implementation (per Symphony spec Section 10):
initialize→initialized→thread/start→turn/startturn/completed,turn/failed,turn/cancelledturn_timeout_ms,read_timeout_ms,stall_timeout_msConfiguration:
codex_command: path to Codex binary (default:codex app-server)approval_policy: auto-approve, require-approvalsandbox_mode: configurable per Symphony specturn_timeout_ms: default 3600000 (1 hour)Event mapping:
session_started→AgentEvent(type="progress")turn_completed→AgentEvent(type="completed")notification→AgentEvent(type="progress")Acceptance Criteria
CodexAdapterimplementsAgentAdapterprotocolcf work start <id> --execute --engine codexDependencies