Skip to content

fix(agents): remove unsupported JSON Schema keywords for Cloud Code Assist API#567

Merged
steipete merged 10 commits into
openclaw:mainfrom
erikpr1994:fix/gemini-schema-sanitization
Jan 9, 2026
Merged

fix(agents): remove unsupported JSON Schema keywords for Cloud Code Assist API#567
steipete merged 10 commits into
openclaw:mainfrom
erikpr1994:fix/gemini-schema-sanitization

Conversation

@erikpr1994

Copy link
Copy Markdown
Contributor

Summary

  • Remove JSON Schema keywords that Cloud Code Assist API rejects (patternProperties, additionalProperties, $schema, $id, $ref, $defs, definitions)
  • Add oneOf literal flattening to match existing anyOf behavior
  • Add test to verify no unsupported keywords remain in tool schemas

Problem

When switching from Claude to Gemini mid-session (e.g., when running out of tokens), Claude's tool schemas contain JSON Schema keywords that Google's Cloud Code Assist API rejects as non-compliant with JSON Schema draft 2020-12.

Solution

Extended cleanSchemaForGemini() in src/agents/pi-tools.ts to:

  1. Remove all unsupported keywords via UNSUPPORTED_SCHEMA_KEYWORDS blocklist
  2. Flatten oneOf literals to enum (matching existing anyOf behavior)
  3. Remove additionalProperties entirely instead of just recursively cleaning it

Test Plan

  • Added test "removes unsupported JSON Schema keywords for Cloud Code Assist API compatibility"
  • All 1820 existing tests pass
  • Lint clean
  • Build successful

Changes

Keyword Before After
patternProperties Removed Removed ✓
additionalProperties Recursively cleaned Removed entirely
$schema, $id, $ref, $defs, definitions Kept Removed
oneOf literals Not flattened Flattened to enum

@erikpr1994

Copy link
Copy Markdown
Contributor Author

@steipete I will be out for around 24 hours as I'm taking a flight back home. It would be nice if you can merge it asap or take care of it!

erikpr1994 and others added 9 commits January 9, 2026 15:19
…ssist API

Cloud Code Assist API requires strict JSON Schema draft 2020-12 compliance
and rejects keywords like patternProperties, additionalProperties, $schema,
$id, $ref, $defs, and definitions.

This extends cleanSchemaForGemini to:
- Remove all unsupported keywords from tool schemas
- Add oneOf literal flattening (matching existing anyOf behavior)
- Add test to verify no unsupported keywords remain in tool schemas
@steipete
steipete force-pushed the fix/gemini-schema-sanitization branch from 402c7f3 to c228df8 Compare January 9, 2026 14:23
@steipete
steipete merged commit 616293f into openclaw:main Jan 9, 2026
13 of 17 checks passed
@steipete

steipete commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main (merged w/ admin override; CI still running).

  • Gate (local): pnpm lint && pnpm build && CI=1 pnpm test
  • Land commit: 17a7d4e
  • Merge commit: 616293f

Thanks @erikpr1994!

dustin-olenslager pushed a commit to dustin-olenslager/ironclaw-supreme that referenced this pull request Mar 24, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
…itization

fix(agents): remove unsupported JSON Schema keywords for Cloud Code Assist API
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
…itization

fix(agents): remove unsupported JSON Schema keywords for Cloud Code Assist API
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants