Repository navigation
Show Codex model capacity failures as red agent status - #28231
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1ed488b5-dc3d-4180-809f-988660f12b76
📒 Files selected for processing (12)
src/main/agent-hooks/server-codex-capacity.test.tssrc/main/agent-hooks/server/server-ingest-terminal.tssrc/main/agent-hooks/server/server-status-update.tssrc/main/runtime/__fixtures__/codex-model-capacity-fullscreen.meta.jsonsrc/main/runtime/__fixtures__/codex-model-capacity-fullscreen.txtsrc/main/runtime/__fixtures__/codex-model-capacity.meta.jsonsrc/main/runtime/__fixtures__/codex-model-capacity.txtsrc/main/runtime/codex-capacity-terminal-status.test.tssrc/main/runtime/codex-capacity-terminal-status.tssrc/main/runtime/orca-runtime-maybe-hydrate-headless-from-renderer.tssrc/shared/agent-terminal-status-equivalence.tssrc/shared/codex-capacity-notice.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
…nce (#28286) #28231 added the codex-model-capacity-fullscreen PTY capture without an entry in the replay test's known-divergence table, so every PR's test shard fails on main (expected 0, got 12). The serializer is untouched; the divergence is the same restore limitation the table records. Co-authored-by: m4air <[email protected]>
ELI5
When Codex says the selected model is at capacity, Orca now replaces the agent's running spinner with its existing red failure indicator. Sending another prompt restores the running state.
What Changed
Recognize Codex's native capacity notice in live terminal output, verify it is the latest notice above the composer, and publish a failed main-agent turn into the execution host's existing hook status store. Preserve prompt, model, session identity and child work; keep the failure through a later Stop or child update, and clear it on the next prompt. Terminal status deduplication now respects an explicitly supplied main-agent verdict.
Why
Codex can finish an overloaded request without the completion hook Orca needs, leaving a misleading spinner. The bounded detector reuses Orca's escape scanner, headless terminal and status pipeline. It abandons unrelated warning text immediately and normalizes only bounded candidate fragments; command recognition is cached per emulator and invalidated when the startup command changes. This avoids another poller, process scan, or sidebar-only state. Source inspection covered Codex's
ServerOverloadederror and its TUI turn-finalization path in~/projects/codex.Linked Issue
Requested directly by a maintainer; no linked issue.
Visual Proof
Hidden Electron instance, real PTY, replay of a captured Codex capacity response in a folder project. Before: working. After: red failure indicator and the capacity message in the left sidebar. Retrying restored Working.
Testing
pnpm tcandpnpm run check:code-quality:changedpassed; changed files formatted withoxfmt.ORCA_BACKGROUND_LAUNCH=1 node --import tsx config/scripts/codex-capacity-status-benchmark.ts. Ordinary output causes zero screen/status reads; command classification occurs once per unchanged launch. No new polling or subprocesses.server_is_overloadedserver; both passed the transcript secret scan.Performance
Same local macOS machine, Node 24, median of five warmed runs. Baseline is commit
2cd76e307da; these numbers measure detection work rather than total Electron CPU or IPC/render time.At 100 captured TUI chunks per second, 45 µs/chunk extrapolates to roughly 0.45% of one CPU core per terminal for detection alone. The rare 40-column/24-row screen read measured about 0.5 µs; parsing and validating the complete captured failure took about 43 µs. Synthetic marker-flood input is included in the benchmark and regression tests.
Source inspection confirmed that the normal Codex TUI sets
persist_extended_history: false, error records require extended rollout history, and Stop hooks have no provider error code. A provider error hook would be the preferable upstream signal. Switching ordinary terminal sessions to a controlled app-server transport would be a separate launch architecture change.Review
Adversarial review found and fixed three issues:
2026parameter. It now recognizes2026in a mode list; tests prove zero screen reads until the combined redraw closes.Remaining heuristic limits are explicit: tool output that exactly imitates the native capacity notice immediately above the composer can produce a false failure. Terminal bytes alone cannot prove the provider error code. Conversely, a genuine notice arriving in the same millisecond as a new turn is conservatively skipped rather than risking marking the newer turn failed. A structured provider error hook would remove these ambiguities.
Checked execution-host ownership, prompt/model/session preservation, failure retention through child activity and Stop, retry recovery, stale output, frame boundaries, cache invalidation, large output and marker floods. No new polling, process scans, wire fields or stream opcodes. Physical Linux/Windows/SSH validation remains a stated gap; remote ownership and relay restatements are covered by unit tests.
Agent skill upstream boundary
Reliability Contract
Invariant (
agent-session.provider-ownership): only the execution host reports the capacity failure, a newer turn cannot be closed by queued old output, and subagent activity does not erase the failed root. The original capacity failure and this performance audit motivate the checks. The oracle is replay of captured Codex bytes through the runtime plus shared-store tests, with deterministic zero-read and command-classification counts. There is an accepted gap for a dedicated capacity entry in the reliability manifest; the focused gate isORCA_BACKGROUND_LAUNCH=1 pnpm test src/shared/codex-capacity-notice.test.ts src/main/runtime/codex-capacity-terminal-status.test.ts src/main/agent-hooks/server-codex-capacity.test.ts; five neighboring suites also passed. Captured fixtures and the benchmark JSON output provide diagnostic artifacts.Local runtime/store behavior is covered on macOS; remote ownership and relay restatements are covered by unit tests. Daemon lifecycle, WSL launch/path handling, and mobile/relay transport are unaffected by this optimization. Physical Linux/Windows/SSH validation remains a stated gap.
Notes
No new dependencies or styling. Trackers live in a WeakMap keyed by terminal emulator, and the text carry is bounded. Folder projects and git worktrees use the same terminal ingress.
Checklist