← Back to PRs

#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatible API validation

by Kansodata open 2026-02-20 22:08 View on GitHub →
channel: discord agents size: S
## 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