Skip to content
Open
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
106 changes: 87 additions & 19 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,18 @@ response.

- The work is done by the real agy CLI over the ACP channel it ships with. The
ACP handshake's `clientInfo` is the plugin's own package name and version
(`opencode-agy-cli-auth`), not Zed or any other editor. The plugin calls
none of Google's endpoints itself: the quota too is read through agy alone
(`opencode-agy-cli-auth`), not Zed or any other editor. Model requests all
go through `agy acp`, and the quota too is read through agy alone
(`agy -p /usage`, see "Usage quota"), never with agy's stored token.
The plugin sends Google one request of its own with the account: when a
sign-in finishes (Sign in, Add another Google account, an import) and
agy's stored sign-in doesn't name its email (no `id_token_email`), it asks
`https://www.googleapis.com/oauth2/v2/userinfo` once with the access token
agy stored, and reads only the account's email from it, to name the
account in Magpie. That is at most once per sign-in; the answer isn't
cached, and an expired token isn't renewed for it. A sign-in that names
its email sends nothing. Downloading and update checks of the plugin's own
copy of agy (see "Requirements") carry no account.
- Tools that belong to the client, such as file reads, writes and shell commands,
are exposed to the model over MCP. The client runs them and the results flow
back into the same agy conversation, so the model sees ordinary native tool
Expand Down Expand Up @@ -93,12 +102,14 @@ MCP server. The control port listens on loopback only, with a token per process.
- **The models agy offers**: the list follows the model option agy advertises
in the ACP session. A model `agy models` lists but the session does not offer
this client (agy may keep Claude and GPT-OSS for clients it recognises) is
left out. To list models, the plugin opens one session with `agy acp` (no
prompt is sent) and reads what it offers; until it has, only Gemini is listed.
The last list agy gave and offered is kept in `models.json` beside the session
state file, so after a restart that list is served while agy is asked again:
both what it lists and what a session offers, and again whenever the list
changes (another account or plan).
left out. An idle account sends Google nothing of its own: `agy models` runs
at sign-in, when you refresh the model list, or when there is no list yet.
What agy offers comes from each request's own session; apart from that,
`agy acp` is asked once (a session, no prompt) at sign-in and on a refresh,
run as a request runs it (telemetry off, no default customizations). Until
agy has said, only Gemini is listed. What agy listed and offered, and the
account's tier, are kept in `models.json` beside the session state file and
served as they are after a restart, without asking agy again.
Models and thinking levels can be switched mid-conversation without losing
history.
`agy models` runs with `--settings '{"modelProvider":""}'`, so a
Expand All @@ -119,6 +130,10 @@ MCP server. The control port listens on loopback only, with a token per process.
otherwise. A video or audio URL, or one sent to a model other than Gemini,
gets HTTP 400. `count_tokens` counts a video or audio clip as one image, so
a long clip is undercounted.
- **PDF input** (Gemini models, since 0.1.189): a PDF attached to the message
(base64) is written to `attachments/<sha256>.pdf` as a video is, and agy's
own file reader hands it to Gemini. Sent to a model other than Gemini, it
gets HTTP 400.
- **Tool calls**: parallel and consecutive calls both work. A tool that runs past
150 seconds first gets a "still running" placeholder; once the real result
arrives, the same turn continues, and the client executes each call exactly once.
Expand All @@ -145,6 +160,40 @@ MCP server. The control port listens on loopback only, with a token per process.
(SillyTavern presets, "continue"/"impersonate", bot frameworks) are served
instead of rejected; the session ledger stays aligned across turns. See
"Assistant prefill" below.
- **Batched web search (opt-in, off by default)**: by default Magpie
handles client `web_search` / `web_fetch` tools one by one. To let the model
submit batched Anthropic hosted `web_search` and `web_fetch` calls inside the
live `agy` session (up to 10 search queries or 3 URL fetches per call, running
at most 2 MCP calls at a time without dropping the live session), enable
**"Batched web search"** under **Providers › Antigravity (local agy CLI)**, run
`magpie plugin options agy-cli '{"hosted_search":true}'`, or set
`AGY_BRIDGE_HOSTED_SEARCH=1`. Restart Magpie after changing the switch. It
calls Magpie's local loopback `/mcp/magpie/web-search` endpoint (reusing
configured search providers, keys, and proxies; loopback calls need and send
no gateway key and never read `caller-keys.json`, while non-loopback URLs
require setting `AGY_BRIDGE_SEARCH_URL` explicitly and only send an explicit
`AGY_BRIDGE_SEARCH_KEY`), defaults to 20 searches per turn when `max_uses` is
omitted (`AGY_BRIDGE_SEARCH_DEFAULT_MAX_USES` can lower that cap within 1–20,
never past 20), rejects keyword-less `site:`-only queries before spending
quota, and never bills failed searches in `usage.server_tool_use`. `web_fetch`
defaults to 20,000 characters (up to 100,000 per call, split across batched
URLs) when the client provides a
file-reading or shell tool (such as Claude Code, Codex, or OpenCode), or fits
within 7,500 UTF-8 bytes with exact code-point `offset`s for inline-only
clients (staying below `agy`'s ~10 KiB single-tool-output spill cliff),
supporting per-URL continuation via single-URL `url` + `offset` or
`requests: [{ url, offset, max_chars }]`.
Notes: `allowed_domains` and `blocked_domains` check initial URLs only (not
redirect targets), and `web_fetch` accepts any public URL the model writes
(Magpie's fetcher blocks private and loopback addresses); do not manually
select `agy-cli/<model>` as Magpie's model searcher while this switch is on,
and note that with **"Antigravity (agy)"** (`agy-cli:agy`) as Magpie's search
source every query opens a separate `agy` session on the signed-in Google
account (so avoid pairing that search source with this switch). Known limitation (verified on `magpie v0.1.5384`):
while enabled, Anthropic non-streaming `/v1/messages` and OpenAI
`/v1/responses` (streaming and non-streaming) execute searches and answer from
them, while omitting search result blocks (`server_tool_use` /
`web_search_call`) and `server_tool_use` usage counts from the response.
- **Web search**: the plugin gives Magpie's web search `agy-cli:agy`
(`magpie search add agy-cli`), through agy's own `search_web`. It opens a
default-agent session whose workspace hook allows only `search_web`, asks
Expand Down Expand Up @@ -239,7 +288,8 @@ After installing, sign in from Magpie; no terminal needed.
minutes. Google credentials stay with agy (in the system keyring); the
plugin never stores them, and counts the sign-in as done only once
`agy models` lists the account's models. Magpie names the account by the
Google email agy stored (the one thing read from the keyring for it).
Google email agy stored (read from the keyring; when the sign-in doesn't
name it, Google is asked once with agy's stored token, see "What it is").
To add another Google account, click agy-cli's Add another account (or
Sign in) and pick "Add another Google account". The new account gets an
agy home of its own (under `~/.local/state/magpie-agy-bridge/accounts/`),
Expand Down Expand Up @@ -324,9 +374,13 @@ read asks Google about twelve times, one after another, which usually takes
5–10 seconds and longer on a first start, on Windows, for a newly added account
or behind a slow network or proxy, so the plugin gives it 45 seconds. Magpie
waits 20 seconds for a read: past that the account says agy is still reading
its quota, agy reads on, and the next refresh shows what it read without
running agy again. A read that doesn't finish in 45 seconds says so, names a
slow network or proxy as the usual cause, and is tried again a minute later.
its quota, agy reads on, and the next refresh shows what it read: within
three minutes without running agy again; later, agy reads again and what it
read before answers if agy is slow again. What it read is kept until a
refresh takes it, a window in it resets or five hours pass, the account
signs out or changes, or a read after it fails. A read that doesn't finish
in 45 seconds says so, names a slow network or proxy as the usual cause, and
is tried again a minute later.
When agy refuses `/usage` for the account's region ("not currently available
in your location"), the plugin asks agy acp which tier it serves the account
on. Google can name a tier the account can't have (the free one, in a region
Expand Down Expand Up @@ -359,8 +413,9 @@ only `config/config.json` differs, without `gateway` and `models`. Your
While agy's access token has ended or ends within two minutes (with a refresh
token to renew it), agy isn't run for usage: a renewal that fails there can
open a Google sign-in in the browser (#1234). The account says agy's sign-in is
due to be renewed; agy renews it on the account's next chat and the quota is
read after that. Until then the last quota read stays shown.
due to be renewed; agy renews it on the account's next chat, and a refresh
after that chat reads the quota (nothing reads it by itself). Until then the
last quota read stays shown.

A signed-out agy opens Google's sign-in page in the browser when it runs, so
before running agy for usage or the model list, the plugin looks at agy's stored
Expand Down Expand Up @@ -419,6 +474,13 @@ The plugin gets these from magpie's own process, so set them before magpie start
| `AGY_CLI_DISABLE_AUTO_UPDATE` | `true` for the plugin's agy processes | agy's own variable. When you set it, agy gets your value; see "Requirements" |
| `AGY_BRIDGE_PREFILL` | on | Set to `0` to restore the stock 400 reject for assistant prefill tails; see "Assistant prefill" |
| `AGY_BRIDGE_PREFILL_CARRIER_NOTE` | English system note | The note line rendered before a prefill fragment (sent to the model) |
| `AGY_BRIDGE_HOSTED_SEARCH` | off (follows UI switch) | Override the "Batched web search" switch: `1` forces on, `0` forces off |
| `AGY_BRIDGE_SEARCH_URL` | auto-discovered local loopback Magpie | Explicit URL for Magpie's `/mcp/magpie/web-search` endpoint (only way to target a non-loopback host) |
| `AGY_BRIDGE_SEARCH_KEY` | unset | Explicit Bearer key sent only when `AGY_BRIDGE_SEARCH_URL` targets a non-loopback host (loopback calls send no key; `caller-keys.json` is never read) |
| `AGY_BRIDGE_MAGPIE_CONFIG_DIR` | auto-discovered Magpie config dir | Explicit Magpie config directory containing `gateway.json` / `settings.json` |
| `AGY_BRIDGE_SEARCH_DEFAULT_MAX_USES` | 20 | Default per-turn cap for in-bridge hosted search/fetch when the client omits `max_uses` (1–20; can lower the cap, never raise past 20; client `max_uses` wins) |
| `AGY_BRIDGE_FETCH_MAX_CHARS` / `AGY_BRIDGE_SEARCH_MCP_MAX_CHARS` | 20000 (7500-byte fit for inline-only clients) / 7500 | Default character budget per `web_fetch` call (20000 split across URLs when the client provides a file-reading tool, or fitted within 7500 UTF-8 bytes with exact code-point `offset`s for inline-only clients) / UTF-8 byte cap per inline MCP reply returned to agy |
| `AGY_BRIDGE_SEARCH_TIMEOUT_MS` / `AGY_BRIDGE_FETCH_TIMEOUT_MS` | 30000 / 30000 | Per-call timeout in ms for hosted `web_search` / `web_fetch` |

## Minimal agent (`AGY_BRIDGE_MINIMAL_AGENT=1`, no longer has an effect)

Expand Down Expand Up @@ -479,6 +541,12 @@ implicit DOM, route, or screenshot context." in its Web GUI paragraph
(#1105) get the 429 as written too, so they go as "You're …" and "The
browser gives …".

WorkBuddy's first line, "This conversation is powered by <model>" (#1871),
gets the 429 whichever model it names, in the system prompt and in a
user's turn alike. The whole line, model and any label after it, goes as
"This conversation is powered by an AI model.", in the system prompt, a
user's turn and a tool result.

agy reads a command name anywhere in a prompt as the user running that
command: `/learn` (or `/plan`, `/goal`, …, or a skill of the session's)
between spaces, or at the start or end, gets the command's whole text added
Expand Down Expand Up @@ -512,11 +580,11 @@ without it. Paths, URLs, `/learn.`, `/Learn`, `` `/learn` `` and
- **Image requests return HTTP 400**: the running agy does not advertise image
support (1.5.0 or later is needed). Only inline base64 is accepted; image URLs
are rejected.
- **Documents**: agy reads text and images only. A text document (plain text,
base64 text/JSON/XML) goes as its text, and a URL document goes as its URL,
for the model to fetch with a tool. A PDF read by a tool reaches the model as
a note to extract its text another way; a PDF attached to the message itself
gets HTTP 400 saying so. Paste its text or attach its pages as images instead.
- **Documents**: a text document (plain text, base64 text/JSON/XML) goes as
its text, and a URL document goes as its URL, for the model to fetch with a
tool. A PDF attached to the message: see PDF input above. A PDF read by a
tool reaches the model as a note to extract its text another way; another
binary file attached to the message gets HTTP 400 saying so.
- **A reply contains "Agent execution terminated due to error."**: that is agy's
in-band error marker. The plugin reads the real cause from agy's log and ends
the turn with an error instead of passing the marker through as text. agy
Expand Down
Loading