Skip to content

Commit a2cdc79

Browse files
committed
Include truncated original tool call in error message
1 parent b7a39b5 commit a2cdc79

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/agent-runtime/src/__tests__/tool-validation-error.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ describe('tool validation error handling', () => {
101101
)
102102
expect(errorEvents.length).toBe(1)
103103
expect(errorEvents[0].message).toContain('Invalid parameters for spawn_agents')
104+
expect(errorEvents[0].message).toContain('Original tool call input:')
105+
expect(errorEvents[0].message).toContain('this should be an array not a string')
104106

105107
// Verify hadToolCallError is true so the agent loop continues
106108
expect(result.hadToolCallError).toBe(true)

packages/agent-runtime/src/tools/tool-executor.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,13 @@ export async function executeToolCall<T extends ToolName>(
180180
}
181181

182182
if ('error' in toolCall) {
183+
const inputStr = JSON.stringify(input, null, 2)
184+
const truncatedInput = inputStr.length > 500
185+
? inputStr.slice(0, 500) + '...(truncated)'
186+
: inputStr
183187
onResponseChunk({
184188
type: 'error',
185-
message: toolCall.error,
189+
message: `${toolCall.error}\n\nOriginal tool call input:\n${truncatedInput}`,
186190
})
187191
logger.debug(
188192
{ toolCall, error: toolCall.error },
@@ -487,9 +491,13 @@ export async function executeCustomToolCall(
487491
}
488492

489493
if ('error' in toolCall) {
494+
const inputStr = JSON.stringify(input, null, 2)
495+
const truncatedInput = inputStr.length > 500
496+
? inputStr.slice(0, 500) + '...(truncated)'
497+
: inputStr
490498
onResponseChunk({
491499
type: 'error',
492-
message: toolCall.error,
500+
message: `${toolCall.error}\n\nOriginal tool call input:\n${truncatedInput}`,
493501
})
494502
logger.debug(
495503
{ toolCall, error: toolCall.error },

0 commit comments

Comments
 (0)