Skip to content

Commit 9c99c3a

Browse files
author
Theodore Li
committed
Strip only logs on payload too large
1 parent 38d46e6 commit 9c99c3a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

apps/sim/lib/copilot/client-sse/run-tool-execution.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,11 @@ async function reportCompletion(
333333
})
334334
// Next.js silently truncates request bodies beyond its body size limit (default 10MB),
335335
// corrupting the JSON and causing a server-side parse error (500). When the request fails
336-
// and the payload is large, retry without the data to unblock the server-side waiter.
336+
// and the payload is large, retry without logs (the largest field) to fit under the limit.
337337
const LARGE_PAYLOAD_THRESHOLD = 1024 * 1024
338338
if (!res.ok && data && new Blob([body]).size > LARGE_PAYLOAD_THRESHOLD) {
339-
logger.warn('[RunTool] reportCompletion failed with large payload, retrying without data', {
339+
const { logs: _logs, ...dataWithoutLogs } = data
340+
logger.warn('[RunTool] reportCompletion failed with large payload, retrying without logs', {
340341
toolCallId,
341342
status: res.status,
342343
bodySize: new Blob([body]).size,
@@ -346,8 +347,9 @@ async function reportCompletion(
346347
headers: { 'Content-Type': 'application/json' },
347348
body: JSON.stringify({
348349
toolCallId,
349-
status: 'error',
350-
message: 'Workflow execution failed: result payload too large',
350+
status,
351+
message: message || (status === 'success' ? 'Tool completed' : 'Tool failed'),
352+
data: dataWithoutLogs,
351353
}),
352354
})
353355
if (!retryRes.ok) {

0 commit comments

Comments
 (0)