File tree Expand file tree Collapse file tree 1 file changed +27
-3
lines changed
apps/sim/lib/copilot/tools/client Expand file tree Collapse file tree 1 file changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -345,18 +345,42 @@ async function reportCompletion(
345345 data ?: Record < string , unknown >
346346) : Promise < void > {
347347 try {
348+ const defaultMessage =
349+ status === MothershipStreamV1ToolOutcome . success ? 'Tool completed' : 'Tool failed'
350+
348351 const res = await fetch ( COPILOT_CONFIRM_API_PATH , {
349352 method : 'POST' ,
350353 headers : { 'Content-Type' : 'application/json' } ,
351354 body : JSON . stringify ( {
352355 toolCallId,
353356 status,
354- message :
355- message ||
356- ( status === MothershipStreamV1ToolOutcome . success ? 'Tool completed' : 'Tool failed' ) ,
357+ message : message || defaultMessage ,
357358 ...( data ? { data } : { } ) ,
358359 } ) ,
359360 } )
361+
362+ if ( res . status === 413 && data ) {
363+ logger . warn ( '[RunTool] reportCompletion payload too large, retrying without data' , {
364+ toolCallId,
365+ } )
366+ const retryRes = await fetch ( COPILOT_CONFIRM_API_PATH , {
367+ method : 'POST' ,
368+ headers : { 'Content-Type' : 'application/json' } ,
369+ body : JSON . stringify ( {
370+ toolCallId,
371+ status : MothershipStreamV1ToolOutcome . error ,
372+ message : 'Workflow execution failed: payload too large' ,
373+ } ) ,
374+ } )
375+ if ( ! retryRes . ok ) {
376+ logger . warn ( '[RunTool] reportCompletion retry also failed' , {
377+ toolCallId,
378+ status : retryRes . status ,
379+ } )
380+ }
381+ return
382+ }
383+
360384 if ( ! res . ok ) {
361385 logger . warn ( '[RunTool] reportCompletion failed' , { toolCallId, status : res . status } )
362386 }
You can’t perform that action at this time.
0 commit comments