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
@@ -1,7 +1,7 @@
|
||||
// Real Antigravity-MITM requests (Gemini-internal: { request: { contents, ... } }) → OpenAI.
|
||||
import { describe, it, expect } from "vitest";
|
||||
import "./registerAll.js";
|
||||
import { translateRequest } from "../../open-sse/translator/index.js";
|
||||
import { translateRequest, translateResponse, initState } from "../../open-sse/translator/index.js";
|
||||
import { FORMATS } from "../../open-sse/translator/formats.js";
|
||||
import { AntigravityExecutor } from "../../open-sse/executors/antigravity.js";
|
||||
|
||||
@@ -54,6 +54,32 @@ describe("Antigravity → OpenAI", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Antigravity → Claude", () => {
|
||||
it("tool call input_json_delta includes Anthropic index", () => {
|
||||
const state = initState(FORMATS.CLAUDE);
|
||||
const events = translateResponse(FORMATS.ANTIGRAVITY, FORMATS.CLAUDE, {
|
||||
response: {
|
||||
responseId: "resp-1",
|
||||
modelVersion: "gemini-pro-agent",
|
||||
candidates: [{
|
||||
content: {
|
||||
role: "model",
|
||||
parts: [{ functionCall: { name: "bash", args: { command: "git status" } } }],
|
||||
},
|
||||
finishReason: "STOP",
|
||||
index: 0,
|
||||
}],
|
||||
},
|
||||
}, state);
|
||||
|
||||
const jsonDelta = events.find(
|
||||
(event) => event.type === "content_block_delta" && event.delta?.type === "input_json_delta"
|
||||
);
|
||||
expect(jsonDelta).toMatchObject({ index: expect.any(Number) });
|
||||
expect(JSON.parse(jsonDelta.delta.partial_json)).toEqual({ command: "git status" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("Antigravity executor", () => {
|
||||
it("strips optional from nested tool schemas", () => {
|
||||
const out = new AntigravityExecutor().transformRequest("gemini-2.5-pro", {
|
||||
|
||||
@@ -171,6 +171,7 @@ describe("Kiro → Claude (direct route, OpenAI-shaped chunks from executor)", (
|
||||
const jsonDelta = events.find(
|
||||
(e) => e.type === "content_block_delta" && e.delta.type === "input_json_delta"
|
||||
);
|
||||
expect(jsonDelta.index).toBeDefined();
|
||||
expect(jsonDelta.delta.partial_json).toBe('{"q":"x"}');
|
||||
const md = events.find((e) => e.type === "message_delta");
|
||||
expect(md.delta.stop_reason).toBe("tool_use");
|
||||
|
||||
Reference in New Issue
Block a user