@@ -1334,6 +1334,9 @@ 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+ // Calls arrive as `t3code.<tool>`; t3McpToolPresentation.ts must keep resolving that form.
1338+ const CODEX_T3_WAIT_MCP_SERVER = "t3code" ;
1339+ const CODEX_DIRECT_ONLY_T3_TOOL = "t3_thread_wait" ;
13371340
13381341function codexThreadRuntimeParams ( input : {
13391342 readonly threadId : ThreadId | null ;
@@ -1346,6 +1349,14 @@ function codexThreadRuntimeParams(input: {
13461349 readonly config : Readonly < Record < string , Schema . Json > > ;
13471350} {
13481351 const { mcpSession } = input ;
1352+ const t3Server =
1353+ mcpSession === undefined
1354+ ? undefined
1355+ : {
1356+ url : mcpSession . endpoint ,
1357+ tool_timeout_sec : CODEX_T3_MCP_TOOL_TIMEOUT_SEC ,
1358+ http_headers : { Authorization : mcpSession . authorizationHeader } ,
1359+ } ;
13491360 return {
13501361 ...( input . runtimePolicy ?. cwd == null ? { } : { cwd : input . runtimePolicy . cwd } ) ,
13511362 ...( input . modelSelection === undefined ? { } : { model : input . modelSelection . model } ) ,
@@ -1355,16 +1366,17 @@ function codexThreadRuntimeParams(input: {
13551366 ...( input . threadId === null
13561367 ? { }
13571368 : { [ `shell_environment_policy.set.${ PortScanner . AGENT_THREAD_ENV } ` ] : input . threadId } ) ,
1358- ...( mcpSession === undefined
1369+ ...( t3Server === undefined
13591370 ? { }
13601371 : {
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- } ,
1372+ // Override only T3's servers so launch-argument MCP servers survive.
1373+ "mcp_servers.t3-code" : { ...t3Server , disabled_tools : [ CODEX_DIRECT_ONLY_T3_TOOL ] } ,
1374+ // Code Mode runs a blocking wait as a nested call, and the model keeps working
1375+ // around it. A second, direct-only registration makes it a plain tool call.
1376+ [ `mcp_servers.${ CODEX_T3_WAIT_MCP_SERVER } ` ] : {
1377+ ...t3Server ,
1378+ enabled_tools : [ CODEX_DIRECT_ONLY_T3_TOOL ] ,
1379+ omit_tools_from : [ "code_mode" , "deferred" ] ,
13681380 } ,
13691381 } ) ,
13701382 } ,
0 commit comments