← Back to PRs

#14499: fix: strip propertyNames from tool schemas for Gemini API [AI-assisted]

by pm990320 open 2026-02-12 07:10 View on GitHub →
agents stale size: XS
## 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