mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix(antigravity): preserve Claude tool delta index (#2223)
Gemini response translation wrote OpenAI-shaped bookkeeping into the shared state.toolCalls map, which the downstream openai-to-claude translator uses for Claude block metadata. That pre-population skipped blockIndex creation, so Anthropic input_json_delta events lost index. Track Gemini function calls via state.geminiToolCallCount instead, leaving state.toolCalls clean for the Claude translator. Closes #2218 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
182c849979
commit
8f81f17b99
@@ -25,7 +25,10 @@ function emitFunctionCall(functionCall, state) {
|
||||
type: OPENAI_BLOCK.FUNCTION,
|
||||
function: { name: fcName, arguments: JSON.stringify(fcArgs) },
|
||||
};
|
||||
state.toolCalls.set(toolCallIndex, toolCall);
|
||||
// Keep Gemini bookkeeping separate from the shared translator state.toolCalls map.
|
||||
// The downstream OpenAI→Claude translator uses state.toolCalls for Claude block
|
||||
// metadata; pre-populating it here makes Anthropic tool deltas lose index.
|
||||
state.geminiToolCallCount = (state.geminiToolCallCount || 0) + 1;
|
||||
return buildChunk(chunkMeta(state), { tool_calls: [toolCall] }, null);
|
||||
}
|
||||
|
||||
@@ -46,6 +49,7 @@ export function geminiToOpenAIResponse(chunk, state) {
|
||||
state.messageId = response.responseId || `msg_${Date.now()}`;
|
||||
state.model = response.modelVersion || "gemini";
|
||||
state.functionIndex = 0;
|
||||
state.geminiToolCallCount = 0;
|
||||
results.push(buildChunk(chunkMeta(state), { role: ROLE.ASSISTANT }, null));
|
||||
}
|
||||
|
||||
@@ -117,7 +121,7 @@ export function geminiToOpenAIResponse(chunk, state) {
|
||||
// Finish reason - include usage in final chunk
|
||||
if (candidate.finishReason) {
|
||||
let finishReason = toOpenAIFinish(candidate.finishReason, "gemini");
|
||||
if (finishReason === OPENAI_FINISH.STOP && state.toolCalls.size > 0) {
|
||||
if (finishReason === OPENAI_FINISH.STOP && state.geminiToolCallCount > 0) {
|
||||
finishReason = OPENAI_FINISH.TOOL_CALLS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user