agy-cli forwards a run_command tool that declares toolSummary when agy adds its own. agy adds a required toolSummary to the MCP tools it loads. When the client's own run_command already lists toolSummary as required, the duplicate makes the schema invalid and the toolbox fails to start. The bridge now drops toolSummary from run_command's required list when it lists the tool. On the way back it fills in "Run command" when agy kept the summary to itself and the client's schema declares the property. A summary the model sent is kept, and a schema without the property is left alone. Run at 52b77b78 on mote: packages/agy-cli `bun test` 25/25. Broken by hand: with main's index.mjs, the new tool-summary test goes red. The author checked a live agy client: run_command is the only tool that requires toolSummary, and an agy-to-magpie-to-agy session ran `pwd`. Not tried here: a live agy session, since the local agy account is disabled. Co-authored-by: andrew-zyf <andrew-zyf@users.noreply.github.com>
47 lines
2.0 KiB
JavaScript
47 lines
2.0 KiB
JavaScript
import { test } from "node:test"
|
|
import assert from "node:assert/strict"
|
|
import { baseBody, createBridgeKit, readSse } from "./testkit.mjs"
|
|
|
|
async function callRunCommand(inputSchema, args) {
|
|
const kit = await createBridgeKit()
|
|
try {
|
|
let listed
|
|
kit.prompts.push(async (agent) => {
|
|
listed = await agent.listTools()
|
|
await agent.tool("run_command", args)
|
|
})
|
|
const body = baseBody({ tools: [{ name: "run_command", input_schema: inputSchema }] })
|
|
const result = await readSse(await kit.request(body))
|
|
return { schema: listed.result.tools[0].inputSchema, call: result.content.find((item) => item.type === "tool_use") }
|
|
} finally {
|
|
await kit.dispose()
|
|
}
|
|
}
|
|
|
|
test("run_command avoids agy's toolSummary collision and restores the argument for the client", async () => {
|
|
const schema = {
|
|
type: "object",
|
|
properties: { CommandLine: { type: "string" }, toolSummary: { type: "string" } },
|
|
required: ["CommandLine", "toolSummary"],
|
|
additionalProperties: false,
|
|
}
|
|
const result = await callRunCommand(schema, { CommandLine: "pwd" })
|
|
assert.deepEqual(result.schema.required, ["CommandLine"])
|
|
assert.deepEqual(result.call.input, { CommandLine: "pwd", toolSummary: "Run command" })
|
|
assert.deepEqual(schema.required, ["CommandLine", "toolSummary"])
|
|
})
|
|
|
|
test("run_command keeps supplied summaries and does not add one to unrelated schemas", async () => {
|
|
const schema = {
|
|
type: "object",
|
|
properties: { CommandLine: { type: "string" }, toolSummary: { type: "string" } },
|
|
required: ["CommandLine", "toolSummary"],
|
|
}
|
|
const supplied = await callRunCommand(schema, { CommandLine: "pwd", toolSummary: "Show location" })
|
|
assert.equal(supplied.call.input.toolSummary, "Show location")
|
|
const withoutSummary = await callRunCommand({
|
|
type: "object", properties: { command: { type: "string" } }, required: ["command"], additionalProperties: false,
|
|
}, { command: "pwd" })
|
|
assert.deepEqual(withoutSummary.call.input, { command: "pwd" })
|
|
})
|