#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatible API validation
channel: discord
agents
size: S
Cluster:
Tool Schema Fixes and Enhancements
## Summary
- Problem: `normalizeToolParameters()` skipped Gemini schema sanitization for `google-antigravity` because the provider matched both Google and Anthropic flags, so `patternProperties` could leak into Google endpoint requests and trigger HTTP 400s.
- Why it matters: `google-antigravity` traffic still goes through Google API schema validation; incompatible JSON Schema keywords break tool calls for Claude models behind that provider.
- What changed:
- Updated `src/agents/pi-tools.schema.ts` to sanitize whenever provider routes through Google/Gemini compatibility path (`isGeminiProvider`), including `google-antigravity`.
- Added regression tests in `src/agents/pi-tools.schema.test.ts`:
- `google-antigravity` now strips `patternProperties`.
- `anthropic` (non-Google) preserves full schema.
- What did NOT change (scope boundary): no runtime/tool execution logic changed; only schema normalization and tests.
## Change Type (select all)
- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [ ] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [ ] Integrations
- [x] API / contracts
- [ ] UI / DX
- [ ] CI/CD / infra
## Linked Issue/PR
- Closes #22187
## User-visible / Behavior Changes
- `google-antigravity` tool schemas are now consistently Gemini-compatible, avoiding Cloud Code Assist 400 errors caused by unsupported keywords like `patternProperties`.
## Security Impact (required)
- New permissions/capabilities? (`Yes/No`): No
- Secrets/tokens handling changed? (`Yes/No`): No
- New/changed network calls? (`Yes/No`): No
- Command/tool execution surface changed? (`Yes/No`): No
- Data access scope changed? (`Yes/No`): No
- If any `Yes`, explain risk + mitigation:
## Repro + Verification
### Repro
1. Configure provider `google-antigravity` with a Claude model (for example `claude-opus-4-6-thinking`).
2. Use a tool whose JSON schema includes `patternProperties`.
3. Observe request behavior through schema normalization path.
### Expected
- Schema sent through Google endpoint is Gemini-compatible (unsupported keywords stripped).
- No 400 from unknown schema fields.
### Actual (before fix)
- `patternProperties` remained for `google-antigravity`, producing 400 errors from Google API validation.
### Evidence
- Added/ran targeted regression tests:
- `pnpm vitest run src/agents/pi-tools.schema.test.ts`
## Human Verification (required)
- Verified scenarios:
- `google-antigravity` provider sanitizes `patternProperties`.
- `anthropic` provider keeps full schema intact.
- Edge cases checked:
- Provider classification overlap (`google-antigravity`) no longer bypasses sanitation.
- What you did not verify:
- Full end-to-end live call against Cloud Code Assist API (unit/regression coverage only).
## Compatibility / Migration
- Backward compatible? (`Yes/No`): Yes
- Config/env changes? (`Yes/No`): No
- Migration needed? (`Yes/No`): No
- If yes, exact upgrade steps:
## Failure Recovery (if this breaks)
- How to disable/revert this change quickly:
- Revert this commit.
- Files/config to restore:
- `src/agents/pi-tools.schema.ts`
- `src/agents/pi-tools.schema.test.ts`
- Known bad symptoms reviewers should watch for:
- Missing expected schema keywords for non-Google providers.
## Risks and Mitigations
- Risk: Over-sanitizing providers that should keep full JSON Schema.
- Mitigation: Added explicit regression for non-Google `anthropic` to ensure schema remains intact.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed schema sanitization for `google-antigravity` provider by removing the conflicting `isAnthropicProvider` check that was preventing Gemini-compatible schema cleaning. The change ensures `google-antigravity` traffic routes through Google endpoint schema validation correctly, preventing HTTP 400 errors from unsupported JSON Schema keywords like `patternProperties`.
- Removed the `isAnthropicProvider` variable and its checks across three locations in `normalizeToolParameters()`
- Simplified conditional logic to only check `isGeminiProvider` when deciding whether to call `cleanSchemaForGemini()`
- Added regression tests confirming `google-antigravity` strips incompatible keywords while pure `anthropic` provider preserves full schemas
<h3>Confidence Score: 5/5</h3>
- Safe to merge with minimal risk
- The fix is a targeted logical correction that removes a conflicting provider check. The change is well-tested with regression tests covering both the fixed case (`google-antigravity` sanitization) and the preserved case (`anthropic` full schema). The modification is minimal, backward compatible, and directly addresses the root cause described in the PR
- No files require special attention
<sub>Last reviewed commit: f48b5bb</sub>
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#21835: fix: apply schema cleaning for google-antigravity in normalizeToolP...
by ephraimm · 2026-02-20
92.1%
#22321: fix: sanitize tool schemas for all Cloud Code Assist providers
by Sr-0w · 2026-02-21
91.3%
#17841: fix(google): include 'google' provider in tool schema sanitization
by zerone0x · 2026-02-16
87.7%
#23507: fix(tools): strip patternProperties from schemas for OpenAI-compati...
by long-pham · 2026-02-22
83.8%
#4445: fix: resolve Antigravity "unsupported version" and tool_use schema ...
by harry2690 · 2026-01-30
83.7%
#13831: fix(agents): include Anthropic in tool call ID sanitization
by lailoo · 2026-02-11
81.8%
#12608: fix: sanitize client tool call IDs per provider requirements
by piyushhhxyz · 2026-02-09
81.7%
#13976: fix(anthropic): include Anthropic in tool call ID sanitization
by omair445 · 2026-02-11
81.3%
#5011: fix(gemini): strip JSON thoughtSignature from tool calls for Gemini 3+
by shayan919293 · 2026-01-30
81.1%
#15205: fix(models): normalize google-antigravity api field from google-gem...
by wboudy · 2026-02-13
80.5%