Tutorial agent demonstrating the convert_codex_to_agentex_events tap,
CodexTurn, and UnifiedEmitter for a sync (HTTP-yield) ACP agent.
- Spawning
codex exec --jsonas a local asyncio subprocess (no Scale sandbox). - Wrapping the stdout line stream in a
CodexTurn. - Delivering every canonical
StreamTaskMessage*event to the HTTP caller viaUnifiedEmitter.yield_turn(tracing as a side-effect).
Production isolation note: A tutorial agent runs the Codex CLI locally. Production-grade isolation (Scale sandbox, secret injection, MCP configuration) is handled by the golden agent at
teams/sgp/agents/golden_agent/project/harness/providers/codex.py.
Live runs require:
- The
codexCLI on PATH:npm install -g @openai/codex OPENAI_API_KEYset in the environment.
The offline tests inject a fake subprocess and never invoke the real CLI:
cd /path/to/scale-agentex-python
uv run --all-packages --all-extras pytest examples/tutorials/00_sync/harness_codex/tests/test_agent.py -qexport CODEX_LIVE_TESTS=1
export OPENAI_API_KEY=sk-...
# Start the agent server first, then:
pytest tests/test_agent.py -v