You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Preserve keyword-named tool properties during schema inlining - #1783
The local-reference inliner treats every object as a schema. Inside a properties map, it therefore removes ordinary tool argument names definitions and $defs. A tool with those required fields and additionalProperties: false reaches the model with a schema that rejects its valid arguments. These keys are instance property names at that position, per the JSON Schema properties contract.
Changes
Walk properties as a name-to-schema map: preserve each name and apply the existing reference resolution to its value. Add one direct regression covering the affected fields and an ordinary referenced-field control.
Verification
Regression: 0 pass / 1 fail on unmodified main, then 1 pass / 0 fail.
Entire provider suite: 42 pass / 0 fail.
An injected-fetch probe captures the real provider request; Ajv 8.17.1 rejects valid arguments against the original captured schema and accepts them against the patched one. No external model request is made.
Provider and SDK typechecks pass with installed native TypeScript 7.0.2. Frozen-lockfile install reports no changes; ESLint reports 0 errors / 4 resolver warnings.
Whole-file Prettier still reports pre-existing source differences; no new formatting differences were introduced. SDK/binary builds remain blocked by the existing declaration-generator ts.sys error, so binary smoke was not run.
Scope / Tradeoffs
Source-audit fix, with no existing issue claimed. Changes are limited to the properties map boundary. Existing reference lookup, cycle handling and removal of definition containers at schema positions are retained. This is not a general JSON Schema traversal rewrite.
Good catch and a clean, minimal fix. The bug is real: the visit function's blanket if (key === '$defs' || key === 'definitions') continue at the bottom of the loop strips these keys regardless of whether they're schema-level containers or legitimate property names inside a properties map. Your fix correctly special-cases the properties map so its children are treated as name→schema pairs rather than being subject to the same keyword-stripping logic, which matches the JSON Schema spec you cite.
The diff is small, isolated to inlineLocalSchemaRefs, and includes a regression test that fails on main and passes with the patch — exactly what's wanted here. The test also includes a reasonable control case (name resolved via $ref) to confirm normal ref resolution still works alongside the fix.
One thing worth double-checking before this lands: nested properties maps (e.g. a property whose schema itself has a properties object one level down) — your visit(child, refStack) call without isPropertyMap for non-properties keys should naturally reset to schema-mode, but it would strengthen the PR to add a test with a nested object property to confirm recursion depth is handled correctly, since that's exactly the kind of case that silently breaks with this sort of fix.
Overall this is a correct, narrowly scoped bug fix with a regression test, which is exactly what this repo should want to port by hand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Why
The local-reference inliner treats every object as a schema. Inside a
propertiesmap, it therefore removes ordinary tool argument namesdefinitionsand$defs. A tool with those required fields andadditionalProperties: falsereaches the model with a schema that rejects its valid arguments. These keys are instance property names at that position, per the JSON Schema properties contract.Changes
Walk
propertiesas a name-to-schema map: preserve each name and apply the existing reference resolution to its value. Add one direct regression covering the affected fields and an ordinary referenced-field control.Verification
ts.syserror, so binary smoke was not run.Scope / Tradeoffs
Source-audit fix, with no existing issue claimed. Changes are limited to the
propertiesmap boundary. Existing reference lookup, cycle handling and removal of definition containers at schema positions are retained. This is not a general JSON Schema traversal rewrite.