Managing conversations
Section titled “Managing conversations”Resume prior development threads, scope active histories to local workspaces, fork or compact sessions, and list, clean, or compact saved conversations from the command line.
Workspace scoping
Section titled “Workspace scoping”To maintain context hygiene, Antigravity CLI scopes conversation histories directly to your current working directory. When you launch agy from a specific directory, the agent only displays and resumes sessions associated with that specific local repository or subdirectory.
This prevents context pollution, ensuring that the agent’s semantic memory and token limits remain focused solely on the relevant codebase.
Resuming sessions
Section titled “Resuming sessions”You can return to a prior conversation at any time to continue an implementation, refine a solution, or recover from an interrupted session.
Antigravity CLI supports an interactive Session Picker TUI overlay
(/resume, or aliases /switch and /conversation), direct resume by ID
(/resume <conversation-id> using a full ID or unique prefix), and command-line
flags (agy -c / agy --continue) to resume threads based on your active
workspace. In the picker, press Ctrl + F to toggle between
a flat list and workspace-grouped view (or set pickerGrouping in /config).
For a complete walkthrough of the interactive picker, workspace grouping, keyboard shortcuts, and how the directory-scoped session cache works, refer to the dedicated Resume command guide.
Branching with /fork
Section titled “Branching with /fork”When engineering a complex feature, you might want to explore multiple design
alternatives without losing your progress. The /fork command enables safe,
parallel experimentation in the current workspace or across projects.
Run /fork with no arguments to branch in your current project, or pass a
configured project_id to fork into another project:
/fork
/fork <project_id>
(Alias: /branch)
The /fork command clones your entire conversation history up to the current
turn into a new, independent session and prints a /resume <conversation-id>
command so you can jump back to the original thread at any time.
Forking workflow
Section titled “Forking workflow”To fork an active conversation into a new branch, follow these steps:
- Type
/fork(or/fork <project_id>to target another configured project) inside the prompt panel and press Enter. - The CLI allocates a new unique session ID and copies the conversation history
and context up to that point while keeping the existing workspace. When you
specify a
<project_id>, the CLI loads~/.gemini/config/projects/<project_id>.json, attaches the forked conversation to that project, and syncs its local resource directories into your active session (refer to Projects for project configuration details). - Your active terminal switches immediately to the new branch and prints the
/resume <conversation-id>command for your original thread. - If the experiment fails, run the printed
/resume <conversation-id>command or open/resumeto restore your original, stable conversation branch.
Rewinding a conversation with /rewind
Section titled “Rewinding a conversation with /rewind”To undo a wrong turn in place instead of branching into a second conversation,
run /rewind (alias /undo) to roll the conversation history back to an
earlier message:
/rewind
Use ↑/↓ to choose a message in the rewind panel and press Enter. The CLI rewinds the conversation to the point just before that message, which removes the message and everything after it, and places the message text back in the prompt so you can edit and resend it.
Compacting long sessions with /compact
Section titled “Compacting long sessions with /compact”When a long session accumulates large search outputs or completed milestones, run /compact to summarize the conversation so far into a checkpoint without starting over:
/compact
You can also pass instructions after /compact (for example, /compact Now add unit tests for the new handler) to compact first and immediately continue working on the compacted context. Run /context afterward to inspect your updated token breakdown.
Listing, cleaning, and compacting saved conversations
Section titled “Listing, cleaning, and compacting saved conversations”Use the agy conversations subcommand from your shell to check how much disk space saved conversations use, safely remove old or oversized sessions, or shrink large idle conversation databases without launching the interactive TUI.
agy conversations <subcommand> [flags] [args]
Run agy conversations --help (or agy conversations <subcommand> --help) to print available subcommands (list, clean, compact) and flags.
Listing saved conversations
Section titled “Listing saved conversations”Run agy conversations list to inspect your saved conversations, their on-disk footprint, and whether any are currently open in another session:
# List the 20 largest saved conversations (default)
agy conversations list
# Sort by oldest first and show up to 50 rows
agy conversations list --sort age --limit 50
# Show all saved conversations without truncation
agy conversations list --limit 0
| Flag | Default | Description |
|---|---|---|
--sort | size | Sort order: size (largest first, with ties broken by most recently modified) or age (oldest first). |
--limit | 20 | Maximum number of conversations to display. Pass 0 to show all saved conversations. |
Example output:
Saved conversations: 3 (total 117.1 MB)
ID SIZE MODIFIED STATUS TITLE
3c587aa5-f234-4b1e-9d04-3a1f8c2b9e41 81.3 MB 2026-11-20 14:30 idle (untitled)
0f6f107f-c720-4c9a-8e12-7d4b1f9a2c08 21.6 MB 2026-11-20 14:32 idle API cleanup
9b2a4c11-e081-4f3d-a516-2e8c4b7d1a93 14.2 MB 2026-11-27 09:15 active Fix cache miss
Each row reports the full conversation ID (which you can pass directly to agy -r <id> or agy --conversation <id>), total on-disk SIZE (including database write-ahead log files), last MODIFIED timestamp, STATUS (active if open in another Antigravity CLI or Antigravity App process, otherwise idle), and TITLE (conversation title, first prompt preview, or (untitled)). If pre-compact backups exist from agy conversations compact, list also prints the total backup count, size, directory, and undo/delete commands. agy conversations list is strictly read-only and does not modify conversation files or timestamps.
Cleaning saved conversations
Section titled “Cleaning saved conversations”Run agy conversations clean to delete saved conversations by age, recency, disk size, or explicit conversation ID:
# Preview conversations older than 30 days without modifying disk
agy conversations clean --older-than 30d --dry-run
# Delete conversations older than 30 days while keeping the 10 most recent
agy conversations clean --older-than 30d --keep-recent 10
# Preview conversation trees using at least 100MB on disk
agy conversations clean --min-size 100MB --dry-run
# Delete specific conversations by full ID or unambiguous prefix
agy conversations clean 0f6f107f-c720-4c9a-8e12-7d4b1f9a2c08
# Delete non-interactively in a script
agy conversations clean --older-than 30d --yes
Pass at least one rule filter (--older-than, --keep-recent, --min-size) or one or more conversation IDs. You cannot combine explicit conversation IDs with rule filters in the same command.
| Flag / Argument | Default | Description |
|---|---|---|
--older-than <duration> | — | Match conversations older than the specified duration (for example, 30d, 2w, 24h). Supports d (days), w (weeks), and standard duration units (h, m, s). Evaluated against the latest modification time across a main conversation and its subagents. |
--keep-recent <N> | 0 | Always keep the <N> most recently modified main conversations (and their subagents), even if they match other filters. |
--min-size <size> | — | Match conversations whose combined on-disk footprint is at least this size (for example, 50MB, 500KB, 1GB, 1.5GB; supports B, KB/KiB, MB/MiB, GB/GiB in base-1024 units). Evaluated against the total size of a main conversation and all of its descendant subagents. |
[id...] | — | One or more full conversation IDs (from agy conversations list) or unambiguous ID prefixes. If a prefix matches multiple conversations, pass a longer prefix. Cannot be combined with rule filters. |
--dry-run | false | Preview matched conversations and active skips without deleting or modifying any files on disk. |
--yes, -y | false | Skip the interactive [y/N] confirmation prompt. Required when running non-interactive commands unless --dry-run is set. |
Subagent tree preview
Section titled “Subagent tree preview”Rule filters (--older-than, --keep-recent, and --min-size) evaluate each main conversation together with all of its descendant subagents as a single subtree. Before deleting—or when you pass --dry-run—the CLI prints a tree showing each matched main conversation and its nested subagents:
Matched 1 main conversation(s) and 2 subagent(s) to delete (178.8 MB on disk):
ID SIZE MODIFIED ROLE TITLE
0f6f107f-c720-4c9a-8e12-7d4b1f9a2c08 21.6 MB 2026-11-08 main API cleanup (178.8 MB with subagents)
├─ 3c587aa5-f234-4b1e-9d04-3a1f8c2b9e41 81.3 MB 2026-11-08 subagent (untitled)
└─ 0cdbb2e3-0341-4a7b-9c21-6f5e8d1a4b29 75.9 MB 2026-11-08 subagent (untitled)
Dry run only; no changes made.
Each row shows its own disk size, while the main row also displays the combined subtree total when subagents are present. Subtrees are removed bottom-up (subagents before their parent conversation) so an interrupted deletion does not leave orphaned subagent sessions.
Compacting saved conversations
Section titled “Compacting saved conversations”Run agy conversations compact to shrink large idle conversation databases on disk without deleting your conversation history. Unlike /compact (which summarizes your prompt context inside a live session), agy conversations compact deduplicates repeated metadata and reclaims free database pages offline while keeping your original files as restorable backups.
# Preview idle conversations >= 10 MB eligible for compaction
agy conversations compact --dry-run
# Compact eligible idle conversations (keeps originals as backups)
agy conversations compact
# Compact specific conversations by full ID or unambiguous prefix
agy conversations compact 0f6f107f-c720-4c9a-8e12-7d4b1f9a2c08
# Restore a conversation from its pre-compact backup
agy conversations compact --undo 0f6f107f-c720-4c9a-8e12-7d4b1f9a2c08
# Delete all pre-compact backups to permanently free disk space
agy conversations compact --delete-backups
# Delete a specific backup non-interactively
agy conversations compact --delete-backups 0f6f107f-c720-4c9a-8e12-7d4b1f9a2c08 --yes
When you run agy conversations compact without conversation IDs, it selects all idle SQLite conversations that are at least 10 MB on disk, have not been modified in the last 10 minutes, are not open in another process, and do not already have a pre-compact backup. When you pass explicit [id...] arguments, the 10 MB size threshold is ignored while the idle, active-session, and existing-backup checks still apply.
| Flag / Argument | Default | Description |
|---|---|---|
[id...] | — | Optional full conversation IDs or unambiguous prefixes. For compaction, targets only these conversations (ignoring the 10 MB threshold). Required with --undo; optional with --delete-backups (omit to delete all backups). |
--dry-run | false | Preview matched conversations or backups without modifying disk. |
--undo | false | Restore the specified conversation IDs from their pre-compact backups. Mutually exclusive with --delete-backups. |
--delete- | false | Permanently delete pre-compact backups (all backups, or only the specified IDs) so disk space is freed. Once deleted, compaction cannot be undone. Mutually exclusive with --undo. |
--yes, -y | false | Skip the interactive [y/N] confirmation prompt. Required when running non-interactive commands unless --dry-run is set. |
Compaction never edits the original database in place. It writes a deduplicated, vacuumed copy first, skips any conversation whose compacted copy is not smaller or whose source file changed mid-run, preserves the original modification timestamp, swaps the compacted file in, and moves the original into conversations_precompact/ inside your app data directory. After compacting, the CLI prints the before/after sizes and the commands to undo or delete backups.
Safety guarantees
Section titled “Safety guarantees”- Active and recent session protection: Both
cleanandcompactskip conversations currently open in another Antigravity CLI or Antigravity App process (forclean, an active member anywhere in a main/subagent tree skips the entire subtree).compactalso skips conversations modified within the last 10 minutes and skips any conversation that already has a pre-compact backup so the true original is never overwritten. - Reversible compaction:
compactkeeps each original database inconversations_precompact/until you verify your conversations and runagy conversations compact --delete-backups. Deleting a conversation withcleanalso removes its pre-compact backup. - Artifacts preserved: Cleaning or compacting a conversation keeps user-facing artifact files (such as implementation plans and walkthroughs) intact.
- Explicit confirmation: Interactive terminals prompt
[y/N]before deleting, compacting, restoring, or removing backups. Non-interactive shells (such as piped commands or CI jobs) refuse to modify files unless you pass--yes(-y) or--dry-run.
Next steps
Section titled “Next steps”Explore how the agent handles complex, asynchronous operations and parallel tasks:
- Background tasks and subagents: Monitor subagents and handle fast-path approvals.
- Settings, rendering, and keybindings: Configure rendering buffers and override JSON preferences.
- Permissions and sandbox: Manage security profiles and system command lists.