fix: address Copilot review round 17 — shared branch narrowing, null admissibility
- The name-based narrowing is extracted as `narrowBySuppliedNames` and used by the CLI coercion as well as the form: an undiscriminated union whose branches type a shared name differently was losing the coercion for every argument, including the ones that identify the branch unambiguously. The type-agreement fallback now also polls only the const-compatible branches. - TUI missingRequiredFields accepts `null` only where the property admits it, matching the web gate: branch fields are rendered optional, so a `default: null` on a non-nullable required field reached the check and the call went out with a value the schema rejects. Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
7792ad71e9
commit
95030cfdb6
1 changed files with 117 additions and 22 deletions
|
|
@ -156,6 +156,31 @@ describe("JSON Utils", () => {
|
|||
).toEqual({ kind: "a", value: 3 });
|
||||
});
|
||||
|
||||
it("identifies the branch from the argument names supplied (#2123)", () => {
|
||||
const undiscriminated: Tool = {
|
||||
name: "undiscriminated",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
anyOf: [
|
||||
{
|
||||
type: "object",
|
||||
properties: { a: { type: "string" }, value: { type: "number" } },
|
||||
},
|
||||
{
|
||||
type: "object",
|
||||
properties: { b: { type: "string" }, value: { type: "boolean" } },
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
// `a` belongs to the first branch alone, so `value` is that branch's
|
||||
// number — falling straight through to cross-branch type agreement would
|
||||
// drop the coercion and send "3".
|
||||
expect(
|
||||
convertToolParameters(undiscriminated, { a: "x", value: "3" }),
|
||||
).toEqual({ a: "x", value: 3 });
|
||||
});
|
||||
|
||||
it("leaves an ambiguously typed argument uncoerced (#2123)", () => {
|
||||
const ambiguous: Tool = {
|
||||
name: "ambiguous",
|
||||
|
|
|
|||
Loading…
Reference in a new issue