# agy-fast Tool Routing & Latency Hygiene Rules Use `agy-fast_fast` MCP tools where batching amortizes the fixed per-call remote check (~1.8s) and keeps context lean, and use built-in `read_file` for allowlisted fast reads (~7ms, 46 KB inline cap per call): | Task | Preferred Tool | Reason | | :--- | :--- | :--- | | Outline unknown large files (>300 lines; prefer 10-20 files/batch, max 40: TS/JS/HTML/Vue/Svelte/CSS/Py/GDScript/Go/Rust/Java/MD/JSON/YAML) | `quick_outline({ paths: [...] })` (or `read_slices` if also piggybacking 1-2 tiny slices) | 1 call maps exact symbol/section line ranges without blind full-file dumps | | Read small files (<300 lines) OR **any** known line ranges after outlining (even 4-8 scattered ranges) | Built-in `read_file` (parallel in one turn, with `StartLine`/`EndLine` <=200 lines) | Locally allowlisted (~7ms, **0 remote check**) + **46 KB/call** inline vs MCP's 8.8 KB total cap | | Run >=2 text/regex/glob/fuzzy/read-only `git` queries (even across multiple directories/repos) | `batch_search` (pack ALL queries into **one** call via per-query `path`) | 1 remote check + concurrent local execution (<70ms), hard-capped <=8.8 KB inline | | Edit >=2 blocks in one file, edit/create/overwrite >=2 files in one turn, OR any edit + verify | `apply_edits` (`bestEffort: true` for >=3 files; optional `verify`) | Replaces N serial checks + verify turn; `bestEffort` commits valid files & returns closest-line / drifted-line hints | | Run >=2 independent non-interactive shell commands in one turn (single lightweight commands can stay on native `run_command`) | `run_checks` (`outputMode: "compact"` by default for pass/fail; `"full"` only when passing stdout is needed) | 1 remote check + concurrent execution instead of N serial `run_command` checks; avoids `full` truncation | ## Rules 1. **Direct invocation (eager-first, no schema read turn)**: When `agy-fast_fast` tools are eagerly loaded, call `mcp_agy-fast_fast_*` directly; if lazily loaded on an older host, call `call_mcp_tool` directly with `ServerName: "agy-fast_fast"` using the schemas below—do **not** spend a turn reading `mcp/agy-fast_fast/*.json` first. 2. **Outline via `quick_outline` (or `read_slices`), read code via parallel `read_file`**: On unknown files >300 lines, call `quick_outline({ paths: [...] })` first (or `read_slices({ outlines, slices })` when piggybacking 1-2 tiny <=120-line slices in the same call), then fetch needed <=200-line sections with parallel built-in `read_file(StartLine, EndLine)`. **Do NOT** use `read_slices({ slices })` to bulk-read >150 lines across multiple files (MCP output is hard-capped <=8.8 KB inline and will truncate), and **do NOT** blind-read `1-800` on large unknown files. 3. **Keep images out of long coding sessions (TTFT & cache hygiene)**: Loading `.png`/`.jpg`/`.webp` images (UI screenshots, business/voucher/receipt images, or debug captures) into a long (>150k-token) coding conversation can trigger full prompt-cache invalidation and a **3-7x TTFT cliff (40-97s/turn)**. Delegate visual inspection of any image to a subagent that returns a **text-only** list of findings (values, file paths, selectors, concrete fixes); do **not** read those images in the main coding session unless strictly unavoidable. 4. **Prevent context bloat & cache expiry**: Keep subagent reports structured and concise (no raw file dumps) and delegate noisy broad exploration to read-only subagents. For large `git diff`/`git show` in `batch_search`, run `--stat` or path-scoped diffs first. Reserve `run_checks` for `>=2` concurrent commands (keep single lightweight commands on native `run_command`, avoiding unnecessary `powershell` wrappers on Windows) and default to `outputMode: "compact"` (`"full"` hits the 8.8 KB cap frequently). In edit-verify loops, keep `apply_edits(verify)` / `run_checks` to fast targeted checks (<45s), avoid unnecessary Plan Mode toggling inside implementation loops (prefix changes invalidate prompt cache), and defer >60s full builds/suites to phase end so turn gaps stay within prompt-cache TTL; for <=10s `run_command` calls, set `WaitMsBeforeAsync` (5000-10000; prefer 10000 on Windows for 3-10s commands) instead of backgrounding early (async wakeups miss cache far more often than continuous tool loops). In multi-phase tasks exceeding ~100k-150k tokens (or ~15+ tool turns), batch aggressively and proactively suggest `/compact` or a fresh session at milestone handoffs. 5. **Apply across all directories, use `bestEffort: true` for >=3 files & circuit-break corrupted MCP args**: Use `apply_edits` and `batch_search` consistently for code, Vue/HTML/CSS, docs, scripts, and scratch folders. For `apply_edits` touching >=3 files, pass `bestEffort: true` (batches <=6-8 files) so one mismatch never rolls back valid files. If `apply_edits` reports nested-argument serialization corruption (e.g., `boolean`/`null` in `edits`, or an empty `edits` array), **do NOT retry the same payload**—immediately fall back to parallel built-in `edit_file` / `write_file`. 6. **Pack into ONE MCP call per turn, use the startup snapshot & brief swarm workers**: Combine cross-repo searches into one `batch_search`, combine edits + verify into one `apply_edits`, always pass explicit `cwd` (especially on Desktop 2.0 / Hub where MCP `roots/list` may be unavailable), read the `SessionStart` snapshot before running `ls`/`git status`, and avoid issuing 2 parallel calls to the same `agy-fast_fast` tool in one turn. When spawning swarm workers for codebase tasks (Antigravity does not mount MCP/rules/`SessionStart` into swarm workers), include exact cross-platform `--cli` commands in their brief: use parallel ranged `read_file` (<=200 lines) and invoke `node "/dist/mcp-server.mjs" --cli ...` directly (using the installed plugin path from this rule's header—do not store command+flags in one shell variable, and put per-query modifiers before their query, e.g. `node "/dist/mcp-server.mjs" --cli search --path src --text "foo" --git "status --short"`, `... --cli outline a.ts b.ts`, `... --cli edit --best-effort --stdin` with `{"edits":[...]}`, `... --cli check --compact "cmd1" "cmd2"`). ## Quick Schemas (`ServerName: "agy-fast_fast"`) > Under Antigravity eager loading, the host injects a required `toolSummary` argument into every `mcp_agy-fast_fast_*` call alongside the parameters below — include it (a short summary of what the call does) or the first call fails with `missing property 'toolSummary'`. - **`batch_search`**: `{ cwd?, queries: [{ type: "text"|"regex"|"glob"|"fuzzy"|"git", pattern, path?, glob?, fileType?, multiline?, outputMode?: "content"|"files_with_matches"|"count", sortBy?: "path"|"mtime", caseSensitive?, contextLines?: 0..5, maxResults?: 1..200 }], maxChars?: 500..8800 }` (1-20 queries; glob uses `*`/`{a,b}`, not regex `|`; `path` relative or absolute; read-only git only). - **`apply_edits`**: `{ cwd?, edits: [{ path, hunks?: [{ target, replacement, startLine?, endLine?, replaceAll? }], create?: string, overwrite?: boolean }], dryRun?, bestEffort?, verify?: string, verifyTimeoutSec?, maxVerifyChars?: 300..7500 }` (1-50 files; `create` is mutually exclusive with `hunks`; when called lazily via `call_mcp_tool`, `edits` also accepts a JSON array string—follow the SessionStart `[agy-fast compat]` notice if present). - **`quick_outline`**: `{ cwd?, paths: string[], maxChars?: 1000..8800 }` (flat outline-only schema; prefer 10-20 files/batch, max 40). - **`read_slices`**: `{ cwd?, outlines?: string[], slices?: [{ path, ranges: [[startLine, endLine], ...] }], lineRanges?: string[], maxChars?: 1000..8800 }` (prefer 10-20 outlines/batch, max 40; `lineRanges` accepts flat `"path:start-end,start2-end2"` shorthand; 1-based inclusive). - **`run_checks`**: `{ cwd?, commands: [{ name?, command, cwd?, timeoutSec? }], concurrency?: 1..8, timeoutSec?, outputMode?: "compact"|"full", maxChars?: 500..8800 }` (1-12 commands). > Tip: Add personal overrides in `rules/AGENTS.local.md` with `---\ntrigger: always_on\n---` frontmatter (gitignored and preserved across plugin updates/re-installs).