Skip to content

Commit a366934

Browse files
committed
fix(google): honor tool_choice none for claude on antigravity
1 parent 46756f5 commit a366934

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

‎src/adapters/google.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ export function createGoogleAdapter(provider: OcxProviderConfig): ProviderAdapte
384384
const draftRequest: Record<string, unknown> = { ...body, sessionId };
385385
// Claude-on-Antigravity forces VALIDATED function calling (the real client always sets it).
386386
if (/claude/i.test(wireModelId)) {
387+
// VALIDATED would defeat a client's tool_choice "none": honor it by dropping the
388+
// declarations instead, the wire shape of a tool-less Claude turn.
389+
if (parsed.options.toolChoice === "none") {
390+
delete draftRequest.tools;
391+
delete draftRequest.toolConfig;
392+
}
387393
const existing = (draftRequest.toolConfig ?? {}) as Record<string, unknown>;
388394
const fcc = (existing.functionCallingConfig ?? {}) as Record<string, unknown>;
389395
draftRequest.toolConfig = { ...existing, functionCallingConfig: { ...fcc, mode: "VALIDATED" } };

‎tests/google-adapter.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,28 @@ describe("google adapter — tool_choice on the wire", () => {
238238
expect((await geminiBody(parsedWithChoice({ name: "get_weather" }, []))).toolConfig).toBeUndefined();
239239
});
240240

241+
test('claude-on-antigravity honors "none" by dropping the declarations', async () => {
242+
const ccaProvider = {
243+
adapter: "google",
244+
googleMode: "cloud-code-assist",
245+
baseUrl: "https://daily-cloudcode-pa.googleapis.com",
246+
apiKey: "key",
247+
project: "proj-123",
248+
};
249+
const claudeParsed = parsedWithChoice("none");
250+
(claudeParsed as unknown as { modelId: string }).modelId = "claude-opus-4.8";
251+
const claudeRequest = JSON.parse((await createGoogleAdapter(ccaProvider).buildRequest(claudeParsed)).body).request as Record<string, unknown>;
252+
// VALIDATED would defeat NONE, so the declarations go instead; the config matches a tool-less turn.
253+
expect(claudeRequest.tools).toBeUndefined();
254+
expect(claudeRequest.toolConfig).toEqual({ functionCallingConfig: { mode: "VALIDATED" } });
255+
256+
// Gemini on the same route has no VALIDATED override, so NONE rides with the catalog intact.
257+
const geminiParsed = parsedWithChoice("none");
258+
const geminiRequest = JSON.parse((await createGoogleAdapter(ccaProvider).buildRequest(geminiParsed)).body).request as Record<string, unknown>;
259+
expect(geminiRequest.tools).toBeDefined();
260+
expect(geminiRequest.toolConfig).toEqual({ functionCallingConfig: { mode: "NONE" } });
261+
});
262+
241263
test("claude-on-antigravity keeps VALIDATED mode over a client choice, allowed names survive", async () => {
242264
const ccaProvider = {
243265
adapter: "google",

0 commit comments

Comments
 (0)