@@ -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.
13361336const 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
13381342function 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 } ,
0 commit comments