Skip to content

perf(server): Codex calls t3_thread_wait directly instead of from Code Mode - #29026

Merged
t3dotgg merged 1 commit into
mainfrom
perf/codex-direct-thread-wait
Nov 2, 2026
Merged

t3dotgg merged 1 commit into
mainfrom
perf/codex-direct-thread-wait

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Nov 2, 2026

Copy link
Copy Markdown
Member

Codex runs T3's MCP tools inside Code Mode. A blocking t3_thread_wait there is a nested call in a script, so the model keeps working around the wait and burns tokens. The Codex team suggested taking the wait out of Code Mode, like Codex's own wait and multi-agent tools.

Each Codex thread now gets T3's MCP server twice, with the same URL, auth, and timeout:

  • t3-code: every T3 tool except t3_thread_wait.
  • t3code: only t3_thread_wait, with omit_tools_from = ["code_mode", "deferred"], so Codex exposes it as a direct tool.

t3code is already a known T3 server alias, so tool display and "waiting" detection work unchanged. Codex versions without omit_tools_from ignore the key and behave as before.

Proof: real Codex 0.166.0 (codex exec, Code Mode on) against a mock Responses API and a mock T3 MCP server. In the captured model request, the old config has no direct T3 tool. The new config has a direct mcp__t3code → t3_thread_wait next to Codex's wait_agent and sleep. The other T3 tools stay where they were. The adapter config test pins the new shape.

Known limits:

  • If a user's own ~/.codex/config.toml defines a t3code server, or customizes T3's injected t3-code server, the per-thread override conflicts with or replaces it. T3 never creates either, and the same risk already exists for t3-code.
  • Follow-up: the evals/mcp-tool-use Codex simulator still offers the wait inside Code Mode.

Council review

Rounds: 2

Delegate Round 1 Round 2
Claude Opus 5.5 8.5/10 9/10
Muse Wonder Full 9/10 9/10
Codex GPT-6.1 Sol 9/10 10/10

Made with Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

Codex Code Mode runs MCP tools as nested calls inside a script. A blocking
t3_thread_wait there leaves the model working around the wait and burning
tokens. Register T3's MCP server twice: `t3-code` without the wait, and
`t3code` with only the wait and `omit_tools_from = ["code_mode", "deferred"]`,
so Codex exposes it as a direct tool like its own wait tools.

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:M 30-99 changed lines (additions + deletions). labels Nov 2, 2026
@macroscopeapp

ghost commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — Codex thread waits now run as direct blocking tool calls rather than nested Code Mode calls, automatically changing behavior for MCP-enabled threads. Human review is needed to confirm this default coordination behavior is intended.

You can add or adjust custom eligibility rules. Learn more.

@github-actions

ghost commented Nov 2, 2026

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.3 KiB 1.3 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.6 KiB 21.6 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 2 2 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.3 KiB 1.3 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 2 2 0 (0.0%) 8 ✅

Baseline: 4a5251b · PR result: 78d529f · 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

ghost commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

Codex now receives T3 MCP settings through thread configuration. The settings register general tools as t3-code and t3_thread_wait as t3code. Tool presentation tests and documentation cover the aliases and configuration.

Changes: Codex T3 MCP registration

Layer / File(s) Summary
Configure and verify T3 MCP registrations
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts, docs/orchestration-v2/orchestrator-mcp-server.md, packages/shared/src/t3McpToolPresentation.test.ts
Codex thread configuration uses the session endpoint, a 65-minute timeout, and an authorization header. It registers general tools under t3-code and t3_thread_wait under t3code. The documentation and tests cover the configuration and alias recognition.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Codex
  participant CodexAdapterV2
  participant T3MCPServer
  Codex->>CodexAdapterV2: Start, resume, or fork thread with MCP configuration
  CodexAdapterV2->>T3MCPServer: Configure t3-code and t3code with session authorization
  Codex->>T3MCPServer: Call t3_thread_wait through t3code
Loading

Possibly related issues

  • pingdotgg/t3code#26120 — The issue describes the mismatch between launcher overrides and per-thread configuration that this change updates.

Suggested reviewers: juliusmarminge, lnieuwenhuis

Merge Risk: Low · up to 78d52

Codex now calls the thread-wait tool directly instead of through Code Mode. A user who has hand-configured an MCP server named t3code could see thread start or resume fail, and this is already documented as a known limit. The change is otherwise mergeable.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: Codex now calls t3_thread_wait directly instead of through Code Mode.
Description check Passed The description clearly explains the problem, implementation, verification evidence, known limits, and follow-up scope. It does not use the template headings or provide an explicit linked issue or mai…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, implementation, verification evidence, known limits, and follow-up scope. It does not use the template headings or provide an explicit linked issue or maintainer approval, but the content is mostly complete.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts-1373-1373: 1

1373-1373: Major · Security & Privacy · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Preserve configured tool restrictions.

A user’s t3-code.disabled_tools list is replaced by this list. Previously disabled tools, such as t3_thread_send, become available to the agent. The new t3code registration can also expose t3_thread_wait when the user’s t3-code.enabled_tools excludes it. Preserve the effective allow and deny lists across both registrations. (raw.githubusercontent.com)


Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 4a5251b and 78d529f.

Files selected for processing: 4
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts
  • apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts
  • docs/orchestration-v2/orchestrator-mcp-server.md
  • packages/shared/src/t3McpToolPresentation.test.ts

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

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

Labels

size:M 30-99 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.

1 participant