--- name: agy-cli description: Directly invocable Auto Office v3 Agy CLI mechanics primitive. Use when a selected/explicit Agy harness dispatch needs exact launch flag ordering, dynamic model discovery, model-dependent effort handling, workspace pinning, timeout/quota-stall diagnosis, prompt transport, recovery, or Agy-specific failure attribution. Do not treat this primitive as a separate lifecycle office or proof of adapter promotion. --- # Agy CLI primitive Load `../../adapters/seed/agy.yaml` plus current local override. New routes start `neutral` for every role (#837); inspect shipped allow/deny defaults with `office route policy --effective --role `. ```bash agy --dangerously-skip-permissions --print-timeout 45m \ --model "" --add-dir "" \ --prompt="$(cat )" ``` - `--print-timeout 45m` — defaults to 5m; always raise it or the run dies mid-task. - Plan review (H4, #1178; H5; code review left Hydrogen, Rico 2026-11-19; as executor Hydrogen runs XS low, S medium, M high only, none for L or XL, per the AA v5 Engineering Index table): the adapter's `reviewer` profile launches `agy --mode plan --print-timeout 30m --model gemini-4-hydrogen-high --add-dir [--add-dir ] --print=`, read-only plan mode with no permission bypass. Its `routes: [gemini-4-hydrogen-high@high]` scope means no other agy model has a reviewer launch form. agy has no verified sandbox, so Office fingerprints the worktree before and after the review and fails it if anything changed. Hydrogen still needs the user's exact allow for that role (`plan_reviewer`) and a fresh exact probe; a manual `--review-as` does not replace the allow. A plan review runs in the run's repo root, so an edit there during the review fails the fingerprint check and the gate falls back. In Herdr the reviewer opens a pane like the worker (#1027), and the pane hosts the same headless `--mode plan --print` run (`interactive.supervisor`): Office captures its stdout as the reply, so no permission setting is relied on (agy's `--settings` allow rules are undocumented) and the headless `--print` run raises no feedback survey. No permission bypass, `--mode auto` or `accept-edits` is passed anywhere. Without Herdr, or when no pane opens, the headless form above runs. The worktree check covers both. A stalled pane ends at the profile's `max_minutes` (`wall_cap`) as a reported no-verdict result. After the reinstall, rerun `office doctor --probe-route agy/gemini-4-hydrogen@high`: the adapter hash changed. - Visual review (Rico 2026-11-19): the `vision` profile launches `agy --mode plan --print-timeout 30m --model [--add-dir ] --prompt=` in the run's private evidence directory, read-only plan mode with no permission bypass, and its pane hosts the headless run (`interactive.supervisor`) so stdout is the reply. Hydrogen reads prompt-path images in plan mode (agy 1.5.12). Gemini 3.8 Flash is retired in every role (Rico 2026-11-19): a shipped deny; Gemini 4 Hydrogen supersedes it. Hydrogen reviews visuals under the same gates as plan review: the user's exact `visual_reviewer` allow of `agy@1/gemini-4-hydrogen@low` plus a fresh exact probe. After a reinstall, rerun `office doctor --probe-vision`: the adapter hash changed. - `--model` — resolve from local `agy models` at dispatch; agy publishes no `latest` alias, so a hardcoded slug is pinned to the day it was written. **For a Claude/gpt-oss model routed through agy, pass the display name from the second column, not the slug from the first.** Verified 2026-09-12 on agy 1.2.2: `--model claude-sonnet-4-6` (the slug) is accepted without error and silently falls back to the account default; `--model "Claude Sonnet 4.6 (Thinking)"` selects correctly. There is no unknown-model error, so the only way to catch this is to read the startup banner's model line before prompting — treat a banner mismatch as adapter invocation failure and restart rather than prompting the wrong route. - Cataloged Claude routes: `agy/claude-sonnet-5-5` and `agy/claude-opus-5-5` at `low`, `medium`, and `high`. Their catalog `invocation_model_id` is the exact display name reported by `agy models` (for example, `Claude Sonnet 5.5 (Medium)`); pass it verbatim as one `--model` argument. On 2026-10-21, Agy 1.4.3 startup banners named the exact requested display name for Sonnet at all three efforts and Opus at medium and high. Those five rows are dispatchable but still subject to normal trust and quota gates. `claude-opus-5-5@low` never showed its banner and stays gated until a banner names `Claude Opus 5.5 (Low)`. For a **native Gemini** model, the opposite convention verified correct: pass the exact combined model+effort slug from `agy models`' first column as a single `--model` value (e.g. `--model gemini-3.8-flash-medium`), with **no separate `--effort` flag**. Verified 2026-09-19 on agy 1.2.7: this launched correctly (banner confirmed "Gemini 3.8 Flash · medium") and the session went on to correctly complete real work. Splitting it into `--model gemini-3.8-flash --effort medium` is the claude/codex convention and is a strong suspect for why earlier Gemini rows were marked `dispatchable: false` under routing defect 3fe80434 — that defect's own original evidence, though, was a Claude-routed model, so treat the fix as verified per-slug (see `catalog/seed.yaml`'s per-row notes), not as a blanket rule across every Gemini row yet. - **Prefer `--prompt=` (the `=` form) over `--print `.** `--print` must be the last flag immediately before the prompt or the prompt is silently swallowed and you get a greeting/banner back with exit 0 — that is invocation failure, not a routing signal; nothing was done. The `=` form binds the value to the flag and makes ordering irrelevant. - **Stdin piping does not work.** The prompt must be bound to `--print`/`--prompt=`, never piped. - `--add-dir` does not reliably select the workspace by itself — pin the absolute workspace root (and forbid the scratch dir) in the prompt text itself. - `--effort low|medium|high` is **Gemini-only**. Passing it with a Claude or gpt-oss slug hard-fails the launch (`--effort is not supported for model ""`). Probe the model's effort support before assuming a house effort tier applies; if the slug doesn't support it, say so rather than substituting a tier. - After a start call returns, confirm the prompt actually landed before counting the task as in flight. Observed 2026-09-14: a prompt sent immediately after `agent start` returned did not land at all — agy's readiness semantics differ from codex's, and its reported `idle` does not mean "ready for input" the way codex's does. The receipt is an observed transition to `working` plus real output appearing in the pane, never the start call's return value. ## Liveness — do not trust agy's reported status alone Observed 2026-09-14: after a re-prompt, `herdr agent get wf` reported `idle` while the pane simultaneously showed `Searching...` and `esc to cancel` — the agent was demonstrably working. For agy, the harness status field is not a liveness signal. Reading `idle` proves nothing — not readiness, not completion, not death. The receipt is the pane content, never the status field. An orchestrator that polls agy status alone will both dispatch into a busy agent (believing it idle) and declare a working agent finished (believing it done). This is the agy analogue of `pgrep -f "codex exec"` matching the wrapper shell instead of the process — a green status reading is not proof of the state it claims. Recurred 2026-09-23 on 1.2.9 during `Running command...`, where a status-keyed monitor fired a false "finished without report." Monitor finish rule for agy: done = the brief's delivery artifact exists; stopped-without-delivering = status `idle`/`done`/`unknown` AND no `esc to cancel` in `herdr agent read --source visible --lines 6`, sustained for about 2 minutes of consecutive polls (the busy marker reappearing resets the count), then inspect the pane and `git status --porcelain` before re-prompting or closing; `blocked` exits immediately. ## Quota and recovery Probe before dispatch: `python3 ../../scripts/agy-usage.py --json` (bare for human-readable, `--percent` for the legacy Gemini-only number). The JSON result reports independent `families.gemini` and `families.claude` values. Exit `2` means unknown, not low. Full contract in `../../references/quota-probe.md`. `families.gemini` and `families.claude` come from `v1internal:retrieveUserQuotaSummary` (empty JSON body, same OAuth token): the account view agy's status line shows, per model group ("Gemini Models", "Claude and GPT models") with a `5h` and a `weekly` window. A family's number is its tightest window. How it was found (2026-10-21, agy 1.4.3): the binary carries `RetrieveUserQuotaSummary`/`QuotaSummaryBucket` symbols, and `~/.gemini/antigravity-cli/log` (`quota_manager.go`) records the failed POST with the full URL; `agy --log-file` on a launch shows `doRefreshQuota`. `v1internal:retrieveUserQuota` is the fallback: when the summary call fails, families are derived from its per-model buckets (no window labels, one reset per bucket), and `family_source` in the JSON says which was used. Claude buckets never change the Gemini number or the reverse. The legacy top-level `tightest_remaining_percent` (and `--percent`) is always the Gemini family result (`--all`/`--claude` only widen the model listing); when that family has no readable number it is `null` with a `cause` (and `--percent` exits 2), never a default 100. Routing applies each family's number to that family's candidates by model id; a probe without `families` applies harness-wide. Since 2026-11-23 (#1339, agy 1.5.14) the script queries the `daily-cloudcode-pa.googleapis.com` host agy itself talks to and falls back to `cloudcode-pa.googleapis.com` only when it fails; `api_host` names the host used. For the same account the production host returned idle 100% windows and no `gemini-4` bucket while agy showed the Gemini weekly window at 0.4%. The daily summary returns only the Claude group, so `families.gemini` comes from the per-model buckets there. `families.gemini-4` is the tightest `gemini-4*` bucket (Hydrogen); when none is reported it reads 0% with `exhausted_by: unreported`, and routing gates agy `gemini-4*` candidates on it rather than on `families.gemini`. A stall after a few narration lines with nothing in `git status`/`git log` is quota, not slowness — confirm before believing an external cause. - Clarifying-question stall or focused correction: `agy --continue` or `--conversation `, same flag-ordering rules apply. - Greeting/swallowed prompt: fix the flag form (prefer `--prompt=`) and relaunch; nothing was done. - Quota stall: relaunch fresh or fall back to another brand for the remainder. - **Feedback-survey stall:** agy interrupts a turn with an interactive survey ("How's the CLI experience so far? [1] Good [2] Fine [3] Bad [0] Skip"). Observed 2026-09-12 on 1.2.2: it appears mid-turn, the agent stops having written nothing, and the harness reports `done` rather than `blocked` (or cycles `idle`/`working`), so a status poll reads as success. Dismiss the survey specifically with `send-keys 0` (Skip), then re-prompt explicitly ("nothing was written, resume from where you left off") — dismissing the modal does not restore the task, the agent has lost it and needs the full re-prompt, it does not resume on its own. Confirm progress against the worktree with `git status --porcelain`, never against the reported status. Launch as a background task with no pipes on stdout (never `tail`/`head` — both buffer until exit and defeat live tailing); read only the tail of the output file after completion. Never edit the tree it is writing to while it runs. Diagnose a greeting/swallowed prompt or a banner model mismatch as adapter invocation failure, an `--effort` hard-fail as adapter/invocation, a status field that disagrees with the pane (idle-while-working, or a survey stall unreported as blocked) as adapter false-positive/false-negative liveness, and narration-with-no-work under exhausted allowance as quota/account when evidence confirms it.