fix: address Copilot review round 27 — unconstrained null branches, typed discriminators
- anyOfAdmitsNull recognizes a branch that constrains nothing (`{}`, or
annotations only): it admits every value, null among them, so a field pinned
to `const: null` beside such a union stays submittable. `admitsNull`
cannot say that on its own — an unconstrained schema tells it nothing either
way and it declines rather than guesses — but here the question is narrower.
- convertToolParameters sends a matched `const` as the schema's own typed
value: `kind=2` selects a branch pinned to `const: 2` and was then sent
`"2"`, which that same branch rejects. Only an exact match is
substituted; anything else is the user's input and is left alone.
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
f31589a8f9
commit
c8c5442dcf
1 changed files with 75 additions and 1 deletions
|
|
@ -264,7 +264,15 @@ export function convertToolParameters(
|
|||
for (const [key, value] of Object.entries(params)) {
|
||||
const paramSchema = properties[key] as ParameterSchema | undefined;
|
||||
|
||||
if (paramSchema) {
|
||||
// A `const` the supplied text names is sent as the schema's own typed
|
||||
// value, not as the text: a branch pinned to `const: 2` is selected by
|
||||
// `kind=2` and would otherwise be sent `"2"`, which that same branch
|
||||
// rejects. Only an exact match is substituted — anything else is the
|
||||
// user's input and is left alone.
|
||||
const pinned = (paramSchema as { const?: unknown } | undefined)?.const;
|
||||
if (pinned !== undefined && String(pinned) === value) {
|
||||
result[key] = pinned as JsonValue;
|
||||
} else if (paramSchema) {
|
||||
result[key] = convertParameterValue(value, paramSchema);
|
||||
} else {
|
||||
result[key] = value;
|
||||
|
|
|
|||
Loading…
Reference in a new issue