perf: stream Codex turns over a persistent app-server

↗ view on GitHub · Eli Ziff · 2026-07-27 · c85ef03a

`codex exec` respawned the CLI every turn (~320-930ms of process init) and
emitted the assistant message only as a single item.completed lump, so
firstContentLatencyMs landed within ~0.4s of totalLatencyMs - users waited out
the whole generation before seeing a character.

Adds a `codex app-server` adapter: one persistent JSON-RPC child per auth
identity, newline-delimited framing, real `item/agentMessage/delta` streaming,
per-thread mike_runtime MCP bridge config, turn/interrupt-backed aborts, and a
transparent fallback to the exec path (BEAVER_CODEX_EXEC=1 forces it).

The app-server has no --ignore-user-config, so it runs against an isolated
CODEX_HOME that mirrors the CLI login; that keeps the operator config.toml MCP
servers, hooks, and plugins out of Beaver turns as the exec path already does.

Measured on codex-cli 0.145.0, gpt-5.3-codex-spark, effort low:
exec 1 content delta at 3.4-4.9s; app-server 8-9 deltas at 2.0-2.9s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QUsMXzBsEJ27DjJVPSfW5o
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Committed
Parents c1142333
Stats 6 files changed , +959 , -69
Part of Codex integration and hardening

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-c85ef03a.md from inside the repo you want the change in.

⬇ Download capture-commit-c85ef03a.md