fix: address Copilot review round 38 — constants must agree, not just types
The cross-branch agreement check ignored `const`, so two branches pinned to `1` and `"1"` both stated no `type`, both matched the text `1`, and the first one's typed constant was sent. Textually indistinguishable constants of different types are ambiguous, and the raw string the user typed is the honest answer. Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
85b030cbde
commit
ab85667dee
1 changed files with 30 additions and 1 deletions
|
|
@ -334,6 +334,24 @@ describe("JSON Utils", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("treats textually equal constants of different types as ambiguous (#2123)", () => {
|
||||
const indistinguishable: Tool = {
|
||||
name: "indistinguishable",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
anyOf: [
|
||||
{ type: "object", properties: { kind: { const: 1 }, a: {} } },
|
||||
{ type: "object", properties: { kind: { const: "1" }, b: {} } },
|
||||
],
|
||||
},
|
||||
};
|
||||
// `kind=1` matches both, so neither typed constant may be assumed —
|
||||
// the raw string is the honest answer.
|
||||
expect(convertToolParameters(indistinguishable, { kind: "1" })).toEqual({
|
||||
kind: "1",
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves an ambiguously typed argument uncoerced (#2123)", () => {
|
||||
const ambiguous: Tool = {
|
||||
name: "ambiguous",
|
||||
|
|
|
|||
Loading…
Reference in a new issue