mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
fix(cli): Handle non-array tool response parts (#758)
This commit is contained in:
@@ -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 }];
|
||||||
|
|||||||
Reference in New Issue
Block a user