#22321: fix: sanitize tool schemas for all Cloud Code Assist providers
agents
size: S
Cluster:
Tool Schema Fixes and Enhancements
## Summary
- `sanitizeToolsForGoogle` only stripped unsupported JSON Schema keywords (`patternProperties`, `additionalProperties`, etc.) when the provider was `google-gemini-cli` or `google-antigravity`
- Providers like `openai-codex` and `google/*` also route through Google Cloud Code Assist, which rejects these keywords with a 400 error
- The `exec` tool's `env` field (`Type.Record`) generates `patternProperties` in its schema, breaking every API call for affected providers
- Removed the provider guard so schemas are always sanitized — matching the intent already described in the comment above the function
## Reproduction
1. Configure `openai-codex/gpt-5.3-codex` or `google/gemini-3-pro-preview` as primary model
2. Send any message via Discord/Signal channel
3. API returns: `Invalid JSON payload received. Unknown name "patternProperties" at 'request.tools[0].function_declarations[3].parameters.properties[2].value': Cannot find field.`
## Test plan
- [x] Added test cases for `openai-codex` and `google/*` providers
- [x] Existing tests for `google-gemini-cli` and `google-antigravity` still pass
- [ ] Verify manually with `openai-codex` provider via Discord channel
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Removes the provider guard in `sanitizeToolsForGoogle` so that tool schemas are always sanitized before being sent to Cloud Code Assist, fixing 400 errors for `openai-codex` and `google/*` providers whose requests were rejected due to unsupported JSON Schema keywords like `patternProperties`.
- The old guard only sanitized for `google-gemini-cli` and `google-antigravity`, contradicting the comment above it that stated schemas should be cleaned "for every provider that routes through this path"
- Providers like `openai-codex` and `google/*` also route through Cloud Code Assist and hit the same OpenAPI 3.03 schema restrictions
- The `exec` tool's `env` field (using `Type.Record`) generates `patternProperties` in its schema, which triggered the 400 on every API call for affected providers
- New tests cover `openai-codex` and `google/*` provider scenarios; existing tests continue to pass
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it's a minimal, well-scoped bug fix that aligns behavior with the stated intent.
- The change is a 3-line removal of a provider guard that was already documented as incorrect by the comment above it. The sanitization logic (`cleanToolSchemaForGemini`) is non-destructive — it only strips optional JSON Schema constraint keywords while preserving the core schema structure. The fix is backed by new test cases and does not change behavior for previously-working providers. There are no security implications, no architectural changes, and no risk of regression.
- No files require special attention.
<sub>Last reviewed commit: 0329be4</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatib...
by Kansodata · 2026-02-20
91.3%
#17841: fix(google): include 'google' provider in tool schema sanitization
by zerone0x · 2026-02-16
87.9%
#21835: fix: apply schema cleaning for google-antigravity in normalizeToolP...
by ephraimm · 2026-02-20
87.7%
#23507: fix(tools): strip patternProperties from schemas for OpenAI-compati...
by long-pham · 2026-02-22
83.2%
#12812: fix(transcript-policy): sanitize tool call IDs for all non-OpenAI p...
by justin-nevins · 2026-02-09
81.2%
#12608: fix: sanitize client tool call IDs per provider requirements
by piyushhhxyz · 2026-02-09
80.9%
#5011: fix(gemini): strip JSON thoughtSignature from tool calls for Gemini 3+
by shayan919293 · 2026-01-30
80.7%
#13976: fix(anthropic): include Anthropic in tool call ID sanitization
by omair445 · 2026-02-11
79.9%
#12487: fix(agents): strip orphaned tool_result when tool_use is sanitized ...
by skylarkoo7 · 2026-02-09
79.1%
#4445: fix: resolve Antigravity "unsupported version" and tool_use schema ...
by harry2690 · 2026-01-30
79.1%