From 1caadb2e2af07adaf8863df3c369b985453e8a9a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 8 Feb 2026 15:53:09 +0100 Subject: [PATCH] fix(ai): use parametersJsonSchema for Google tool declarations, revert Antigravity opus model - Use parametersJsonSchema instead of parameters for Gemini tool declarations to support full JSON Schema (anyOf, oneOf, const, etc.) - Keep legacy parameters field for Claude models on Cloud Code Assist, where the API translates parameters into Anthropic's input_schema - Revert claude-opus-4-6-thinking back to claude-opus-4-5-thinking (model doesn't exist on the Antigravity endpoint) fixes #1398 --- packages/ai/CHANGELOG.md | 5 +++++ packages/ai/scripts/generate-models.ts | 4 ++-- packages/ai/src/models.generated.ts | 6 +++--- packages/ai/src/providers/google-gemini-cli.ts | 5 ++++- packages/ai/src/providers/google-shared.ts | 12 +++++++++--- .../test/compaction-thinking-model.test.ts | 6 +++--- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 46457e99..aaff0aae 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -2,6 +2,11 @@ ## [Unreleased] +### Fixed + +- Use `parametersJsonSchema` for Google provider tool declarations to support full JSON Schema (anyOf, oneOf, const, etc.) ([#1398](https://github.com/badlogic/pi-mono/issues/1398) by [@jarib](https://github.com/jarib)) +- Reverted incorrect Antigravity model change: `claude-opus-4-6-thinking` back to `claude-opus-4-5-thinking` (model doesn't exist on Antigravity endpoint) + ## [0.52.8] - 2026-02-07 ### Added diff --git a/packages/ai/scripts/generate-models.ts b/packages/ai/scripts/generate-models.ts index 206a0afd..2690411c 100644 --- a/packages/ai/scripts/generate-models.ts +++ b/packages/ai/scripts/generate-models.ts @@ -1021,8 +1021,8 @@ async function generateModels() { maxTokens: 64000, }, { - id: "claude-opus-4-6-thinking", - name: "Claude Opus 4.6 Thinking (Antigravity)", + id: "claude-opus-4-5-thinking", + name: "Claude Opus 4.5 Thinking (Antigravity)", api: "google-gemini-cli", provider: "google-antigravity", baseUrl: ANTIGRAVITY_ENDPOINT, diff --git a/packages/ai/src/models.generated.ts b/packages/ai/src/models.generated.ts index 8f92ed48..90264f1f 100644 --- a/packages/ai/src/models.generated.ts +++ b/packages/ai/src/models.generated.ts @@ -2971,9 +2971,9 @@ export const MODELS = { } satisfies Model<"google-generative-ai">, }, "google-antigravity": { - "claude-opus-4-6-thinking": { - id: "claude-opus-4-6-thinking", - name: "Claude Opus 4.6 Thinking (Antigravity)", + "claude-opus-4-5-thinking": { + id: "claude-opus-4-5-thinking", + name: "Claude Opus 4.5 Thinking (Antigravity)", api: "google-gemini-cli", provider: "google-antigravity", baseUrl: "https://daily-cloudcode-pa.sandbox.googleapis.com", diff --git a/packages/ai/src/providers/google-gemini-cli.ts b/packages/ai/src/providers/google-gemini-cli.ts index 896998d4..27bff148 100644 --- a/packages/ai/src/providers/google-gemini-cli.ts +++ b/packages/ai/src/providers/google-gemini-cli.ts @@ -953,7 +953,10 @@ export function buildRequest( } if (context.tools && context.tools.length > 0) { - request.tools = convertTools(context.tools); + // Claude models on Cloud Code Assist need the legacy `parameters` field; + // the API translates it into Anthropic's `input_schema`. + const useParameters = model.id.startsWith("claude-"); + request.tools = convertTools(context.tools, useParameters); if (options.toolChoice) { request.toolConfig = { functionCallingConfig: { diff --git a/packages/ai/src/providers/google-shared.ts b/packages/ai/src/providers/google-shared.ts index a12b454c..4605513d 100644 --- a/packages/ai/src/providers/google-shared.ts +++ b/packages/ai/src/providers/google-shared.ts @@ -2,7 +2,7 @@ * Shared utilities for Google Generative AI and Google Cloud Code Assist providers. */ -import { type Content, FinishReason, FunctionCallingConfigMode, type Part, type Schema } from "@google/genai"; +import { type Content, FinishReason, FunctionCallingConfigMode, type Part } from "@google/genai"; import type { Context, ImageContent, Model, StopReason, TextContent, Tool } from "../types.js"; import { sanitizeSurrogates } from "../utils/sanitize-unicode.js"; import { transformMessages } from "./transform-messages.js"; @@ -232,17 +232,23 @@ export function convertMessages(model: Model, contex /** * Convert tools to Gemini function declarations format. + * + * By default uses `parametersJsonSchema` which supports full JSON Schema (including + * anyOf, oneOf, const, etc.). Set `useParameters` to true to use the legacy `parameters` + * field instead (OpenAPI 3.03 Schema). This is needed for Cloud Code Assist with Claude + * models, where the API translates `parameters` into Anthropic's `input_schema`. */ export function convertTools( tools: Tool[], -): { functionDeclarations: { name: string; description?: string; parameters: Schema }[] }[] | undefined { + useParameters = false, +): { functionDeclarations: Record[] }[] | undefined { if (tools.length === 0) return undefined; return [ { functionDeclarations: tools.map((tool) => ({ name: tool.name, description: tool.description, - parameters: tool.parameters as Schema, + ...(useParameters ? { parameters: tool.parameters } : { parametersJsonSchema: tool.parameters }), })), }, ]; diff --git a/packages/coding-agent/test/compaction-thinking-model.test.ts b/packages/coding-agent/test/compaction-thinking-model.test.ts index c7785f27..ea679cfe 100644 --- a/packages/coding-agent/test/compaction-thinking-model.test.ts +++ b/packages/coding-agent/test/compaction-thinking-model.test.ts @@ -57,7 +57,7 @@ describe.skipIf(!HAS_ANTIGRAVITY_AUTH)("Compaction with thinking models (Antigra }); function createSession( - modelId: "claude-opus-4-6-thinking" | "claude-sonnet-4-5", + modelId: "claude-opus-4-5-thinking" | "claude-sonnet-4-5", thinkingLevel: ThinkingLevel = "high", ) { const model = getModel("google-antigravity", modelId); @@ -97,8 +97,8 @@ describe.skipIf(!HAS_ANTIGRAVITY_AUTH)("Compaction with thinking models (Antigra return session; } - it("should compact successfully with claude-opus-4-6-thinking and thinking level high", async () => { - createSession("claude-opus-4-6-thinking", "high"); + it("should compact successfully with claude-opus-4-5-thinking and thinking level high", async () => { + createSession("claude-opus-4-5-thinking", "high"); // Send a simple prompt await session.prompt("Write down the first 10 prime numbers.");