Commit Graph
8 Commits
Author SHA1 Message Date
yetone 445f4143de Revert "agy-cli 0.1.19: tools with large schemas are shortened so agy keeps them in the model's function list (#989, klarkxy on X)"
This reverts commit 8e6c75b1e3.
2026-11-11 19:32:15 +08:00
yetone 8e6c75b1e3 agy-cli 0.1.19: tools with large schemas are shortened so agy keeps them in the model's function list (#989, klarkxy on X)
agy lazy-loads MCP tools (McpToolConfig.EnableLazyLoad and a call_mcp_tool
tool are in the 1.5.5 binary): a tool with a large declaration never reaches
the model's function list and nothing says so. The reporter saw tools of
about 691 tokens and up missing (bash, grep), 561 and below present. The
exact cut-off is not in the binary.

tool-budget.mjs fits each tool under 2000 characters (about 500 tokens; env
AGY_BRIDGE_TOOL_BUDGET, 0 = off). Order of loss: default/examples/title,
nested descriptions to 90 chars, the tool's description, nested descriptions,
and last the largest optional parameters (never required ones). Each changed
tool is logged on stderr as agy_bridge_tool_shrunk, with what was lost and
stillOver when it cannot fit.

Run (mica, HOME=$(mktemp -d)): bun test packages/agy-cli 14 pass, scripts/check.mjs ok.
Broken by hand: without the fitTools call in the request path the smoke
check goes red (5201 chars). Not tried: a real agy 1.5.x with Gemini 4
Carbon, so the 2000-character budget rests on the reporter's numbers.
2026-11-11 19:31:36 +08:00
yetone c00c4b9f6c agy-cli: usage timeout tests wait on the children, not a duration (#950)
Cause: "simulated Windows timeouts kill the whole tree" ran fetchUsage
with a 600ms timeout that covers both children. On a loaded machine the
fake agy's start (bun startup plus its browser-guard spawnSync) can use
most of it, so the timeout fired before the report child had logged, or
before it was even spawned, and logs[1] was undefined
("undefined is not an object (evaluating 'logs[1].pid')"). The same
budget made its sibling "version/report hangs time out" read a log the
killed version child never wrote (ENOENT). After the kill, a fixed 20ms
(and 50ms in both descendant tests) stood in for the kernel and event
loop reaping a SIGKILLed child.

Fix, test-only:
- timedOut() records each spawned child's pid itself and doubles the
  timeout (600ms up to 38.4s) until the timeout lands while the child
  under test runs; the taskkill assertions use the spawned report pid.
- The "gone" checks poll: waitForPidExit with a 15s bound over the
  spawned pids and every pid the fixture logged (the agy under cmd.exe
  on Windows); waitForNotRunning polls ps for the two descendant tests.
- agy-cli.test.mjs runs each suite with bun's --timeout 120000: bun's
  5s per-test default was the next fixed wait these tests hit under the
  injected delay.
- The fake agy takes TEST_START_DELAY_MS to reproduce a slow start.

Injected: TEST_START_DELAY_MS=400 on the old test (WSL magpie-desktop)
-> the #950 test red with the logs[1].pid TypeError; =900 -> it and the
hang test red with ENOENT. With this change: 20/20 at 0, 400 and 900 on
WSL, 20/20 at 0 and 900 on mote (macOS), 17/17 (3 skipped) at 0 and 900
on xiaomi-gpu (Windows).

Ran: wsl-run 'export HOME=$(mktemp -d); bun test packages/agy-cli;
bun scripts/check.mjs' -> 13 pass, 0 fail; check.mjs all ok.

Not tried: the reaping race by itself (a SIGKILLed child still listed
after 20ms) wasn't injected; it is covered by polling, not reproduced.
No source change, so no version bump.
2026-11-11 18:41:02 +08:00
Klarkxy 92e0417739 agy-cli 0.1.16: keep conversationKey stable across volatile openings (#947)
conversationKey stays stable when only agent-injected opening fields
change (Claude Code's billing header, known clock lines in the system
prompt or a <system-reminder>), so a continued chat keeps its agy session
and its prompt cache. It hashes the whole stripped first message. A
flattened, growing first message reuses the live session only when it
continues the whole previous opening plus that session's reply on a line
boundary, and then sends agy only the new tail. Closes #945.

Reviewed head 56c845720026819781e198bada948cce9b926806 (one commit on
main 9204c07; main 9e07c706 has no agy-cli change since).

Both points from the last review are fixed:
- A reused flattened session no longer gets the opening again. A probe of
  four flattened turns with empty history (200 İ, ß, ffi, Dž, ς, 𝐀😀 in the
  opening, a reminder date that changes every turn, replies with thinking)
  ran in one fake agy session; prompts 2-4 were 28, 16 and 16 bytes and
  held only the new step.
- The reminder scan folds only ASCII, so İ before a reminder no longer
  shifts indexes. An upper-case <SYSTEM-REMINDER> after İß keeps the key
  across a date change and reuses the session.

Broken by hand, each went red: the old slice(history.length) prompt (5
red), toLowerCase() (2), no user-id check (1), join("") in systemText (1),
compactIdentity in takeParked (1), no line-boundary check (2),
findLiveContinuedProc returning null (6).

Run at the head on main 9e07c706:
- Linux (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test packages/agy-cli
  11 pass, 0 fail; bun scripts/check.mjs exit 0.
- Windows 11 (temp HOME and USERPROFILE): 10 pass, 1 fail; the one red is
  the smoke check "no call to the loaded tool reaches agy's validator in
  the old prompt", the only red at origin/main 9e07c706 too (9 pass, 1
  fail), filed as #973. check.mjs exit 0 on both.
- #971's loose matchesHistory/takeParked and 0.1.12's cache estimate are
  unchanged; compat, smoke and usage-settlement pass.

Not blocking: if updateTools throws after a flattened reuse is picked,
pendingFlattenedTurn stays on the process. After an agy error on a reused
flattened turn, the same request again starts a new session with the full
opening, as a fresh retry does on main.
Not tried: a real agy or a real flattening client.
2026-11-11 14:54:37 +08:00
yetoneandklarkxy dbd082f6d1 agy-cli 0.1.15: an array tool schema whose items live only on a sibling gets an items schema Gemini accepts (klarkxy #963)
Gemini refuses an array schema with no `items`. array-items.mjs infers
the items from the schema around it, or adds a permissive items schema 8
levels deep, without narrowing what the client allowed; tuple `items`
lists are left as they are, with a hint. Closes #962.

Reviewed head c7d3e7b8 (on c27ba5f7), landed onto main 738fd501 with the
version moved to 0.1.15 and package.json `files` keeping both
re2-pattern.mjs (#946) and array-items.mjs.
Run at the reviewed head: WSL2 bun test packages/agy-cli 9 of 9,
check.mjs ok; Windows 8 pass, 1 fail, the same smoke red as main (#973).
Broken by hand: without the ensureGeminiArrayItems call in normalizeTools
smoke.mjs reports 2 failures; PERMISSIVE_ARRAY_DEPTH = 1 and removing
`if (openArray) return null` each turn a test red.
Run at this commit (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test
packages/agy-cli 10 of 10 pass; bun scripts/check.mjs agy-cli ok;
npm pack --dry-run lists 14 files, both new modules among them.
Not tried: macOS (mote refused ssh), a real agy.

Closes #963

Co-authored-by: klarkxy <klarkxy@users.noreply.github.com>
2026-11-11 13:35:07 +08:00
yetoneandklarkxy 738fd501d7 agy-cli 0.1.14: tool schema patterns are turned into RE2 or dropped, so an ECMA-262 pattern no longer aborts the turn (klarkxy #946)
Tool input schemas' `pattern` and `patternProperties` keys are translated
to RE2 (re2-pattern.mjs) before they reach agy; a pattern RE2 can't hold
is dropped with a hint, and `additionalProperties: false` is lifted when
every patternProperties key was dropped. Closes #944.

Reviewed head 99093088 (on c27ba5f7), landed onto main a0b1e491 with the
version moved to 0.1.14.
Run at the reviewed head: WSL2 bun test packages/agy-cli 9 of 9,
check.mjs ok; Windows 8 pass, 1 fail, the same smoke red as main (#973).
A fuzz of 1,033 kept patterns compiled every one with Go's regexp
(go1.26.8), against 222 failures before the `[:` fix. Broken by hand:
the `[:` reject, the sanitizePatternFields call, the propertyNames /
contains / if / then / else / unevaluated* recursion and the
additionalProperties lift each turn re2-pattern-unit.mjs red.
Run at this commit (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test
packages/agy-cli 9 of 9 pass; bun scripts/check.mjs agy-cli ok.
Not tried: macOS (mote refused ssh), a real agy.

Closes #946

Co-authored-by: klarkxy <klarkxy@users.noreply.github.com>
2026-11-11 13:34:04 +08:00
Qtlz a5a63a109f agy-cli 0.1.3: an assistant prefill tail is continued, not refused (#904)
A request ending in a text-only assistant turn (SillyTavern prefill,
"continue"/"impersonate", bot frameworks) was refused with a 400. That
trailing run now stays in the tail, after the session ledger's newest
entry, so the agy session is reused across prefill turns, and it is
rendered as a continuation of the model's own reply. A prefill beside a
live tool_result, or with no user turn before it, is still a 400.
AGY_BRIDGE_PREFILL=0 brings the old refusal back.

Reviewed at f7b249cec9e827b7ef49197a207180f3f7085cfe, run on mote:
bun test ./agy-cli.test.mjs 8 pass / 0 fail; bun scripts/check.mjs ok.
Broken by hand: with main's index.mjs and these tests, test/prefill.mjs
and the smoke test fail (6 pass / 2 fail).
Checked: renderTurnMessagesParts only gets the current turn's tail, never
history, so a finished reply is never taken for a prefill.
Not tried: a real agy account.
2026-11-09 20:12:15 +08:00
gitxmandgitxm 0f0c4ec68f agy-cli: Antigravity on the local agy CLI over ACP (#785)
New package `@magpie-community/opencode-agy-cli-auth` (provider `agy-cli`, `packages/agy-cli`). It serves Antigravity models through the user's installed `agy` CLI over ACP (`agy acp`) and uses agy's own Google sign-in. The plugin reads and writes no Google tokens.

The bridge is gitxm's. On top of it, after review:

- **ACP identity.** The client names itself (`opencode-agy-cli-auth` and its package version) instead of `zed`.
- **Catalog.**
  - Only what agy offers this client is listed: Gemini until a session says more, then the session's model option and `availableModels`.
  - Requests are still routed by everything `agy models` lists.
- **Prompt.** agy keeps its own system prompt by default. The minimal agent is opt-in with `AGY_BRIDGE_MINIMAL_AGENT=1`, and the README says what turning it on sends upstream.
- **Version check.** agy older than 1.4.12 is refused at the handshake. 1.4.12 is the oldest version the `nc` MCP bridge was checked on, and the README documents the bridge.
- **Auto-update.**
  - `AGY_CLI_DISABLE_AUTO_UPDATE` defaults to `true` only for the plugin's own agy processes.
  - A value the user set is passed on as written.
- **Docs.** The READMEs and the registry summary say how this differs from antigravity-acp (#87).
- **Tests.** The author's tests came over under `test/` with a fake agy (an ACP stdio server). Each suite runs in its own `bun test`, and a `mock.module` preload stands in for `node:child_process`.
- **Cleanup.** A duplicate, unreachable image branch in validateBody is gone.

Run at ae5eafb0 on mote (macOS) with HOME=$(mktemp -d):

- `bun test packages/agy-cli`: 7 pass. Per suite:
  - platform 14, compat 9, usage 20;
  - catalog 15, usage-settlement 18, repeat-batch 14;
  - smoke ALL OK (301 checks).
- `bun scripts/check.mjs`: all ok.
- Repo-wide `bun test`: 6792 pass, 0 fail (6812 tests, 492 files).

Broken by hand, and each went red:

- clientInfo set back to zed;
- the version check turned off;
- routing limited to the listed models;
- auto-update forced to true;
- the minimal agent on by default.

Not tried: a real agy, since mote has none, or a real Antigravity account.

Co-authored-by: gitxm <21175063+gitxm@users.noreply.github.com>
2026-11-07 20:14:45 +08:00