|
1 | 1 | import { endsAgentStepParam } from '@codebuff/common/tools/constants' |
2 | 2 | import { toolParams } from '@codebuff/common/tools/list' |
3 | | -import { toolJsonContent } from '@codebuff/common/util/messages' |
| 3 | +import { jsonToolResult } from '@codebuff/common/util/messages' |
4 | 4 | import { generateCompactId } from '@codebuff/common/util/string' |
5 | 5 | import { cloneDeep } from 'lodash' |
6 | 6 | import z from 'zod/v4' |
@@ -179,11 +179,9 @@ export function executeToolCall<T extends ToolName>( |
179 | 179 | role: 'tool', |
180 | 180 | toolName, |
181 | 181 | toolCallId: toolCall.toolCallId, |
182 | | - content: [ |
183 | | - toolJsonContent({ |
184 | | - errorMessage: toolCall.error, |
185 | | - }), |
186 | | - ], |
| 182 | + content: jsonToolResult({ |
| 183 | + errorMessage: toolCall.error, |
| 184 | + }), |
187 | 185 | } |
188 | 186 | toolResults.push(cloneDeep(toolResult)) |
189 | 187 | toolResultsToAddAfterStream.push(cloneDeep(toolResult)) |
@@ -216,11 +214,9 @@ export function executeToolCall<T extends ToolName>( |
216 | 214 | role: 'tool', |
217 | 215 | toolName, |
218 | 216 | toolCallId: toolCall.toolCallId, |
219 | | - content: [ |
220 | | - toolJsonContent({ |
221 | | - errorMessage: `Tool \`${toolName}\` is not currently available. Make sure to only use tools listed in the system instructions.`, |
222 | | - }), |
223 | | - ], |
| 217 | + content: jsonToolResult({ |
| 218 | + errorMessage: `Tool \`${toolName}\` is not currently available. Make sure to only use tools listed in the system instructions.`, |
| 219 | + }), |
224 | 220 | } |
225 | 221 | toolResults.push(cloneDeep(toolResult)) |
226 | 222 | toolResultsToAddAfterStream.push(cloneDeep(toolResult)) |
@@ -430,11 +426,9 @@ export async function executeCustomToolCall( |
430 | 426 | role: 'tool', |
431 | 427 | toolName, |
432 | 428 | toolCallId: toolCall.toolCallId, |
433 | | - content: [ |
434 | | - toolJsonContent({ |
435 | | - errorMessage: toolCall.error, |
436 | | - }), |
437 | | - ], |
| 429 | + content: jsonToolResult({ |
| 430 | + errorMessage: toolCall.error, |
| 431 | + }), |
438 | 432 | } |
439 | 433 | toolResults.push(cloneDeep(toolResult)) |
440 | 434 | toolResultsToAddAfterStream.push(cloneDeep(toolResult)) |
@@ -471,11 +465,9 @@ export async function executeCustomToolCall( |
471 | 465 | role: 'tool', |
472 | 466 | toolName, |
473 | 467 | toolCallId: toolCall.toolCallId, |
474 | | - content: [ |
475 | | - toolJsonContent({ |
476 | | - errorMessage: `Tool \`${toolName}\` is not currently available. Make sure to only use tools listed in the system instructions.`, |
477 | | - }), |
478 | | - ], |
| 468 | + content: jsonToolResult({ |
| 469 | + errorMessage: `Tool \`${toolName}\` is not currently available. Make sure to only use tools listed in the system instructions.`, |
| 470 | + }), |
479 | 471 | } |
480 | 472 | toolResults.push(cloneDeep(toolResult)) |
481 | 473 | toolResultsToAddAfterStream.push(cloneDeep(toolResult)) |
|
0 commit comments