#14499: fix: strip propertyNames from tool schemas for Gemini API [AI-assisted]
agents
stale
size: XS
Cluster:
Tool Schema Fixes and Enhancements
## Summary
- Add `propertyNames` to `GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS` in both `src/agents/schema/clean-for-gemini.ts` and `src/agents/pi-embedded-runner/google.ts`
- The Google Generative AI API rejects the JSON Schema `propertyNames` keyword in `function_declarations` with a 400 `INVALID_ARGUMENT` error
- Confirmed via the [Google API discovery document](https://generativelanguage.googleapis.com/$discovery/rest?version=v1beta) that `propertyNames` is not in the supported Schema fields
- This matches the existing treatment of other unsupported keywords like `patternProperties`, `additionalProperties`, `minProperties`, `maxProperties`, etc.
## Error reproduced
```
Invalid JSON payload received. Unknown name "propertyNames" at
'tools[0].function_declarations[30].parameters.properties[1].value.items.any_of[1].properties[2].value': Cannot find field.
```
Multiple tool schemas (indices 30, 32, 33, 35, 36) contain `propertyNames` at various nesting depths within `properties`, `items`, and `anyOf` variants. The existing `cleanSchemaForGemini` function already recursively strips keywords from the unsupported set through all these paths — only `propertyNames` was missing from the set.
## AI-assisted
- This PR was authored with Claude Code (Claude Opus 4.6)
- **Testing:** Fully tested — `pnpm build && pnpm check && pnpm test` all pass (890/890 test files, 1 pre-existing env-dependent failure in model-auth.test.ts unrelated to this change)
- I understand what the code does: the `GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS` set is checked during recursive schema cleaning in `cleanSchemaForGeminiWithDefs` — any key in the set is skipped when building the cleaned output object
## Test plan
- [x] `pnpm build` passes
- [x] `pnpm check` passes (format, typecheck, lint)
- [x] `pnpm test` passes (5816/5817 tests, 1 pre-existing failure)
- [x] Verified `propertyNames` is not in Google's supported Schema fields via API discovery doc
- [ ] Verify Gemini API calls no longer return 400 for `propertyNames`
Most Similar PRs
#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatib...
by Kansodata · 2026-02-20
77.2%
#22321: fix: sanitize tool schemas for all Cloud Code Assist providers
by Sr-0w · 2026-02-21
75.0%
#21835: fix: apply schema cleaning for google-antigravity in normalizeToolP...
by ephraimm · 2026-02-20
74.9%
#23507: fix(tools): strip patternProperties from schemas for OpenAI-compati...
by long-pham · 2026-02-22
74.4%
#5011: fix(gemini): strip JSON thoughtSignature from tool calls for Gemini 3+
by shayan919293 · 2026-01-30
72.9%
#20249: fix(schema): ensure normalizeToolParameters always includes propert...
by aldoeliacim · 2026-02-18
70.5%
#12877: fix: backfill empty toolName on toolResult messages for Gemini comp...
by aldoeliacim · 2026-02-09
69.4%
#17841: fix(google): include 'google' provider in tool schema sanitization
by zerone0x · 2026-02-16
68.8%
#14314: fix(agent-runner): auto-recover from Gemini INVALID_ARGUMENT errors
by thebtf · 2026-02-11
68.6%
#23034: Add Gemini 3.1 Pro to Google model normalizer and OpenCode Zen catalog
by Clawborn · 2026-02-21
68.3%