[Feature Request] Native programmatic context compaction trigger in Lifecycle Hooks (hooks.json) & Plugin/Sidecar API

Aperta
#30,413 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
15/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
json, python, typescript
Ambito
cli, tooling

Direzione di ricerca

This is a design request, not a scoped edit: read how hooks.json lifecycle hooks (PreInvocation, PostInvocation, Stop) currently emit systemMessage, userMessage, errorMessage and terminationBehavior, and compare with the Python SDK's CompactionConfig(token_threshold=...) on LocalAgentConfig. Then trace where the interactive /compact slash command reaches the host CHECKPOINT compaction engine, so a hook-level or Sidecar RPC trigger could reuse that path. Done means a maintainer has picked one of the three proposals and written down the config/RPC surface; the issue itself only sketches options and no code location is named.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status/need-triage
Summary

In the Antigravity Python SDK, developers can configure automatic context compaction thresholds programmatically via CompactionConfig(token_threshold=...) on LocalAgentConfig.

However, in Antigravity Desktop (Antigravity 2.0), CLI, and the Customization / Plugin ecosystem (hooks.json, Sidecars, MCP Apps):

  1. /compact is strictly a frontend UI slash command intercepted by the interactive input prompt.
  2. Lifecycle hooks (PreInvocation, PostInvocation, Stop in hooks.json) can only inject systemMessage, userMessage, or errorMessage steps, or set terminationBehavior ("terminate" | "force_continue"). Injecting {"userMessage": "/compact"} passes the literal string "/compact" to the model instead of invoking the host compaction (CHECKPOINT) engine.
  3. There is no user/workspace setting or sanctioned Sidecar / LanguageServer RPC to configure per-model compaction thresholds or trigger background compaction for a conversationId without UI interaction.
Real-World Motivation & Current Workaround

We built an open-source native Antigravity plugin — Context & Cache Monitor (antigravity-context-monitor) — combining a Left-Sidebar MCP App, a Sidecar dashboard, and a PreInvocation hook to observe Gemini context occupancy, prefix cache hit rates, and CHECKPOINT compactions.

Because prefix cache drops and cold recomputations frequently happen before the built-in default CHECKPOINT ceiling is reached, users want dynamic per-model compaction thresholds (e.g., compacting cleanly at ~180K–210K tokens once a turn becomes idle).

Today, the only way for a plugin to execute /compact automatically is to wait for the session and OS keyboard/mouse input to go idle and dispatch /compact via OS window automation, which requires foreground window focus.

Proposed Solutions (Any or All)
1. Lifecycle Hook Compaction Action (hooks.json)

Allow PreInvocation, PostInvocation, or especially the Stop hook (when fullyIdle: true and terminationReason: "NO_TOOL_CALL") to request an internal host compaction cleanly between turns:

{
  "decision": "allow",
  "compactionBehavior": "compact"
}

(or "terminationBehavior": "compact_and_continue" in PreInvocation / PostInvocation)

This would let a lightweight hooks.json script trigger a native CHECKPOINT compaction 100% silently in the background without touching the UI or stealing window focus.

2. Expose compactionConfig.tokenThreshold in Desktop / CLI Settings

Mirror the Python SDK's CompactionConfig(token_threshold=...) in user/workspace configuration (with optional per-model overrides), so users can tune when native CHECKPOINT compaction fires.

3. Sanctioned Sidecar SDK / Local RPC Method

Expose a documented method (e.g., CompactConversation({ conversationId })) in the Sidecar SDK / local LanguageServer service so authorized plugins and MCP Apps can trigger background compaction for an idle conversation directly.

Lingua principale
TypeScript
Stelle
109k
Fork
15k
Merge medio
1g 24m
PR unite (30g)
91

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google-gemini/gemini-cli

Tutte le issue di google-gemini/gemini-cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.