fix(codex/app-server): release session lane when projector throws on turn/completed#69072
Conversation
Greptile SummaryThis PR fixes a lane-lock regression where a throwing projector callback during Confidence Score: 5/5Safe to merge — the fix is minimal, well-scoped, and backed by a targeted regression test that reproduces the hang. The logic change is correct: computing No files require special attention. Reviews (1): Last reviewed commit: "fix(codex/app-server): release session l..." | Re-trigger Greptile |
37e09fd to
94e4800
Compare
94e4800 to
01a46b7
Compare
89ae4a6 to
5c6271f
Compare
|
Landed via temp rebase onto main.
Thanks @ayeshakhalid192007-dev! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c6271f66e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { | ||
| this.params.onAgentEvent?.(event); | ||
| } catch { | ||
| // Downstream event consumers must not corrupt the canonical Codex turn projection. |
There was a problem hiding this comment.
Preserve diagnostics when suppressing agent-event callback failures
Catching and dropping all onAgentEvent exceptions here makes downstream consumer failures completely silent: emitAgentEvent no longer throws, so run-attempt.ts's projector-level debug logging path is never reached for this class of error. In production this means broken event consumers (the exact regression class this patch targets) can keep losing plan/item/compaction events with no warning signal, which materially hurts incident triage and makes behavior regressions hard to trace.
Useful? React with 👍 / 👎.
Summary
session:agent:main:<session>lane lock./statusshows the run as still in progress.extensions/codex/src/app-server/run-attempt.ts, the notification pump now wrapsprojector.handleNotificationintry/finallyand computes the terminal-turn flag before invoking the projector, so a throw inside a downstream consumer still firesresolveCompletion(). The projector error is logged at debug and the run resolves cleanly.models.test.tsgot the sameawait vi.waitFor/vi.mockpattern thatshared-client.test.tsalready uses, so the full codex extension suite is reliably green while the new regression test runs.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
Regression Test Plan (if applicable)
User-visible / Behavior Changes
None user-visible on the happy path. Codex sessions where a downstream consumer throws during `turn/completed` now release their lane and surface the run result instead of wedging.
Diagram (if applicable)
```text
Before:
turn/completed -> projector.handleNotification -> throws
-> resolveCompletion() never called
-> completion pending
-> runCodexAppServerAttempt waits params.timeoutMs
-> session lane stays locked
-> follow-up messages queue forever
After:
turn/completed -> compute isTurnCompletion
-> try { projector.handleNotification } catch { debug-log }
-> finally { if (isTurnCompletion) resolveCompletion() }
-> completion resolves immediately
-> session lane released
-> follow-up messages flow
```
Security Impact (required)
Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Regression test in `extensions/codex/src/app-server/run-attempt.test.ts` fails on `upstream/main` without the fix and passes with it.
Human Verification (required)
Review Conversations
Compatibility / Migration
Risks and Mitigations