fix(tool-pair-validator): emit schema-compatible synthetic tool results

This commit is contained in:
rshks
2026-05-08 14:09:42 +05:30
committed by YeonGyu-Kim
parent 24f7e560ca
commit b504fb1deb
7 changed files with 218 additions and 20 deletions
@@ -10,8 +10,10 @@ type Client = ReturnType<typeof createOpencodeClient>
interface ToolResultPart {
type: "tool_result"
tool_use_id: string
content: string
toolUseId: string
tool_use_id?: string
isError?: boolean
content: Array<{ type: "text"; text: string }>
}
interface PromptWithToolResultInput {
@@ -91,8 +93,10 @@ export async function recoverUnavailableTool(
const toolResultParts = targetToolUses.map((part) => ({
type: "tool_result" as const,
toolUseId: part.id,
tool_use_id: part.id,
content: '{"status":"error","error":"Tool not available. Please continue without this tool."}',
isError: true,
content: [{ type: "text" as const, text: '{"status":"error","error":"Tool not available. Please continue without this tool."}' }],
}))
try {