@@ -1083,8 +1083,7 @@ function isLightweightSession(session: Pick<AgentChatSession, "sessionProfile">)
10831083
10841084let _mcpRuntimeRootCache : string | null = null ;
10851085function resolveMcpRuntimeRoot ( ) : string {
1086- if ( _mcpRuntimeRootCache !== null ) return _mcpRuntimeRootCache ;
1087- _mcpRuntimeRootCache = resolveUnifiedRuntimeRoot ( ) ;
1086+ _mcpRuntimeRootCache ??= resolveUnifiedRuntimeRoot ( ) ;
10881087 return _mcpRuntimeRootCache ;
10891088}
10901089
@@ -1342,22 +1341,25 @@ export function createAgentChatService(args: {
13421341 ownerId ?: string | null ;
13431342 computerUsePolicy ?: ComputerUsePolicy | null ;
13441343 } ) => {
1345- const launch = resolveAdeMcpServerLaunch ( {
1344+ const { mode , command , entryPath , runtimeRoot , socketPath , packaged , resourcesPath } = resolveAdeMcpServerLaunch ( {
13461345 workspaceRoot : projectRoot ,
13471346 runtimeRoot : resolveMcpRuntimeRoot ( ) ,
13481347 defaultRole : args . defaultRole ,
13491348 ownerId : args . ownerId ?? undefined ,
13501349 computerUsePolicy : normalizeComputerUsePolicy ( args . computerUsePolicy , createDefaultComputerUsePolicy ( ) ) ,
13511350 } ) ;
1352- return {
1353- mode : launch . mode ,
1354- command : launch . command ,
1355- entryPath : launch . entryPath ,
1356- runtimeRoot : launch . runtimeRoot ,
1357- socketPath : launch . socketPath ,
1358- packaged : launch . packaged ,
1359- resourcesPath : launch . resourcesPath ,
1360- } ;
1351+ return { mode, command, entryPath, runtimeRoot, socketPath, packaged, resourcesPath } ;
1352+ } ;
1353+
1354+ /** Best-effort diagnostic: resolve the MCP launch config for a session, returning undefined on failure. */
1355+ const tryDiagnosticMcpLaunch = ( managed : ManagedChatSession ) : ReturnType < typeof summarizeAdeMcpLaunch > | undefined => {
1356+ try {
1357+ return summarizeAdeMcpLaunch ( {
1358+ defaultRole : managed . session . identityKey === "cto" ? "cto" : "agent" ,
1359+ ownerId : resolveWorkerIdentityAgentId ( managed . session . identityKey ) ,
1360+ computerUsePolicy : managed . session . computerUse ,
1361+ } ) ;
1362+ } catch { return undefined ; }
13611363 } ;
13621364
13631365 const readTranscriptConversationEntries = ( managed : ManagedChatSession ) : string [ ] => {
@@ -4692,14 +4694,7 @@ export function createAgentChatService(args: {
46924694 } ;
46934695
46944696 const startCodexRuntime = async ( managed : ManagedChatSession ) : Promise < CodexRuntime > => {
4695- let adeMcpLaunch : ReturnType < typeof summarizeAdeMcpLaunch > | undefined ;
4696- try {
4697- adeMcpLaunch = summarizeAdeMcpLaunch ( {
4698- defaultRole : managed . session . identityKey === "cto" ? "cto" : "agent" ,
4699- ownerId : resolveWorkerIdentityAgentId ( managed . session . identityKey ) ,
4700- computerUsePolicy : managed . session . computerUse ,
4701- } ) ;
4702- } catch { /* best-effort diagnostic — must not block Codex startup */ }
4697+ const adeMcpLaunch = tryDiagnosticMcpLaunch ( managed ) ;
47034698
47044699 logger . info ( "agent_chat.codex_runtime_start" , {
47054700 sessionId : managed . session . id ,
@@ -5191,17 +5186,10 @@ export function createAgentChatService(args: {
51915186 ) ;
51925187 }
51935188 let diagClaudePath : string | undefined ;
5194- let diagMcpLaunch : ReturnType < typeof summarizeAdeMcpLaunch > | undefined ;
51955189 try {
51965190 diagClaudePath = runtime . v2Session ? undefined : buildClaudeV2SessionOpts ( managed , runtime ) . pathToClaudeCodeExecutable ;
51975191 } catch { /* best-effort diagnostic */ }
5198- try {
5199- diagMcpLaunch = summarizeAdeMcpLaunch ( {
5200- defaultRole : managed . session . identityKey === "cto" ? "cto" : "agent" ,
5201- ownerId : resolveWorkerIdentityAgentId ( managed . session . identityKey ) ,
5202- computerUsePolicy : managed . session . computerUse ,
5203- } ) ;
5204- } catch { /* best-effort diagnostic */ }
5192+ const diagMcpLaunch = tryDiagnosticMcpLaunch ( managed ) ;
52055193 logger . warn ( "agent_chat.claude_v2_prewarm_failed" , {
52065194 sessionId : managed . session . id ,
52075195 error : error instanceof Error ? error . message : String ( error ) ,
0 commit comments