diff --git a/packages/agy-cli/README.en.md b/packages/agy-cli/README.en.md index e11706c..01d4b23 100644 --- a/packages/agy-cli/README.en.md +++ b/packages/agy-cli/README.en.md @@ -57,6 +57,9 @@ MCP server. The control port listens on loopback only, with a token per process. and says to update. - The private `nc` applies only to the agy processes the plugin starts, but for those it stands in for every `nc` agy runs. +- Every client tool is listed with `_meta: {"antigravity/alwaysLoad": true}`. + Without it agy loads larger tools on demand, out of the model's function + list, and the model cannot reach them (#989). ## Features diff --git a/packages/agy-cli/README.md b/packages/agy-cli/README.md index 39c44d1..9326f39 100644 --- a/packages/agy-cli/README.md +++ b/packages/agy-cli/README.md @@ -43,6 +43,7 @@ agy 连接 `--ide-mcp-port` 时会运行 `nc 127.0.0.1 <端口>`。插件在 agy - 这依赖 agy 拨号的方式,不是 agy 公开承诺的接口,已在 1.4.12 和 1.5.0 上验证。agy 低于 1.4.12 时,插件会直接报错并提示升级。 - 这个 `nc` 只对插件启动的 agy 进程生效,但对这些进程来说,它替换了 agy 运行的所有 `nc`。 +- 客户端的每个工具都带 `_meta: {"antigravity/alwaysLoad": true}` 列出。不带的话,agy 会把较大的工具改为按需加载,不放进模型的函数列表,模型就用不到它们(#989)。 ## 功能 diff --git a/packages/agy-cli/index.mjs b/packages/agy-cli/index.mjs index 2334479..a21ffdf 100644 --- a/packages/agy-cli/index.mjs +++ b/packages/agy-cli/index.mjs @@ -47,6 +47,8 @@ const AGENT_NAME = "magpie-bridge" const MCP_SERVER_PATH = fileURLToPath(new URL("./mcp-server.mjs", import.meta.url)) // agy exposes tools from the --ide-mcp-port server as direct functions with this prefix. const IDE_TOOL_PREFIX = "mcp_ide-tools_" +// agy 1.3.5+: a tools/list entry with this _meta key is never deferred. +const ALWAYS_LOAD = "antigravity/alwaysLoad" const IDLE_MS = positiveTimeout(process.env.AGY_BRIDGE_IDLE_MS, 10 * 60 * 1000) // Read at call time so a host (or a test) can size the pool without a reload. function maxProcs() { @@ -1320,7 +1322,11 @@ class Proc { waiter.resolve() } this.listWaiters = this.listWaiters.filter((item) => item.version > this.listedVersion) - return this.tools + // agy loads an MCP tool on demand, out of the model's function list, unless + // the server marks it always loaded; tools with larger schemas were left out + // and the model could not reach them (#989). Every client-declared tool is + // one the client means the model to see. + return this.tools.map((tool) => ({ ...tool, _meta: { ...tool._meta, [ALWAYS_LOAD]: true } })) } addWatcher(socket) { diff --git a/packages/agy-cli/package.json b/packages/agy-cli/package.json index aefec04..55cf644 100644 --- a/packages/agy-cli/package.json +++ b/packages/agy-cli/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-agy-cli-auth", - "version": "0.1.18", + "version": "0.1.19", "description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI", "type": "module", "main": "./opencode.mjs", diff --git a/packages/agy-cli/test/smoke.mjs b/packages/agy-cli/test/smoke.mjs index ac3f604..7362085 100644 --- a/packages/agy-cli/test/smoke.mjs +++ b/packages/agy-cli/test/smoke.mjs @@ -888,6 +888,37 @@ let nativeConv check("tools/list preserves JSON schema", listed?.tools?.[0] === "echo" || logs().some(event => event.type === "toolsList" && event.tools.includes("echo"))) } +{ + // #989: agy left tools with larger schemas (the reporter's bash at ~1005 + // tokens, grep at ~691) out of the model's function list and loaded them on + // demand, while small ones (read at ~561 and below) were listed. The report + // gives sizes, not the schemas, so these are sized to match. + const words = n => Array.from({ length: n }, (_, i) => `word${i}`).join(" ") + const bigTool = { + name: "bash", + description: words(600), + input_schema: { + type: "object", + properties: { + command: { type: "string", description: words(200) }, + timeout: { type: "number", description: words(40) }, + workdir: { type: "string", description: words(40) }, + description: { type: "string", description: words(60) }, + }, + required: ["command", "description"], + }, + } + const smallTool = { name: "read", description: "Read a file", input_schema: { type: "object", properties: { filePath: { type: "string" } }, required: ["filePath"] } } + const res = await callFetch({ model, messages: [{ role: "user", content: "large tool schema listed" }], tools: [bigTool, smallTool, echoTool] }) + await readSSE(res) + const listed = inits().at(-1)?.tools || [] + check("every client tool is listed always loaded, a large schema too (#989)", + res.status === 200 && listed.length === 3 && + listed.every(tool => tool._meta?.["antigravity/alwaysLoad"] === true) && + listed.find(tool => tool.name === "bash")?.inputSchema?.properties?.command?.type === "string", + JSON.stringify(listed.map(tool => [tool.name, tool._meta, JSON.stringify(tool).length]))) +} + { const secondBody = continuation(nativeBody, nativeEvents, "native-result") const assistant = secondBody.messages[1]