Skip to content

Commit 7c0cd36

Browse files
committed
Fix error status
1 parent 2788c68 commit 7c0cd36

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

apps/sim/lib/copilot/orchestrator/sse/handlers/handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ function inferToolSuccess(data: Record<string, unknown> | undefined): {
113113
const explicitSuccess = data?.success ?? resultObj.success
114114
const hasResultData = data?.result !== undefined || data?.data !== undefined
115115
const hasError = !!data?.error || !!resultObj.error
116-
const success = hasExplicitSuccess ? !!explicitSuccess : hasResultData && !hasError
116+
const success = hasExplicitSuccess ? !!explicitSuccess : !hasError
117117
return { success, hasResultData, hasError }
118118
}
119119

apps/sim/lib/copilot/orchestrator/stream/core.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,22 @@ export async function runStreamLoop(
180180
* Build a ToolCallSummary array from the streaming context.
181181
*/
182182
export function buildToolCallSummaries(context: StreamingContext): ToolCallSummary[] {
183-
return Array.from(context.toolCalls.values()).map((toolCall) => ({
184-
id: toolCall.id,
185-
name: toolCall.name,
186-
status: toolCall.status,
187-
params: toolCall.params,
188-
result: toolCall.result?.output,
189-
error: toolCall.error,
190-
durationMs:
191-
toolCall.endTime && toolCall.startTime ? toolCall.endTime - toolCall.startTime : undefined,
192-
}))
183+
return Array.from(context.toolCalls.values()).map((toolCall) => {
184+
let status = toolCall.status
185+
if (toolCall.result && toolCall.result.success !== undefined) {
186+
status = toolCall.result.success ? 'success' : 'error'
187+
} else if (status === 'pending' || status === 'executing') {
188+
status = toolCall.error ? 'error' : 'success'
189+
}
190+
return {
191+
id: toolCall.id,
192+
name: toolCall.name,
193+
status,
194+
params: toolCall.params,
195+
result: toolCall.result?.output,
196+
error: toolCall.error,
197+
durationMs:
198+
toolCall.endTime && toolCall.startTime ? toolCall.endTime - toolCall.startTime : undefined,
199+
}
200+
})
193201
}

0 commit comments

Comments
 (0)