@@ -86,8 +86,17 @@ export class CodexElicitationHandler implements ElicitationHandler {
8686 params : McpServerElicitationRequestParams
8787 ) : Promise < McpServerElicitationRequestResponse > {
8888 try {
89- const request = this . buildPermissionRequest ( params ) ;
89+ const { request, correlatedCallId } = this . buildPermissionRequest ( params ) ;
9090 const response = await this . connection . requestPermission ( request ) ;
91+ if ( correlatedCallId !== undefined && response . outcome . outcome !== "cancelled" ) {
92+ const optionId = response . outcome . optionId ;
93+ if ( optionId !== "decline" ) {
94+ await this . connection . sessionUpdate ( {
95+ sessionId : this . sessionState . sessionId ,
96+ update : { sessionUpdate : "tool_call_update" , toolCallId : correlatedCallId , status : "in_progress" } ,
97+ } ) ;
98+ }
99+ }
91100 return this . convertResponse ( response ) ;
92101 } catch ( error ) {
93102 logger . error ( "Error handling MCP elicitation request" , error ) ;
@@ -97,7 +106,7 @@ export class CodexElicitationHandler implements ElicitationHandler {
97106
98107 private buildPermissionRequest (
99108 params : McpServerElicitationRequestParams
100- ) : acp . RequestPermissionRequest {
109+ ) : { request : acp . RequestPermissionRequest ; correlatedCallId : string | undefined } {
101110 const sessionId = this . sessionState . sessionId ;
102111 const messageContent : acp . ToolCallContent = {
103112 type : "content" ,
@@ -119,39 +128,48 @@ export class CodexElicitationHandler implements ElicitationHandler {
119128 // item/started was emitted before the elicitation request. Sending content or
120129 // rawInput here would duplicate that information in the approval widget.
121130 return {
131+ request : {
132+ sessionId,
133+ toolCall : {
134+ toolCallId : correlatedCallId ,
135+ kind : "execute" ,
136+ status : "pending" ,
137+ // content: [messageContent], — omitted: already rendered via item/started
138+ // rawInput: { ... } — omitted: same reason
139+ } ,
140+ options,
141+ } ,
142+ correlatedCallId,
143+ } ;
144+ }
145+ return {
146+ request : {
122147 sessionId,
123148 toolCall : {
124- toolCallId : correlatedCallId ,
125- kind : "execute" ,
149+ toolCallId : `elicitation- ${ params . serverName } ` ,
150+ kind : isToolApproval ? "execute" : "other ",
126151 status : "pending" ,
127- // content: [messageContent], — omitted: already rendered via item/started
128- // rawInput: { ... } — omitted: same reason
152+ content : [ messageContent ] ,
153+ rawInput : { serverName : params . serverName , schema : params . requestedSchema } ,
129154 } ,
130155 options,
131- } ;
132- }
133- return {
134- sessionId,
135- toolCall : {
136- toolCallId : `elicitation-${ params . serverName } ` ,
137- kind : isToolApproval ? "execute" : "other" ,
138- status : "pending" ,
139- content : [ messageContent ] ,
140- rawInput : { serverName : params . serverName , schema : params . requestedSchema } ,
141156 } ,
142- options ,
157+ correlatedCallId : undefined ,
143158 } ;
144159 } else {
145160 return {
146- sessionId,
147- toolCall : {
148- toolCallId : `elicitation-${ params . elicitationId } ` ,
149- kind : "fetch" ,
150- status : "pending" ,
151- content : [ messageContent ] ,
152- rawInput : { serverName : params . serverName , url : params . url } ,
161+ request : {
162+ sessionId,
163+ toolCall : {
164+ toolCallId : `elicitation-${ params . elicitationId } ` ,
165+ kind : "fetch" ,
166+ status : "pending" ,
167+ content : [ messageContent ] ,
168+ rawInput : { serverName : params . serverName , url : params . url } ,
169+ } ,
170+ options,
153171 } ,
154- options ,
172+ correlatedCallId : undefined ,
155173 } ;
156174 }
157175 }
0 commit comments