#20249: fix(schema): ensure normalizeToolParameters always includes properties field
agents
size: XS
trusted-contributor
Cluster:
Tool Schema Fixes and Enhancements
Fixes #20224
## Problem
`normalizeToolParameters()` has a fallthrough path that returns the tool unchanged when the schema has `type` but no `properties`, `anyOf`, or `oneOf`. OpenAI-compatible providers (e.g. Abacus RouteLLM) strictly require `properties` on every tool schema, causing HTTP 400 errors.
## Fix
Add an empty `properties: {}` fallback in the no-variant-key path before returning.
## Testing
- Added unit tests in `pi-tools.schema.test.ts` (3 tests, all passing)
- AI-assisted (Claude), lightly tested
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR fixes a compatibility issue where `normalizeToolParameters()` could return tool schemas without a `properties` field, causing HTTP 400 errors on OpenAI-compatible providers (e.g., Abacus RouteLLM) that strictly require `properties` on every tool schema.
- Adds a `properties: {}` fallback in the `!variantKey` path of `normalizeToolParameters()` when the schema has `type` but no `properties`, `anyOf`, or `oneOf`
- The implementation fix in `pi-tools.schema.ts` is minimal and correct — it only affects the specific fallthrough path that was missing the `properties` field
- The new test file (`pi-tools.schema.test.ts`) has an **incorrect import**: `AnyAgentTool` is imported from `./pi-tools.schema.js`, but that module does not export this type. It should be imported from `./pi-tools.types.js`
<h3>Confidence Score: 4/5</h3>
- The core fix is safe to merge, but the test file has a compilation error that needs a one-line fix before merging.
- The logic change in pi-tools.schema.ts is minimal, correct, and well-targeted to the reported issue. However, the test file has an incorrect import (AnyAgentTool from the wrong module) that will fail TypeScript compilation, preventing the tests from actually running. This is a straightforward fix but should be addressed before merge.
- src/agents/pi-tools.schema.test.ts — incorrect import source for AnyAgentTool type
<sub>Last reviewed commit: cff1b5b</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22214: fix(tools): sanitize google-antigravity schemas for Gemini-compatib...
by Kansodata · 2026-02-20
80.3%
#23507: fix(tools): strip patternProperties from schemas for OpenAI-compati...
by long-pham · 2026-02-22
78.9%
#21835: fix: apply schema cleaning for google-antigravity in normalizeToolP...
by ephraimm · 2026-02-20
78.6%
#12642: feat(tools): typed tool schemas for xAI/Grok compatibility
by 2nd-ren · 2026-02-09
77.1%
#22321: fix: sanitize tool schemas for all Cloud Code Assist providers
by Sr-0w · 2026-02-21
77.1%
#19394: fix(agents): normalize tool call arguments dropped to {} (#19261)
by DevvGwardo · 2026-02-17
76.3%
#4767: fix(agents): handle read alias required schema
by RomeroYang · 2026-01-30
76.1%
#21166: fix(agents): sanitize tool names in session transcript repair (#8595)
by dinakars777 · 2026-02-19
75.5%
#11854: fix: resolve per-agent tools.exec config in pi-tools
by Yida-Dev · 2026-02-08
75.4%
#4964: fix: strip null-valued optional parameters from tool calls for prov...
by umut-polat · 2026-01-30
74.9%