fix: strip unsupported JSON Schema keywords for Claude via Cloud Code Assist (openclaw#20124) thanks @ephraimm

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm check (fails on existing unrelated type error: src/agents/subagent-announce.format.e2e.test.ts:71)
- pnpm test:e2e src/agents/pi-embedded-runner/google.e2e.test.ts
- pnpm test:macmini (fails on existing unrelated test: src/agents/subagent-registry.steer-restart.test.ts)

Co-authored-by: ephraimm <2803669+ephraimm@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
Ephraim Moss
2026-02-20 06:31:20 +02:00
committed by GitHub
parent f91034aa6b
commit 59e58bf81c
3 changed files with 39 additions and 5 deletions

View File

@@ -173,6 +173,7 @@ Docs: https://docs.openclaw.ai
### Fixes
- Agents/Google: clean tool JSON Schemas for `google-antigravity` the same as `google-gemini-cli` before Cloud Code Assist requests, preventing Claude tool calls from failing with `patternProperties` 400 errors. (#19860)
- Tests/Telegram: add regression coverage for command-menu sync that asserts all `setMyCommands` entries are Telegram-safe and hyphen-normalized across native/custom/plugin command sources. (#19703) Thanks @obviyus.
- Agents/Image: collapse resize diagnostics to one line per image and include visible pixel/byte size details in the log message for faster triage.
- Auth/Cooldowns: clear all usage stats fields (`disabledUntil`, `disabledReason`, `failureCounts`) in `clearAuthProfileCooldown` so manual cooldown resets fully recover billing-disabled profiles without requiring direct file edits. (#19211) Thanks @nabbilkhan.

View File

@@ -33,4 +33,37 @@ describe("sanitizeToolsForGoogle", () => {
expect(params.additionalProperties).toBeUndefined();
expect(params.properties?.foo?.format).toBeUndefined();
});
it("strips unsupported schema keywords for google-antigravity", () => {
const tool = {
name: "test",
description: "test",
parameters: {
type: "object",
patternProperties: {
"^x-": { type: "string" },
},
properties: {
foo: {
type: "string",
format: "uuid",
},
},
},
execute: async () => ({ ok: true, content: [] }),
} as unknown as AgentTool;
const [sanitized] = sanitizeToolsForGoogle({
tools: [tool],
provider: "google-antigravity",
});
const params = sanitized.parameters as {
patternProperties?: unknown;
properties?: Record<string, { format?: unknown }>;
};
expect(params.patternProperties).toBeUndefined();
expect(params.properties?.foo?.format).toBeUndefined();
});
});

View File

@@ -247,11 +247,11 @@ 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") {
// Cloud Code Assist uses the OpenAPI 3.03 `parameters` field for both Gemini
// AND Claude models. This field does not support JSON Schema keywords such as
// patternProperties, additionalProperties, $ref, etc. We must clean schemas
// for every provider that routes through this path.
if (params.provider !== "google-gemini-cli" && params.provider !== "google-antigravity") {
return params.tools;
}
return params.tools.map((tool) => {