Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ channel: Antigravity's models over ACP. The differences:
history as context. This plugin keeps a pool of agy processes, reuses one agy
session for one conversation, and picks it up again with `session/resume`
after a restart; only when that fails does it replay the history, within a
byte budget.
byte budget. When magpie's image-slim swaps an earlier image for its
placeholder (on Codex, a whole view_image output for one line of text), or
magpie leaves one out to fit a size or image limit, the session holds.
- **Tool calls**: Antigravity ACP ends the turn with the call as the reply's
`tool_calls`. This plugin feeds the client's result back into the same agy
turn (see "Tool bridge" below).
Expand Down Expand Up @@ -101,7 +103,8 @@ MCP server. The control port listens on loopback only, with a token per process.
own tools (shell, file edits, browser) is refused. A request for one of the
client's tools on the bridge's `ide-tools` server is allowed once, since that
tool runs in the client under the client's own permissions. Real actions
happen on the client side.
happen on the client side. Set `AGY_BRIDGE_ALLOW_AGY_TOOLS=1` to instead start
agy with `--dangerously-skip-permissions` and let its own tools through.
- **Assistant prefill**: requests that end with a text-only assistant message
(SillyTavern presets, "continue"/"impersonate", bot frameworks) are served
instead of rejected; the session ledger stays aligned across turns. See
Expand Down Expand Up @@ -280,8 +283,9 @@ account", which keeps its sign-in in a file.
| `AGY_BRIDGE_MAX_PROCS` | 16 | Maximum number of agy processes in the pool |
| `AGY_BRIDGE_THINKING` | on | Set to `0` to stop forwarding thought summaries |
| `AGY_BRIDGE_EFFORT` | unset | Force a thinking level: `minimal`, `low`, `medium`, `high`, `xhigh` or `max` |
| `AGY_BRIDGE_MINIMAL_AGENT` | off | Set to `1` to drop agy's own prompt components; see "Minimal agent" below |
| `AGY_BRIDGE_MINIMAL_AGENT` | off | **⚠️ Ban risk, not recommended.** Set to `1` to drop agy's own prompt components, so requests upstream no longer look like the official agy client's; a user reported their account banned within hours of turning it on. See "Minimal agent" below |
| `AGY_BRIDGE_TELEMETRY` | off (agy reports nothing) | The bridge starts agy with `--disable-telemetry` when agy's `acp --help` lists it; set to `1` to keep agy's own reporting |
| `AGY_BRIDGE_ALLOW_AGY_TOOLS` | off | Set to `1` to start every `agy acp` with `--dangerously-skip-permissions`, so agy's own tools (shell, file edits, browser) auto-approve instead of the bridge refusing each `session/request_permission`. Client `ide-tools` still run under the client's own permissions. agy's tools run on the computer magpie runs on, with your user's rights, for every request that reaches this provider: a client on another machine, or anyone holding a gateway key, can run commands there. Leave off unless only you use it |
| `AGY_BRIDGE_SYSTEM_APPEND` | off | Set to `1` to append the client's system prompt to agy's own instead of putting it in the first prompt; see below |
| `AGY_BRIDGE_IDLE_MS` | 600000 | How long a process may sit idle before it is reclaimed; the session can still resume |
| `AGY_BRIDGE_SPARE` | on | Keeps one spare agy per account, started but with no session and no request sent, so a new conversation skips agy's start; set to `0` to turn it off |
Expand All @@ -301,6 +305,15 @@ account", which keeps its sign-in in a file.

## Minimal agent (`AGY_BRIDGE_MINIMAL_AGENT=1`)

> **⚠️ Ban risk, not recommended.** With it on, requests go upstream without
> agy's own system prompt, so they no longer look like the official agy
> client's, and the point of this plugin is that requests are sent by the
> official client and look like it. A user reported their account was banned
> within hours of turning it on. That is one report, not proof of cause, but
> treat the risk as real. While it is on, the plugin prints the same warning to its
> log, once a process. If you turned it on, unset it to go back to the
> default.

By default agy runs every request with its own system prompt, and the
client's system prompt goes as `<external_system_instructions>` at the start
of the first prompt. Antigravity answers a bare 429 to a growing set of
Expand Down Expand Up @@ -345,8 +358,8 @@ request that goes upstream then has none of agy's own system prompt, only
the plugin's one-line tool note and the client's system prompt (sent in one
of the two ways above). The original author measured about 8,400 input
tokens per model call with agy's prompt and about 500 without. The cost is
that upstream no longer sees agy's own request shape, which is why it is
off unless you turn it on.
that upstream no longer sees agy's own request shape, a ban risk (see the
top of this section), which is why it is off and not recommended.

## Troubleshooting

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ OpenCode、Claude Code 等客户端经由 Magpie 调用 agy 向本插件开放
机器上没有时,在 Magpie 里登录会按 Google 官方安装脚本的方式装一份(见「环境要求」)。
- **会话**:Antigravity ACP 每个请求开一个新会话,把历史当作上下文带上。本插件维护一个
agy 进程池,同一段对话复用同一个 agy 会话,重启后用 `session/resume` 接上;只有接不上时
才在字节预算内重放历史。
才在字节预算内重放历史。magpie 的 image-slim 把较早的图片换成占位文字(Codex 上是整段
view_image 结果换成一行字),或 magpie 为满足大小、图片数上限省去较早的图片时,会话照常复用。
- **工具调用**:Antigravity ACP 把工具调用作为回复的 `tool_calls` 结束这一轮。本插件把
客户端的结果送回同一轮 agy 对话(见下文「工具桥接」)。
- **额度**:本插件读 agy 自己的 `/usage` 报告;Antigravity ACP 读每次回复带的配额。
Expand Down Expand Up @@ -197,8 +198,9 @@ macOS 上,以 LaunchDaemon 方式运行的 Magpie 不在你的登录会话里
| `AGY_BRIDGE_MAX_PROCS` | 16 | agy 进程池上限 |
| `AGY_BRIDGE_THINKING` | 开启 | 设为 `0` 关闭思考摘要 |
| `AGY_BRIDGE_EFFORT` | 未设置 | 强制思考等级:`minimal` / `low` / `medium` / `high` / `xhigh` / `max` |
| `AGY_BRIDGE_MINIMAL_AGENT` | 关闭 | 设为 `1` 去掉 agy 自带的提示组件,见下文「精简 agent」 |
| `AGY_BRIDGE_MINIMAL_AGENT` | 关闭 | **⚠️ 有封号风险,不建议开启。** 设为 `1` 去掉 agy 自带的提示组件,发往上游的请求就和官方 agy 客户端的不一样了;有用户反馈开启几个小时后账号被封。见下文「精简 agent」 |
| `AGY_BRIDGE_TELEMETRY` | 关闭(agy 不上报) | 插件启动 agy 时带上 `--disable-telemetry`(agy 的 `acp --help` 没这个开关就带不上);设成 `1` 保留 agy 自己的上报 |
| `AGY_BRIDGE_ALLOW_AGY_TOOLS` | 关闭 | 设为 `1` 让每个 `agy acp` 带 `--dangerously-skip-permissions` 启动,agy 自带的工具(shell、改文件、浏览器)自动放行,不再由 bridge 逐个拒绝 `session/request_permission`。客户端 `ide-tools` 仍在客户端自己的权限下运行。agy 的工具在 magpie 所在的电脑上以你的用户权限运行,凡是到达这个 provider 的请求都能用:另一台机器上的客户端、或持有网关密钥的任何人,都能在这台电脑上执行命令。只有你自己用时才打开 |
| `AGY_BRIDGE_SYSTEM_APPEND` | 关闭 | 设为 `1` 把客户端的系统提示词附加到 agy 自己的系统提示词后面,而不是放进第一条提示词,见下文 |
| `AGY_BRIDGE_IDLE_MS` | 600000 | 进程空闲多久后回收(会话仍可续接) |
| `AGY_BRIDGE_SPARE` | 开启 | 每个账号预先启动一个备用 agy(只启动、不建会话,不发任何请求),新对话直接用它,省掉 agy 的启动时间;设为 `0` 关闭 |
Expand All @@ -218,6 +220,11 @@ macOS 上,以 LaunchDaemon 方式运行的 Magpie 不在你的登录会话里

## 精简 agent(`AGY_BRIDGE_MINIMAL_AGENT=1`)

> **⚠️ 有封号风险,不建议开启。** 开启后,发往上游的请求不再带 agy 自己的系统提示词,和官方
> agy 客户端发出的请求不一样了;而这个插件的意义正在于请求由官方客户端发出、看起来就是官方客户端。
> 有用户反馈开启后几个小时账号就被封了。这只是一例反馈,不能证明就是它导致的,但请把这个风险当真。
> 开启时插件会在日志里打印一行同样的警告(每个进程一次)。已经开了的话,去掉这个变量即可恢复默认。

默认情况下,agy 用它自己的系统提示词跑每个请求,客户端的系统提示词作为
`<external_system_instructions>` 放在第一条提示词开头。Antigravity 对附加在 agy 系统提示词
后面的越来越多 agent 的提示词直接回 429(11-15 起包括 Claude Code 的 "You are an interactive
Expand All @@ -242,7 +249,7 @@ DeepSeek Harness 的第一句 "You are an AI agent powered by DeepSeek Harness."
设为 `1` 后,临时 agent 带上 `excludeDefaultComponents: true`:发往上游的请求里不再有
agy 自己的系统提示词,只剩插件的一行工具说明和客户端的系统提示词(同样以上面两种方式之一
发送)。原作者实测每次模型调用的输入从约 8,400 token 降到约 500 token。代价是上游看到的
不再是 agy 自己的请求形态,所以默认关闭,由你自行决定是否开启。
不再是 agy 自己的请求形态,有封号风险(见本节开头),所以默认关闭,不建议开启。

## 常见排查

Expand Down
15 changes: 15 additions & 0 deletions agy-cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ for (const [name, mocks] of [
["step-usage.mjs", false],
["tool-schema.mjs", false],
["tool-summary.mjs", false],
["call-mcp-tool.mjs", false],
["usage-settlement.mjs", false],
["steer-in-session.mjs", false],
["dropped-call.mjs", false],
Expand All @@ -32,10 +33,18 @@ for (const [name, mocks] of [
["conversation-key.mjs", false],
["windows-nc.mjs", false],
["spare.mjs", false],
["account-scope.mjs", false],
["stateless-reuse.mjs", false],
["tools-listed.mjs", false],
["concurrent-convs.mjs", false],
["masking-drift.mjs", false],
["spilled-output.mjs", false],
["tool-result-prefill.mjs", false],
["tool-step-retry.mjs", false],
["image-bytes.mjs", false],
["dsh-replay-state.mjs", false],
["duplicate-result-notice.mjs", false],
["image-slim.mjs", false],
]) {
test(`test/${name}`, () => {
// bun's 5s default per test is a fixed wait these process-spawning tests
Expand All @@ -53,6 +62,12 @@ test("test/re2-pattern-unit.mjs", () => {
expect(code).toBe(0)
}, 70_000)

test("test/image-signature-unit.mjs", () => {
const { code, output } = run([path.join(dir, "image-signature-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)

test("test/smoke.mjs against a fake agy", () => {
const { code, output } = run([path.join(dir, "smoke.mjs")], 240_000)
expect(output).toMatch(/ALL OK \(\d+ checks\)/)
Expand Down
Loading