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 @@ -110,7 +112,9 @@ MCP server. The control port listens on loopback only, with a token per process.
- **Usage visibility**: Magpie shows the agy subscription usage windows. Each
model's window (its pool's most used one) is what Magpie's routing weighs the
account by for that model, so a routing group puts it by what it has left,
and a model whose pool is used up is passed over for the next member.
and a model whose pool is used up is passed over for the next member. When
the plugin reads the quota directly from Google Code Assist, Magpie also
shows the account's plan and email when that read provides them.

## Assistant prefill

Expand Down Expand Up @@ -281,7 +285,7 @@ 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 |
Expand All @@ -303,6 +307,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 @@ -347,8 +360,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
20 changes: 16 additions & 4 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 @@ -71,7 +72,13 @@ agy 连接 `--ide-mcp-port` 时会运行 `nc 127.0.0.1 <端口>`。插件在 agy
都在客户端侧完成。
- **助手预填**:以 assistant 结尾的预填请求(SillyTavern 预设、继续写、bot 框架)不再
400 拒绝:预填留在本轮并渲染为续写载体,会话跨轮保持对齐,见下文「助手预填」。
- **额度查看**:在 Magpie 里查看 agy 订阅的用量窗口。每个模型的窗口(它所在额度池用得最多的那个)也是 Magpie 路由给这个模型排账号的依据:路由组按剩余额度排它,额度池用完的模型会让给下一个成员。
- **网页搜索**:给 Magpie 的网页搜索提供 `agy-cli:agy`(`magpie search add agy-cli`),
用的是 agy 自己的 `search_web`:插件开一个只有这一个工具的 agy 会话,让它搜这次的查询,
从 agy 保存的这一步输出里读出摘要和来源,然后取消这一轮,模型不写回答。搜索由 agy 在
Google 那边完成,插件不直接请求 Google。每条结果的标题是来源的域名,链接是 Google 的
跳转地址(agy 给出的就是这样),正文是摘要里引用这个来源的句子。按账号搜索时,用的是
这个账号的 agy 登录。
- **额度查看**:在 Magpie 里查看 agy 订阅的用量窗口。每个模型的窗口(它所在额度池用得最多的那个)也是 Magpie 路由给这个模型排账号的依据:路由组按剩余额度排它,额度池用完的模型会让给下一个成员。插件直接向 Google Code Assist 读额度时,Magpie 还会显示这次读取给出的账号套餐和邮箱。

## 助手预填(assistant prefill)

Expand Down Expand Up @@ -197,7 +204,7 @@ 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 自己的系统提示词后面,而不是放进第一条提示词,见下文 |
Expand All @@ -219,6 +226,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 @@ -243,7 +255,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
7 changes: 7 additions & 0 deletions agy-cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@ 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],
["web-search.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],
["transient-history.mjs", false],
]) {
test(`test/${name}`, () => {
// bun's 5s default per test is a fixed wait these process-spawning tests
Expand Down
Loading