agy-cli: start agy without the machine's own skills when it can (#1166)

On Windows with agy 1.5.9, a session loaded 120 local skills from
~/.gemini/skills, ~/.gemini/config/skills and ~/.agents/skills although
the bridge agent says inheritCustomizations: false. Skills and the
client's MCP tools share agy's 20,000-token customization budget, so
agy dropped the six largest client tools (task, shell, …) and three
skills.

agy 1.5.9's acp takes --include-default-customizations (default true).
The bridge now passes --include-default-customizations=false when
`agy acp --help` lists the flag. An agy without it exits on an unknown
flag, so it is never passed blind. The answer is kept per binary (path,
mtime, size); a probe that errors or times out is asked again. The bare
`agy acp` model probe is unchanged. 0.1.52.

Run:
- bun test packages/agy-cli on mote (temp HOME): 21 pass, 0 fail;
  bun scripts/check.mjs agy-cli ok.
- the same on Windows (win-run, xiaomi-gpu): 21 pass, 0 fail.
- test/smoke.mjs alone with bun on mote: ALL OK (348 checks).
- real agy 1.5.9 on macOS: `agy acp --help` prints the flag on stderr
  (exit 0); a session started with the flag set to false runs.
Broken by hand: without the args.push in Proc.start, repeat-batch's
"#1166 … asked once" test and smoke's #1166 check go red.
Not tried: the reporter's Windows machine with its 120 skills. On this
Mac the default run sent no user skills to the model either, so it is
not shown here that the flag keeps them out; the reporter is asked to
confirm.
This commit is contained in:
yetone
2026-11-15 06:43:07 +08:00
parent 4a64252bd7
commit 57d1cc6a9f
5 changed files with 76 additions and 2 deletions
+27
View File
@@ -200,6 +200,32 @@ function findAgy() {
return null
}
// agy loads the machine's own skills (~/.gemini/skills, ~/.agents/skills, …)
// into an ACP session even when the agent says inheritCustomizations: false.
// They share agy's 20,000-token customization budget with the client's tools,
// and over it agy drops the largest tools (plugins#1166). agy 1.5.9's acp
// takes --include-default-customizations=false to leave them out, but an
// agy without the flag refuses to start on it, so it is passed only when
// `agy acp --help` lists it. The answer is kept per binary (path, mtime,
// size), so an agy update asks again; a probe that failed is asked again.
const customizationFlag = new Map()
export function noDefaultCustomizationsArgs(agyPath) {
let key = agyPath
try {
const st = fs.statSync(agyPath)
key += `\0${st.mtimeMs}\0${st.size}`
} catch {}
let probe = customizationFlag.get(key)
if (!probe) {
probe = execOnce(agyPath, ["acp", "--help"], { timeoutMs: 10_000 }).then(({ err, stdout, stderr, timedOut }) => {
if (err || timedOut) customizationFlag.delete(key)
return /--include-default-customizations\b/.test(stdout + stderr)
})
customizationFlag.set(key, probe)
}
return probe.then((ok) => (ok ? ["--include-default-customizations=false"] : []))
}
function execOnce(file, args, opts = {}) {
return new Promise((resolve) => {
let child
@@ -1639,6 +1665,7 @@ class Proc {
"--ide-mcp-port", String(controlServer.address().port),
]
if (this.workDir) args.push("--add-dir", this.workDir)
args.push(...await noDefaultCustomizationsArgs(this.agyPath))
try {
const childEnv = { ...process.env }
const inheritedPath = process.env.PATH || childEnv.Path || ""
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-agy-cli-auth",
"version": "0.1.51",
"version": "0.1.52",
"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",
+25
View File
@@ -1020,3 +1020,28 @@ test("the same opening sent to several models at once is answered for each", asy
assert.equal(arrived, ids.length)
})
})
// ------------------------------------------- #1166 machine customizations
test("#1166: an agy whose acp --help lists the flag starts without the machine's own skills, asked once", async () => {
await withKit({ acpHelp: "Usage of acp:\n --include-default-customizations\n \tload the default customizations (default true)\n" }, async (kit) => {
scriptedAgent(kit)
for (const user of ["custom-a", "custom-b"]) {
const reply = await readSse(await kit.request(baseBody({ metadata: { user_id: user }, messages: [{ role: "user", content: "hello " + user } ] })))
assert.equal(reply.stopReason, "end_turn")
}
assert.equal(kit.acpSpawns.length, 2, "two conversations, two processes")
for (const spawn of kit.acpSpawns) assert.ok(spawn.args.includes("--include-default-customizations=false"), spawn.args.join(" "))
assert.equal(kit.helpSpawns.length, 1, "acp --help is asked once per agy binary")
})
})
test("#1166: an agy without the flag is never given it, so it still starts", async () => {
await withKit({}, async (kit) => {
scriptedAgent(kit)
const reply = await readSse(await kit.request(baseBody({ metadata: { user_id: "custom-old" }, messages: [{ role: "user", content: "hello old" }] })))
assert.equal(reply.stopReason, "end_turn")
assert.equal(kit.acpSpawns.length, 1)
assert.ok(!kit.acpSpawns[0].args.some((arg) => arg.startsWith("--include-default-customizations")), kit.acpSpawns[0].args.join(" "))
})
})
+12 -1
View File
@@ -88,6 +88,11 @@ if (argv.includes("models")) {
process.stdout.write("gemini-test-medium\tGemini Test (Medium)\ngemini-test-high\tGemini Test (High)\ngemini-test-low\tGemini Test (Low)\nclaude-test-medium\tClaude Test (Medium)\n")
process.exit(0)
}
if (argv[0] === "acp" && argv.includes("--help")) {
log({ type: "acpHelp" })
process.stderr.write("Usage of acp:\n --agent string\n --include-default-customizations\n \tload the default customizations (default true)\n")
process.exit(0)
}
if (argv[0] !== "acp") {
process.stderr.write("unknown subcommand\n")
process.exit(2)
@@ -475,7 +480,7 @@ async function handle(message) {
model = "gemini-test-medium"
await connectIde()
log({
type: "init", pid: process.pid, convId: session.id, resumed: message.method === "session/resume", update: process.env.AGY_CLI_DISABLE_AUTO_UPDATE,
type: "init", args: argv, pid: process.pid, convId: session.id, resumed: message.method === "session/resume", update: process.env.AGY_CLI_DISABLE_AUTO_UPDATE,
cwd: process.cwd(), addDir, agentConfig, clientInfo, systemAppend: params._meta?.antigravity?.systemPrompt?.append ?? null,
tools, idePort,
})
@@ -2818,6 +2823,12 @@ for (const location of ["inline", "system", "developer", "user"]) {
check("AGY_BRIDGE_MINIMAL_AGENT=1 turns on the minimal agent", !!init && init.agentConfig.includes("excludeDefaultComponents: true"), init?.agentConfig)
}
{
// the bridge's sessions; the bare `agy acp` model probe only lists models
const sessions = inits().filter(event => event.args.includes("--agent"))
const without = sessions.filter(event => !event.args.includes("--include-default-customizations=false"))
check("an agy whose acp --help lists it starts without the machine's own customizations (#1166)", sessions.length > 0 && without.length === 0, JSON.stringify(without.map(event => event.args)))
}
check("all ACP children disable auto update when the user set nothing", inits().length > 0 && inits().every(event => event.update === "true"))
check("child launches never mutate the parent's update setting", process.env.AGY_CLI_DISABLE_AUTO_UPDATE === undefined)
if (originalAutoUpdate === undefined) delete process.env.AGY_CLI_DISABLE_AUTO_UPDATE
+11
View File
@@ -419,6 +419,7 @@ export async function createBridgeKit(options = {}) {
modelsSpawns: [],
acpSpawns: [],
otherSpawns: [],
helpSpawns: [],
spawnSyncs: [],
execFiles: [],
modelsBehavior: options.modelsBehavior ?? { stdout: modelsOutput(BASE_MODEL_ROWS) },
@@ -469,6 +470,16 @@ export async function createBridgeKit(options = {}) {
})
const spawn = (file, args = [], opts = {}) => {
if (args[0] === "models") return spawnModels(kit, file, args)
if (args[0] === "acp" && args.includes("--help")) {
// agy's flag usage goes to stderr; an older agy doesn't list the flag
kit.helpSpawns.push({ file, args })
const child = new FakeChild(kit, file, args)
setImmediate(() => {
if (options.acpHelp) child.stderr.emit("data", options.acpHelp)
child.finish(0)
})
return child
}
if (args[0] === "acp") {
const child = new FakeChild(kit, file, args)
kit.acpSpawns.push({ file, args, env: opts.env })