fix(cli): Group cancelled tool call responses to prevent API errors (#3333)

This commit is contained in:
N. Taylor Mullen
2025-07-05 13:56:39 -07:00
committed by GitHub
parent 8adc586973
commit 4be32d1f73
2 changed files with 114 additions and 8 deletions

View File

@@ -636,20 +636,20 @@ export const useGeminiStream = (
const responsesToAdd = geminiTools.flatMap(
(toolCall) => toolCall.response.responseParts,
);
const combinedParts: Part[] = [];
for (const response of responsesToAdd) {
let parts: Part[];
if (Array.isArray(response)) {
parts = response;
combinedParts.push(...response);
} else if (typeof response === 'string') {
parts = [{ text: response }];
combinedParts.push({ text: response });
} else {
parts = [response];
combinedParts.push(response);
}
geminiClient.addHistory({
role: 'user',
parts,
});
}
geminiClient.addHistory({
role: 'user',
parts: combinedParts,
});
}
const callIdsToMarkAsSubmitted = geminiTools.map(