Skip to content

Commit e83d3a6

Browse files
authored
fix(tool-calls): remove redundant input/output fields in favor of arguments/response, exclude isExpanded for tools in agents in workflow change detection (#1630)
1 parent 6723adf commit e83d3a6

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,7 @@ export class AgentBlockHandler implements BlockHandler {
928928
endTime: tc.endTime,
929929
duration: tc.duration,
930930
arguments: tc.arguments || tc.input || {},
931-
input: tc.arguments || tc.input || {}, // Keep both for backward compatibility
932-
output: tc.result || tc.output,
931+
result: tc.result || tc.output,
933932
}
934933
}
935934

apps/sim/lib/workflows/utils.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,23 @@ export async function updateWorkflowRunCounts(workflowId: string, runs = 1) {
237237
}
238238
}
239239

240+
/**
241+
* Sanitize tools array by removing UI-only fields
242+
* @param tools - The tools array to sanitize
243+
* @returns A sanitized tools array
244+
*/
245+
function sanitizeToolsForComparison(tools: any[] | undefined): any[] {
246+
if (!Array.isArray(tools)) {
247+
return []
248+
}
249+
250+
return tools.map((tool) => {
251+
// Remove UI-only field: isExpanded
252+
const { isExpanded, ...cleanTool } = tool
253+
return cleanTool
254+
})
255+
}
256+
240257
/**
241258
* Normalize a value for consistent comparison by sorting object keys
242259
* @param value - The value to normalize
@@ -385,8 +402,14 @@ export function hasWorkflowChanged(
385402
}
386403

387404
// Get values with special handling for null/undefined
388-
const currentValue = currentSubBlocks[subBlockId].value ?? null
389-
const deployedValue = deployedSubBlocks[subBlockId].value ?? null
405+
let currentValue = currentSubBlocks[subBlockId].value ?? null
406+
let deployedValue = deployedSubBlocks[subBlockId].value ?? null
407+
408+
// Special handling for 'tools' subBlock - sanitize UI-only fields
409+
if (subBlockId === 'tools' && Array.isArray(currentValue) && Array.isArray(deployedValue)) {
410+
currentValue = sanitizeToolsForComparison(currentValue)
411+
deployedValue = sanitizeToolsForComparison(deployedValue)
412+
}
390413

391414
// For string values, compare directly to catch even small text changes
392415
if (typeof currentValue === 'string' && typeof deployedValue === 'string') {

0 commit comments

Comments
 (0)