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

merged1
main
perf/codex-direct-thread-wait
opened4d agobyTtheo
View on GitHubTwo-way sync enabledPR last imported 4d ago

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

DelegateRound 1Round 2
Claude Opus 5.58.5/109/10
Muse Wonder Full9/109/10
Codex GPT-6.1 Sol9/1010/10

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

🤖 Generated with Claude Code

Checks

24 successful · 12 skipped · 1 neutral
All checks passed
78d529f

Added 1 commit

  • perf(server): Codex calls t3_thread_wait directly, not from Code Mode78d529f
Synced from GitHub

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.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.3 KiB1.3 KiB0 B (0.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
ClaudeLive turn messages220 (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.

Synced from GitHub

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)

mermaid
1sequenceDiagram
2 participant Codex
3 participant CodexAdapterV2
4 participant T3MCPServer
5 Codex->>CodexAdapterV2: Start, resume, or fork thread with MCP configuration
6 CodexAdapterV2->>T3MCPServer: Configure t3-code and t3code with session authorization
7 Codex->>T3MCPServer: Call t3_thread_wait through t3code

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: External image 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 nameStatusExplanation
Title checkPassedThe title clearly identifies the primary change: Codex now calls t3_thread_wait directly instead of through Code Mode.
Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck 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
CcoderabbitaiBotreviewed4d ago
Synced from GitHub
External image Additional comments: 1
apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts-1373-1373: 1

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

External image 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)


External image Review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 4a5251b1c4b867ad2d89bf59d7a062ca8c40f2a6 and 78d529fd17f390fe5199bb545ba0d147f9b4b277.

External image 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.