Skip to content

fix(server): Codex waits for request_secret instead of ending its turn - #42767

Open
juliusmarminge wants to merge 1 commit into
mainfrom
factory/issue-42749
Open

juliusmarminge wants to merge 1 commit into
mainfrom
factory/issue-42749

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

With Codex, an agent that asked for a secret kept working while the secret card was open and ended its turn after a few minutes. T3 then closed the card as cancelled and told the agent to ask again, so the card disappeared and the agent could re-ask in a loop. Codex was running request_secret from Code Mode, which returns control to the model while a call is still pending. request_secret now joins t3_thread_wait and delegate_task on the direct-only t3-code-direct MCP registration, so Codex calls it as a plain tool call that waits for the user's answer.

Fixes #42749

Reproduction on main

Commit e8fb0a0 (origin/main). Ran T3CODE_DEV_SEED=0 vp run dev in a fresh worktree and drove the web app in a browser. Thread 1, Codex GPT-6-Astra: sent 'Use request_secret right now (label "Test API token", reason "triage repro"). Do nothing else; report the tool's result in one line.' The secret card opened at 10:59:14 UTC and I left it unanswered. The provider log shows Codex accepting the MCP elicitation and leaving the mcpToolCall in progress while the model kept sampling every 20-60 s (about 600k tokens). At 11:06:34 the model ended the turn ('request_secret was invoked ... it remains pending with no result returned'). turn/completed came at 11:06:35.433, and T3 then marked the secret_request turn item cancelled (11:06:35.592; the UI shows 'Test API token · Request ended'). The MCP POST returned after 440.7 s with {status:'cancelled', note:'The card closed with the run. Ask again with a new clientRequestId only if the secret is still needed.'}. That was before the 10-minute server timeout and without any user action. Thread 2, Claude Haiku 5.5, same prompt at 11:04:30: the call blocked correctly, and the card was still pending with the run still running at 11:12. I did not see the follow-up re-ask turn myself, because the prompt told the agent to do nothing else; the note returned to the agent tells it to ask again.

Evidence

Requested a secret with the triage prompt on both builds and left it unanswered. Real web app, Chromium at 1280×800, light theme, isolated synthetic state; Codex CLI 0.172.0, GPT-6-Astra Medium, with Code Mode enabled on both sides.

Before After
21a96989b0 abc0987546
Before: unanswered card cancelled at turn completion After: card remains editable after eight minutes
Before recording: turn ends after 5m32s and the unanswered card becomes Request ended. After recording: card stays open beyond eight minutes; an explicit decline returns to Codex before the turn ends.

Base yielded the nested call after 31 seconds and consumed 611,892 input tokens while polling. Head made one direct blocking request_secret call and received its result only after Decline.

Reproduction script · Sanitized event timeline

Not shown:

  • The follow-up re-asking loop and repeated notifications were not exercised; the supplied prompt explicitly instructed the agent to do nothing else.
  • Secret submission and file delivery were not exercised; the head run verified unanswered waiting followed by explicit decline.

Tests

  • vp test run src/orchestration-v2/Adapters/CodexAdapterV2.test.ts (apps/server): 224 passed
  • vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (2 files) all pass
  • Manual: codex exec (0.172, features.code_mode=true) against a stub MCP tool that sleeps 100 s. On the default registration the model polled with 9 wait calls; with omit_tools_from=["code_mode","deferred"] it was one blocking call
  • CI on fix(server): Codex waits for request_secret instead of ending its turn #42767: all 8 required checks passed

Not in this change

  • requestSecret still closes the card and returns 'ask again' whenever the run ends for any other reason (interrupt, failure); that behaviour is unchanged.
  • Other long-blocking T3 tools that Codex may call from Code Mode were not audited.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

Codex ran request_secret from Code Mode, which yields the call after about
30 seconds and lets the model keep polling it. The model eventually ended the
turn, which closed the secret card as cancelled and told the agent to ask
again. request_secret now joins t3_thread_wait and delegate_task on the
direct-only t3-code-direct server, so Codex calls it as a plain blocking tool.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 21a9698 · PR result: abc0987 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Codex adapter adds request_secret to its direct-only T3 tools. The test expectation now places it among the disabled tools for t3-code and enabled tools for t3-code-direct. A nearby comment also refers to secret requests as nested calls in Code Mode.

Changes: T3 tool routing

Layer / File(s) Summary
Route request_secret as direct-only
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
The direct-only T3 tools list now includes request_secret. The comment describes secret requests among calls that Code Mode runs as nested calls. The test expects request_secret to be disabled on t3-code and enabled on t3-code-direct.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: yash-singh1, genesiscz, abhiram-745

Merge Risk: Minimal · up to abc09

Codex's request_secret card now blocks as a direct tool call, so it stays open until the user answers instead of closing when the turn ends. The change is a one-line tool registration with an updated test. No concrete merge-blocking risk was found, and it is easy to revert.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Codex waits for request_secret instead of ending its turn. The changeset adds request_secret to CODEX_DIRECT_ONLY_T3_TOOLS and updates the matching test, so the title …
Linked Issues check Passed [#42749] The issue requires that a request_secret card stay open until the user submits or cancels it, even when the agent ends its turn while waiting. The diff adds request_secret to CODEX_DIRECT_ONL…
Out of Scope Changes check Passed All changes connect to the issue. The CodexAdapterV2.ts edit adds one entry to CODEX_DIRECT_ONLY_T3_TOOLS and updates the adjacent comment to name secret requests. The CodexAdapterV2.test.ts edit upda…
Description check Passed The description covers all template sections. It states the problem (an unanswered request_secret card closes when Codex ends its turn, which triggers repeated re-asks), the change (request_secret mov…
Full details: Title check

Explanation

The title names the main change: Codex waits for request_secret instead of ending its turn. The changeset adds request_secret to CODEX_DIRECT_ONLY_T3_TOOLS and updates the matching test, so the title matches the fix. It follows the conventional commit format and is specific enough for a teammate scanning history.

Full details: Linked Issues check

Explanation

[#42749] The issue requires that a request_secret card stay open until the user submits or cancels it, even when the agent ends its turn while waiting. The diff adds request_secret to CODEX_DIRECT_ONLY_T3_TOOLS in apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts. The t3-code server disables it and the t3-code-direct server enables it. Codex then calls it as a plain blocking tool call instead of through Code Mode, so the agent cannot end its turn while the call is pending. The test in CodexAdapterV2.test.ts now asserts this registration. The PR reports a reproduction on main where the card closed at run end, and a manual codex exec check where the stub tool produced one blocking call. The Claude path was reported as already blocking. The issue names no other acceptance criteria. Gaps: the Evidence section (before and after in the app) is still pending, and the PR does not cover run ends caused by interrupt or failure, which the issue does not describe.

Full details: Out of Scope Changes check

Explanation

All changes connect to the issue. The CodexAdapterV2.ts edit adds one entry to CODEX_DIRECT_ONLY_T3_TOOLS and updates the adjacent comment to name secret requests. The CodexAdapterV2.test.ts edit updates the expected disabled and enabled tool lists for both MCP servers to include request_secret. No unrelated files or behavior changes appear in the reviewed diff. The PR description states that requestSecret cancel behavior on other run endings and other long-blocking tools are unchanged and unaudited. Those are exclusions, not changes in this PR.

Full details: Description check

Explanation

The description covers all template sections. It states the problem (an unanswered request_secret card closes when Codex ends its turn, which triggers repeated re-asks), the change (request_secret moves onto the direct-only t3-code-direct MCP registration next to t3_thread_wait and delegate_task), and the scope (it links issue #42749 as the bug report). Verification includes focused test results (224 passed), check:changed results, a manual codex exec comparison, and before/after evidence with a reproduction on main. It also states what was not exercised: the re-ask loop and secret submission. It names the model and harness that did the work, as the template asks. Minor gaps: the Problem section does not separate expected behavior from the observed behavior in a formal way, and the Evidence section links to external media that a reviewer cannot verify from the diff alone. These gaps do not block a decision.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 21a9698 and abc0987.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: request_secret card closes when the turn ends, so the agent loops re-asking

1 participant