@@ -290,7 +290,6 @@ function buildResultData(result: unknown): Record<string, unknown> | undefined {
290290 return {
291291 success : r . success ,
292292 output : r . output ,
293- logs : r . logs ,
294293 error : r . error ,
295294 }
296295 }
@@ -300,7 +299,6 @@ function buildResultData(result: unknown): Record<string, unknown> | undefined {
300299 return {
301300 success : exec . success ,
302301 output : exec . output ,
303- logs : exec . logs ,
304302 error : exec . error ,
305303 }
306304 }
@@ -320,17 +318,37 @@ async function reportCompletion(
320318 data ?: Record < string , unknown >
321319) : Promise < void > {
322320 try {
321+ const payload = {
322+ toolCallId,
323+ status,
324+ message : message || ( status === 'success' ? 'Tool completed' : 'Tool failed' ) ,
325+ ...( data ? { data } : { } ) ,
326+ }
323327 const res = await fetch ( COPILOT_CONFIRM_API_PATH , {
324328 method : 'POST' ,
325329 headers : { 'Content-Type' : 'application/json' } ,
326- body : JSON . stringify ( {
327- toolCallId,
328- status,
329- message : message || ( status === 'success' ? 'Tool completed' : 'Tool failed' ) ,
330- ...( data ? { data } : { } ) ,
331- } ) ,
330+ body : JSON . stringify ( payload ) ,
332331 } )
333- if ( ! res . ok ) {
332+ if ( res . status === 413 && data ) {
333+ logger . warn ( '[RunTool] reportCompletion payload too large, retrying without data' , {
334+ toolCallId,
335+ } )
336+ const retryRes = await fetch ( COPILOT_CONFIRM_API_PATH , {
337+ method : 'POST' ,
338+ headers : { 'Content-Type' : 'application/json' } ,
339+ body : JSON . stringify ( {
340+ toolCallId,
341+ status : 'error' ,
342+ message : 'Workflow execution failed: payload too large' ,
343+ } ) ,
344+ } )
345+ if ( ! retryRes . ok ) {
346+ logger . warn ( '[RunTool] reportCompletion retry also failed' , {
347+ toolCallId,
348+ status : retryRes . status ,
349+ } )
350+ }
351+ } else if ( ! res . ok ) {
334352 logger . warn ( '[RunTool] reportCompletion failed' , { toolCallId, status : res . status } )
335353 }
336354 } catch ( err ) {
0 commit comments