fix(cli): Handle non-array tool response parts (#758)

This commit is contained in:
N. Taylor Mullen 2025-06-04 23:25:57 -07:00 committed by GitHub
parent d99d132cdf
commit 77afd37c2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 3 deletions

View File

@ -94,9 +94,19 @@ export async function runNonInteractive(
console.error( console.error(
`Error executing tool ${fc.name}: ${toolResponse.resultDisplay || toolResponse.error.message}`, `Error executing tool ${fc.name}: ${toolResponse.resultDisplay || toolResponse.error.message}`,
); );
toolResponseParts.push(...(toolResponse.responseParts as Part[])); }
} else {
toolResponseParts.push(...(toolResponse.responseParts as Part[])); if (toolResponse.responseParts) {
const parts = Array.isArray(toolResponse.responseParts)
? toolResponse.responseParts
: [toolResponse.responseParts];
for (const part of parts) {
if (typeof part === 'string') {
toolResponseParts.push({ text: part });
} else if (part) {
toolResponseParts.push(part);
}
}
} }
} }
currentMessages = [{ role: 'user', parts: toolResponseParts }]; currentMessages = [{ role: 'user', parts: toolResponseParts }];