mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
fix(tool-calls): remove redundant input/output fields in favor of arguments/response, exclude isExpanded for tools in agents in workflow change detection (#1630)
This commit is contained in:
@@ -928,8 +928,7 @@ export class AgentBlockHandler implements BlockHandler {
|
||||
endTime: tc.endTime,
|
||||
duration: tc.duration,
|
||||
arguments: tc.arguments || tc.input || {},
|
||||
input: tc.arguments || tc.input || {}, // Keep both for backward compatibility
|
||||
output: tc.result || tc.output,
|
||||
result: tc.result || tc.output,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,6 +237,23 @@ export async function updateWorkflowRunCounts(workflowId: string, runs = 1) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize tools array by removing UI-only fields
|
||||
* @param tools - The tools array to sanitize
|
||||
* @returns A sanitized tools array
|
||||
*/
|
||||
function sanitizeToolsForComparison(tools: any[] | undefined): any[] {
|
||||
if (!Array.isArray(tools)) {
|
||||
return []
|
||||
}
|
||||
|
||||
return tools.map((tool) => {
|
||||
// Remove UI-only field: isExpanded
|
||||
const { isExpanded, ...cleanTool } = tool
|
||||
return cleanTool
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a value for consistent comparison by sorting object keys
|
||||
* @param value - The value to normalize
|
||||
@@ -385,8 +402,14 @@ export function hasWorkflowChanged(
|
||||
}
|
||||
|
||||
// Get values with special handling for null/undefined
|
||||
const currentValue = currentSubBlocks[subBlockId].value ?? null
|
||||
const deployedValue = deployedSubBlocks[subBlockId].value ?? null
|
||||
let currentValue = currentSubBlocks[subBlockId].value ?? null
|
||||
let deployedValue = deployedSubBlocks[subBlockId].value ?? null
|
||||
|
||||
// Special handling for 'tools' subBlock - sanitize UI-only fields
|
||||
if (subBlockId === 'tools' && Array.isArray(currentValue) && Array.isArray(deployedValue)) {
|
||||
currentValue = sanitizeToolsForComparison(currentValue)
|
||||
deployedValue = sanitizeToolsForComparison(deployedValue)
|
||||
}
|
||||
|
||||
// For string values, compare directly to catch even small text changes
|
||||
if (typeof currentValue === 'string' && typeof deployedValue === 'string') {
|
||||
|
||||
Reference in New Issue
Block a user