← Plugins

AGY Auto Compact

tangxingpeng8installs

Automatically compacts Antigravity (AGY) context at a configurable token threshold with mid-turn brake-and-resume and end-of-turn fallback.

$ paseo plugin add edynasty/agy-auto-compact
AGY Auto Compact screenshot 1

Automatically compacts Antigravity (AGY) sessions inside Paseo when context usage crosses a configurable token threshold, with safe mid-turn braking and automatic task resumption.

What it does

  • Adds a composer threshold picker on Antigravity sessions to switch presets (128K, 200K, 250K, 272K, 400K, 512K) or pause auto-compact without leaving the chat.
  • Adds a Context limits settings screen (also reachable from the Command Center) for custom thresholds (50K to 1M), trigger strategies, anti-loop cooldown, and custom /compact prompts.
  • Uses 272K tokens as the default recommended threshold to preserve reasoning quality and response speed before long-context degradation sets in, rather than waiting for AGY's default near-1M compaction threshold.
  • Supports English (en) and Simplified Chinese (zh-CN) interface translations that follow Paseo's app language.

How it works

Antigravity CLI's built-in auto-compaction triggers near the end of its 1M context window. This plugin coordinates two lightweight hooks so compaction happens earlier and cleanly without interrupting active tool calls:

  1. Mid-turn brake (PreInvocation hook in AGY): Before each subsequent model call inside a turn (invocationNum >= 1), the bundled script scripts/agy-pre-invocation-brake.mjs inspects the tail (up to 256 KB) of the active AGY session transcript. It reads the latest PLANNER_RESPONSE token count (input_tokens + cache_read_tokens + output_tokens). When usage reaches the configured threshold inside a Paseo-managed foreground AGY session (PASEO_AGENT_ID set), the script writes a brake marker under ~/.paseo/plugin-data/paseo-agy-auto-compact/brakes/ and returns terminationBehavior: "terminate" so AGY stops cleanly between steps. Standalone terminal or Desktop AGY sessions without PASEO_AGENT_ID are never affected.
  2. Automatic /compact and resume (agent.turn.after hook in Paseo): When the stopped turn finishes and the agent becomes idle, Paseo's daemon hook detects the matching brake marker, sends /compact <resume prompt> using activeTurnBehavior: "queue" and a deterministic messageId (retrying once on transient send error), records cooldown, and clears the marker. AGY compresses the conversation and immediately resumes the remaining work.
  3. End-of-turn fallback and safeguards: If a normal turn finishes above the threshold without triggering a mid-turn brake (and was not already a /compact turn), Paseo sends /compact (plus the optional end-of-turn prompt) to free context for the next turn. A per-session cooldown (default 90 seconds) prevents compaction loops. Disabling or stopping the plugin removes the brake-hook-active marker file so the external AGY hook immediately stops braking until the plugin runs again.

Setup

  • Requires Antigravity CLI (agy) configured as a provider in Paseo, Node.js on the daemon host, and Paseo 0.18.2 or later (macOS, Linux, or Windows).
  • End-of-turn compaction works immediately after installation.
  • To enable mid-turn braking, open Settings > Plugins > AGY Auto Compact > Context limits and click Install hook. With your click, the plugin copies scripts/agy-pre-invocation-brake.mjs into ~/.paseo/plugin-data/paseo-agy-auto-compact/ and registers a paseo-agy-auto-compact PreInvocation command entry in ~/.gemini/config/hooks.json (or $ANTIGRAVITY_GEMINI_DIR/config/hooks.json). Nothing is written to hooks.json unless you click Install hook.

Settings, data access, and limits

  • Settings: Enable/disable switch, threshold presets and custom input (50K to 1M), mid-turn brake toggle, end-of-turn fallback toggle, anti-loop cooldown (30s to 5m), mid-turn resume prompt, and optional end-of-turn prompt.
  • Local files read and written: Reads the tail of the active AGY transcript file during PreInvocation. Stores synchronized settings, active-state marker, brake markers, cooldown state, agent background flags, and hook logs under ~/.paseo/plugin-data/paseo-agy-auto-compact/. Reads ~/.gemini/config/hooks.json to detect installation status and updates it only when you click Install hook.
  • Data sent to providers: Sends /compact and your configured compact prompt text to your Antigravity session through Paseo's daemon API. The plugin makes no external network requests and collects no telemetry.
  • Limits: Mid-turn braking skips background Paseo subagents by default to avoid premature completion signals. On repeated send failures (after one automatic retry), the brake marker remains on disk and you can resume the session manually.

Related plugins

Browse all plugins →