feat(codex): live agent status from the app-server event stream (A3) - #236
Merged
Conversation
Codex agents were status-blind (flat "running") — no hook relay. A3 sources their working-status (busy/idle) from the app-server daemon instead, reusing A2's per-agent control client: - codexControl.ts: the client now connects EAGERLY at spawn (startCodexStatusWatch) and runs a status loop — thread/status/changed pushes for instant updates plus a periodic thread/read reconcile (STATUS_POLL_MS) as the safety net so a missed push can't leave the dashboard stale. queryIdle (the inbound idle-gate) also emits status, for free. - routes/hooks.ts: setAgentStatus() sets the in-memory status map directly (the daemon gives ground truth, so no deriveStatus event-machine needed). The dashboard polls this map exactly as it does for CC/Gemini — zero dashboard change. - gateway/index.ts: wires the status sink to setAgentStatus. - runtime.ts: starts the watch at spawn for sidecar (Codex) agents; guarded so cosmetic status can never break a spawn. Hardened from /polish: - connect() now settles on socket close/error + a connect timeout — previously its promise resolved/rejected only in onopen, so a daemon that died mid-life left the status loop (and the pre-existing drain path) parked forever. This is the exact staleness the reconciler exists to prevent. - statusLoop counts consecutive failures and raises a dashboard SystemWarning when a daemon is persistently unreachable, instead of silently never reconciling. - unrecognized Codex status types are logged once (not silently dropped); respawn TOCTOU fixed (getOrCreate treats a disposed controller as absent); the string->AgentStatus cast is gone (CodexStatus union, checked end-to-end). Verified with a real-spawn E2E: a Codex agent transitions idle -> working -> idle in the live status map. Full suite green, biome + tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016qfhGLXBWPQM8a2ixVrnZY
aterrylu
enabled auto-merge (squash)
June 20, 2026 21:31
nox-0x
approved these changes
Jun 20, 2026
nox-0x
left a comment
Collaborator
There was a problem hiding this comment.
Approving — clean, well-defended A3 wiring: eager status loop with periodic reconciler, connect promise now settles on close/error/timeout so a dead daemon can't park awaiters, respawn-safe getOrCreate, unmapped status types logged-once instead of silently dropped, and threshold-bounded SystemWarning on persistent feed failure. setAgentStatus is a focused minimal surface on hooks.ts and feeds the same dashboard map as CC/Gemini with no cast (closed CodexStatus union). Test coverage is on the right contract (set/transition/dedupe/clear-tool). No blocking issues.
This was referenced Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Codex agents were status-blind — no hook relay, so the dashboard showed a flat "running" regardless of whether the agent was working, idle, or done. CC/Gemini show live busy/idle via the hook→
deriveStatuspath; Codex had nothing.Solution
Source Codex working-status from the app-server daemon's event stream (which A1/A2 already connect to), and feed it into the same in-memory status map CC/Gemini use — so no dashboard changes were needed.
startCodexStatusWatch) and runs a status loop:thread/status/changedpushes for instant updates + a periodicthread/readreconcile as a safety net (a missed push can't leave the dashboard stale). The inbound idle-gate'sthread/readalso emits status, for free.setAgentStatus()sets the status map directly — the daemon gives ground truth, so noderiveStatusevent-machine / fake-event synthesis is needed.gateway/index.ts; started at spawn inruntime.ts(guarded — cosmetic status can never break a spawn).Hardened from
/polish(3-agent review)connect()wedge — its promise settled only inonopen, so a mid-life daemon death left the status loop (and the pre-existingdrainpath) parked forever. Now settles on close/error + a connect timeout → the loop retries.statusLoopnow counts failures and raises a dashboardSystemWarningwhen a daemon is persistently unreachable.as AgentStatuscast removed via aCodexStatusunion (checked end-to-end).Testing
idle → working → idlein the live status map (observed sequence asserted).setAgentStatus(set/transition/dedupe/clear). Full suite green, biome + tsc clean.Note
This needs no dashboard changes — so a provider-distinct status icon (Claude vs Codex, using the existing
agent.provider) is a clean, separate follow-up.🤖 Generated with Claude Code