Repository navigation
fix(agents): settle nested code mode bridge calls - #128440
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 9:58 PM ET / August 24, 2026, 01:58 UTC. ClawSweeper reviewWhat this changesThe PR prevents nested Code Mode bridge calls from re-entering the outer reply-flush boundary and makes them settle when the call, run, or context closes. Merge readinessNo blocking correctness finding found. Current main still lacks the nested lifecycle boundary and closure races, so this active maintainer PR remains necessary; its availability-sensitive path should proceed through normal exact-head merge validation. Priority: P1 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherCode Mode converts JavaScript tool calls into embedded agent tool lifecycles. The lifecycle invokes the target tool, handles presentation and cancellation, then returns a settled result to the suspended Code Mode run. flowchart LR
A[Code Mode JavaScript] --> B[Bridge request]
B --> C[Embedded tool lifecycle]
C --> D{Nested lifecycle?}
D -->|Yes| E[Skip duplicate reply flush]
D -->|No| F[Flush reply boundary]
E --> G[Run target with closure race]
F --> G
G --> H[Settled result to Code Mode]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +25, Tests +282. Total +307 across 7 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single nested-lifecycle marker and shared abort race at the bridge/lifecycle owners; no net-neutral absorption was identified because call, context, and run closure must all settle the stored bridge result. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main re-enters the ordinary lifecycle start for an inner bridge target, whose reply flush can await the outer presentation boundary; the added harness models that cycle and its closure variants. Is this the best way to solve the issue? Yes. Marking the nested lifecycle at its owner and racing settlement at the bridge boundary is narrower and safer than suppressing flushes in target tools or adding downstream timeouts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 24c463749fb1. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where users running QuickJS Code Mode with a nested bridge tool call could see the run remain in
waiting/pending_toolsindefinitely without the requested target ever being invoked. The nested synthetic lifecycle recursively awaited the outer block-reply presentation flush, creating a deadlock before the call produced any outcome.Why This Change Was Made
Make the nested synthetic lifecycle skip only the duplicate block-reply presentation boundary while preserving normal hooks, telemetry, and approvals. Race bridge calls against call, run, and context closure, and ensure each bridge call settles and wakes the owner exactly once.
Landed #128088 handles outcomes after they exist; this change fixes calls that never produced an outcome.
User Impact
QuickJS Code Mode nested bridge calls reach their target and finish deterministically, including cancellation and closure paths, instead of silently hanging before invocation. Existing lifecycle hooks, telemetry, and approval behavior remain intact.
Evidence
waiting/pending_toolswith zero target invocations.node scripts/run-vitest.mjs src/agents/code-mode.bridge.lifecycle.test.ts src/agents/code-mode.bridge.test.ts src/agents/code-mode.wait.test.ts src/agents/code-mode.agent-loop.test.ts src/agents/code-mode-worker-lifecycle.test.ts— five files, 66 tests passed across two Vitest shards.+81/-60(net+21); tests/test-support:+289/-3(net+286).