Skip to content

Commit e05a802

Browse files
committed
Include original tool call in malformed spawn/set_output tool call
1 parent cc36cfe commit e05a802

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

packages/agent-runtime/src/tools/handlers/tool/set-output.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export const handleSetOutput = (async (params: {
6161
const prefix = usedData
6262
? 'Output validation error: Your output was found inside the `data` field but still failed validation. Please fix the issues and try again without wrapping in `data`. Issues: '
6363
: 'Output validation error: Output failed to match the output schema and was ignored. You might want to try again! Issues: '
64-
const errorMessage = `${prefix}${bestError}`
64+
const outputStr = JSON.stringify(output, null, 2)
65+
const truncatedOutput = outputStr.length > 500
66+
? outputStr.slice(0, 500) + '...(truncated)'
67+
: outputStr
68+
const errorMessage = `${prefix}${bestError}\n\nOriginal output value:\n${truncatedOutput}`
6569
logger.error(
6670
{
6771
output,

packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,12 @@ export function validateAgentInput(
221221
if (inputSchema.prompt) {
222222
const result = inputSchema.prompt.safeParse(prompt ?? '')
223223
if (!result.success) {
224+
const promptStr = JSON.stringify(prompt ?? '', null, 2)
225+
const truncatedPrompt = promptStr.length > 500
226+
? promptStr.slice(0, 500) + '...(truncated)'
227+
: promptStr
224228
throw new Error(
225-
`Invalid prompt for agent ${agentType}: ${JSON.stringify(result.error.issues, null, 2)}`,
229+
`Invalid prompt for agent ${agentType}: ${JSON.stringify(result.error.issues, null, 2)}\n\nOriginal prompt value:\n${truncatedPrompt}`,
226230
)
227231
}
228232
}
@@ -231,8 +235,12 @@ export function validateAgentInput(
231235
if (inputSchema.params) {
232236
const result = inputSchema.params.safeParse(params ?? {})
233237
if (!result.success) {
238+
const paramsStr = JSON.stringify(params ?? {}, null, 2)
239+
const truncatedParams = paramsStr.length > 500
240+
? paramsStr.slice(0, 500) + '...(truncated)'
241+
: paramsStr
234242
throw new Error(
235-
`Invalid params for agent ${agentType}: ${JSON.stringify(result.error.issues, null, 2)}`,
243+
`Invalid params for agent ${agentType}: ${JSON.stringify(result.error.issues, null, 2)}\n\nOriginal params value:\n${truncatedParams}`,
236244
)
237245
}
238246
}

0 commit comments

Comments
 (0)