fix: flatten remaining anyOf/oneOf in Gemini schema cleaning

The Cloud Code Assist API rejects anyOf/oneOf in tool schemas, not just
unsupported keywords. The image tool (index 21) had:
  image: { anyOf: [{ type: "string" }, { type: "array" }] }
which caused "JSON schema is invalid" errors when forwarded to Anthropic
via google-antigravity.

simplifyUnionVariants only handles literal unions and single non-null
variants. This adds a fallback in cleanSchemaForGeminiWithDefs that
flattens any remaining anyOf/oneOf to a simple type schema.

Also reverts the previous provider-aware normalizeToolParameters and
sanitizeToolsForGoogle changes, which were incorrect — the cleaning IS
needed for Google's API regardless of which downstream model is used.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sean McLellan
2026-02-16 16:36:31 -05:00
committed by Peter Steinberger
parent 1bbf6206d5
commit 06b961b037
4 changed files with 75 additions and 47 deletions

View File

@@ -245,11 +245,7 @@ export function sanitizeToolsForGoogle<
tools: AgentTool<TSchemaType, TResult>[];
provider: string;
}): AgentTool<TSchemaType, TResult>[] {
// google-antigravity serves Anthropic models (e.g. claude-opus-4-6-thinking),
// NOT Gemini. Applying Gemini schema cleaning strips JSON Schema keywords
// (minimum, maximum, format, etc.) that Anthropic's API requires for
// draft 2020-12 compliance. Only clean for actual Gemini providers.
if (params.provider !== "google-gemini-cli") {
if (params.provider !== "google-antigravity" && params.provider !== "google-gemini-cli") {
return params.tools;
}
return params.tools.map((tool) => {