Environment
google-antigravity SDK v0.1.3
- Python 3.14
- macOS
Problem
The SDK supports automatic context compaction via CapabilitiesConfig.compaction_threshold, but there is no way to trigger compaction on-demand from Python code. The Go harness handles all compaction internally — the Python SDK only receives an OnCompactionHook notification after it happens.
For interactive IDE integrations (ACP agents), users expect a /compact command (like Claude Code's) to proactively compress context before hitting limits. Currently we can only tell users "compaction is automatic."
Current state
What works:
CapabilitiesConfig(compaction_threshold=50000) — sets when automatic compaction fires
OnCompactionHook — observability hook dispatched after compaction occurs
conversation.compaction_indices — tracks where compaction happened in history
- Full history preserved in Python SDK for transcript purposes
What's missing:
- No API to trigger compaction on-demand — e.g.,
conversation.request_compaction() or agent.compact()
ActionCompaction proto is empty — no metadata about what was compacted (token count before/after, which turns were summarized)
- No way to control compaction strategy — can't choose summarize vs. prune, or specify which turns to retain
Use case
Building an ACP agent adapter for JetBrains IDEs. Users expect:
/compact command to proactively compress context when they notice the conversation getting long
- Visibility into what was compacted (token savings)
- Control over when compaction happens (not just when threshold is hit)
The Gemini CLI has compressionThreshold in settings.json. Claude Code has /compact which summarizes earlier messages. The SDK's compaction_threshold is the config equivalent, but lacks the interactive trigger.
Proposed API
# Option 1: Method on Agent
await agent.compact() # triggers immediate context compaction
# Option 2: Method on Conversation
conversation.request_compaction()
# Option 3: Config-level (less useful for on-demand)
CapabilitiesConfig(compaction_threshold=0) # compact on next turn
Enriched OnCompactionHook data would also help:
class CompactionData:
tokens_before: int
tokens_after: int
turns_compacted: int
Workaround
Currently the only option is to rebuild the agent (losing conversation context entirely), or to set a very low compaction_threshold so compaction fires frequently. Neither provides the user-controlled "compact now" experience.
References
Environment
google-antigravitySDK v0.1.3Problem
The SDK supports automatic context compaction via
CapabilitiesConfig.compaction_threshold, but there is no way to trigger compaction on-demand from Python code. The Go harness handles all compaction internally — the Python SDK only receives anOnCompactionHooknotification after it happens.For interactive IDE integrations (ACP agents), users expect a
/compactcommand (like Claude Code's) to proactively compress context before hitting limits. Currently we can only tell users "compaction is automatic."Current state
What works:
CapabilitiesConfig(compaction_threshold=50000)— sets when automatic compaction firesOnCompactionHook— observability hook dispatched after compaction occursconversation.compaction_indices— tracks where compaction happened in historyWhat's missing:
conversation.request_compaction()oragent.compact()ActionCompactionproto is empty — no metadata about what was compacted (token count before/after, which turns were summarized)Use case
Building an ACP agent adapter for JetBrains IDEs. Users expect:
/compactcommand to proactively compress context when they notice the conversation getting longThe Gemini CLI has
compressionThresholdinsettings.json. Claude Code has/compactwhich summarizes earlier messages. The SDK'scompaction_thresholdis the config equivalent, but lacks the interactive trigger.Proposed API
Enriched
OnCompactionHookdata would also help:Workaround
Currently the only option is to rebuild the agent (losing conversation context entirely), or to set a very low
compaction_thresholdso compaction fires frequently. Neither provides the user-controlled "compact now" experience.References
compressionThresholdsetting/compactcommandCapabilitiesConfig.compaction_threshold(types.py line 372)OnCompactionHook(hooks.py line 230)ActionCompactionproto (empty message, no metadata)