mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 07:04:45 +00:00
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
This commit is contained in:
parent
82caf064e0
commit
1caadb2e2a
6 changed files with 26 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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<T extends GoogleApiType>(model: Model<T>, 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<string, unknown>[] }[] | 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 }),
|
||||
})),
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue