@@ -113,6 +113,7 @@ export class CodexAcpServer implements acp.Agent {
113113 private readonly connection : acp . AgentSideConnection ;
114114 private readonly defaultAuthRequest : CodexAuthRequest | null ;
115115 private readonly getExitCode : ( ) => number | null ;
116+ private readonly getRecentStderr : ( ) => string ;
116117 private readonly availableCommands : CodexCommands ;
117118 private clientInfo : acp . Implementation | null ;
118119 private terminalOutputMode : TerminalOutputMode ;
@@ -130,6 +131,7 @@ export class CodexAcpServer implements acp.Agent {
130131 codexAcpClient : CodexAcpClient ,
131132 defaultAuthRequest ?: CodexAuthRequest ,
132133 getExitCode ?: ( ) => number | null ,
134+ getRecentStderr ?: ( ) => string ,
133135 ) {
134136 this . sessions = new Map ( ) ;
135137 this . pendingMcpStartupSessions = new Map ( ) ;
@@ -142,6 +144,7 @@ export class CodexAcpServer implements acp.Agent {
142144 this . codexAcpClient = codexAcpClient ;
143145 this . defaultAuthRequest = defaultAuthRequest ?? null ;
144146 this . getExitCode = getExitCode ?? ( ( ) => null ) ;
147+ this . getRecentStderr = getRecentStderr ?? ( ( ) => "" ) ;
145148 this . clientInfo = null ;
146149 this . terminalOutputMode = "terminal_output_delta" ;
147150 this . availableCommands = new CodexCommands (
@@ -1458,7 +1461,9 @@ export class CodexAcpServer implements acp.Agent {
14581461 throw new RequestError ( requestErrorCode , `VC++ redistributable should be installed` ) ;
14591462 }
14601463 if ( exitCode !== null ) {
1461- throw new RequestError ( requestErrorCode , `Codex process has exited with code ${ exitCode } ` ) ;
1464+ const stderr = this . getRecentStderr ( ) . trim ( ) ;
1465+ const detail = stderr ? `:\n${ stderr } ` : "" ;
1466+ throw new RequestError ( requestErrorCode , `Codex process has exited with code ${ exitCode } ${ detail } ` ) ;
14621467 }
14631468 throw err ;
14641469 }
0 commit comments