Skip to content

Commit 96ed85a

Browse files
Merge remote-tracking branch 'upstream/main' into HEAD
2 parents 7b951c8 + 23075af commit 96ed85a

5 files changed

Lines changed: 56 additions & 23 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,14 @@ describe("CodexAdapterV2 post-settle continuation", () => {
15301530
url: "http://127.0.0.1:43123/mcp",
15311531
tool_timeout_sec: 3_900,
15321532
http_headers: { Authorization: "Bearer secret-codex-token" },
1533+
disabled_tools: ["t3_thread_wait"],
1534+
},
1535+
"mcp_servers.t3-code-direct": {
1536+
url: "http://127.0.0.1:43123/mcp",
1537+
tool_timeout_sec: 3_900,
1538+
http_headers: { Authorization: "Bearer secret-codex-token" },
1539+
enabled_tools: ["t3_thread_wait"],
1540+
omit_tools_from: ["code_mode", "deferred"],
15331541
},
15341542
},
15351543
},

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,10 @@ export const CODEX_THREAD_CONFIG = {
13341334

13351335
// T3 waits can block for an hour; keep Codex's MCP timeout above that.
13361336
const CODEX_T3_MCP_TOOL_TIMEOUT_SEC = 65 * 60;
1337+
// Holds T3 tools Codex must call directly, never from Code Mode. Calls arrive as
1338+
// `t3-code-direct.<tool>`; t3McpToolPresentation.ts must keep resolving that form.
1339+
const CODEX_T3_DIRECT_MCP_SERVER = "t3-code-direct";
1340+
const CODEX_DIRECT_ONLY_T3_TOOL = "t3_thread_wait";
13371341

13381342
function codexThreadRuntimeParams(input: {
13391343
readonly threadId: ThreadId | null;
@@ -1346,6 +1350,14 @@ function codexThreadRuntimeParams(input: {
13461350
readonly config: Readonly<Record<string, Schema.Json>>;
13471351
} {
13481352
const { mcpSession } = input;
1353+
const t3Server =
1354+
mcpSession === undefined
1355+
? undefined
1356+
: {
1357+
url: mcpSession.endpoint,
1358+
tool_timeout_sec: CODEX_T3_MCP_TOOL_TIMEOUT_SEC,
1359+
http_headers: { Authorization: mcpSession.authorizationHeader },
1360+
};
13491361
return {
13501362
...(input.runtimePolicy?.cwd == null ? {} : { cwd: input.runtimePolicy.cwd }),
13511363
...(input.modelSelection === undefined ? {} : { model: input.modelSelection.model }),
@@ -1355,16 +1367,17 @@ function codexThreadRuntimeParams(input: {
13551367
...(input.threadId === null
13561368
? {}
13571369
: { [`shell_environment_policy.set.${PortScanner.AGENT_THREAD_ENV}`]: input.threadId }),
1358-
...(mcpSession === undefined
1370+
...(t3Server === undefined
13591371
? {}
13601372
: {
1361-
// Override only T3's server so launch-argument MCP servers survive.
1362-
"mcp_servers.t3-code": {
1363-
url: mcpSession.endpoint,
1364-
tool_timeout_sec: CODEX_T3_MCP_TOOL_TIMEOUT_SEC,
1365-
http_headers: {
1366-
Authorization: mcpSession.authorizationHeader,
1367-
},
1373+
// Override only T3's servers so launch-argument MCP servers survive.
1374+
"mcp_servers.t3-code": { ...t3Server, disabled_tools: [CODEX_DIRECT_ONLY_T3_TOOL] },
1375+
// Code Mode runs a blocking wait as a nested call, and the model keeps working
1376+
// around it. A second, direct-only registration makes it a plain tool call.
1377+
[`mcp_servers.${CODEX_T3_DIRECT_MCP_SERVER}`]: {
1378+
...t3Server,
1379+
enabled_tools: [CODEX_DIRECT_ONLY_T3_TOOL],
1380+
omit_tools_from: ["code_mode", "deferred"],
13681381
},
13691382
}),
13701383
},

‎docs/orchestration-v2/orchestrator-mcp-server.md‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,18 @@ check the `orchestration` capability before reading or mutating state.
5858

5959
### Codex V2
6060

61-
Codex app-server receives the remote MCP server through command-line config
62-
overrides:
63-
64-
```text
65-
-c mcp_servers.t3-code.url=http://127.0.0.1:<port>/mcp
66-
-c mcp_servers.t3-code.bearer_token_env_var="T3_MCP_BEARER_TOKEN"
67-
```
68-
69-
The provider-session token is placed in `T3_MCP_BEARER_TOKEN`. Both the
70-
production Codex launcher and the injectable test launcher use the same
71-
projection helper.
61+
Codex gets T3's MCP server in each thread's `thread/start`, `thread/resume`,
62+
and `thread/fork` config, with the provider-session token in an
63+
`Authorization` header. The same server is registered twice:
64+
65+
- `t3-code`: every tool except `t3_thread_wait`.
66+
- `t3-code-direct`: only `t3_thread_wait`, with `omit_tools_from = ["code_mode", "deferred"]`.
67+
68+
Code Mode runs a nested call as part of a script, so the model keeps working
69+
while a blocking wait runs. The second entry makes the wait a direct tool call,
70+
like Codex's own wait tools. Codex reports calls as `<server>.<tool>`, so
71+
`packages/shared/src/t3McpToolPresentation.ts` must resolve both server names.
72+
Tool display and pending-work detection depend on it.
7273

7374
### Claude Agent SDK V2
7475

‎packages/shared/src/t3McpToolPresentation.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ describe("resolveT3McpToolPresentation", () => {
1616
"mcp__t3_code__",
1717
"mcp__t3code__",
1818
"T3-code.",
19+
"t3code.",
20+
"t3-code-direct.",
21+
"mcp__t3_code_direct__",
1922
"t3_code/",
2023
"t3code:",
2124
"mcp_t3-code_",

‎packages/shared/src/t3McpToolPresentation.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ function tool(
8686
return { displayName, labels, icon, summaryAction };
8787
}
8888

89-
const T3_MCP_SERVER_ALIASES = new Set(["t3-code", "t3_code", "t3code"]);
89+
// Codex registers "t3-code-direct" for T3 tools kept out of Code Mode.
90+
const T3_MCP_SERVER_ALIASES = new Set([
91+
"t3-code",
92+
"t3_code",
93+
"t3code",
94+
"t3-code-direct",
95+
"t3_code_direct",
96+
]);
9097

9198
const T3_MCP_TOOLS: Readonly<Record<string, T3McpToolDefinition>> = {
9299
link_pull_request: tool(
@@ -386,9 +393,10 @@ function resolveT3McpToolName(value: string): string | null {
386393
: null;
387394
}
388395

389-
const namespaceMatch = /^(?<server>t3-code|t3_code|t3code)(?:[.:/]|\s*·\s*)(?<tool>.+)$/i.exec(
390-
label,
391-
);
396+
const namespaceMatch =
397+
/^(?<server>t3[-_]code[-_]direct|t3-code|t3_code|t3code)(?:[.:/]|\s*·\s*)(?<tool>.+)$/i.exec(
398+
label,
399+
);
392400
if (namespaceMatch?.groups) {
393401
return namespaceMatch.groups.tool ?? null;
394402
}

0 commit comments

Comments
 (0)