> ## Documentation Index
> Fetch the complete documentation index at: https://agdiai-597e782f.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# sessions

# `agdi sessions`

List stored conversation sessions.

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
agdi sessions
agdi sessions --agent work
agdi sessions --all-agents
agdi sessions --active 120
agdi sessions --json
```

Scope selection:

* default: configured default agent store
* `--agent <id>`: one configured agent store
* `--all-agents`: aggregate all configured agent stores
* `--store <path>`: explicit store path (cannot be combined with `--agent` or `--all-agents`)

`agdi sessions --all-agents` reads configured agent stores. Gateway and ACP
session discovery are broader: they also include disk-only stores found under
the default `agents/` root or a templated `session.store` root. Those
discovered stores must resolve to regular `sessions.json` files inside the
agent root; symlinks and out-of-root paths are skipped.

JSON examples:

`agdi sessions --all-agents --json`:

```json theme={"theme":{"light":"min-light","dark":"min-dark"}}
{
  "path": null,
  "stores": [
    { "agentId": "main", "path": "/home/user/.agdi/agents/main/sessions/sessions.json" },
    { "agentId": "work", "path": "/home/user/.agdi/agents/work/sessions/sessions.json" }
  ],
  "allAgents": true,
  "count": 2,
  "activeMinutes": null,
  "sessions": [
    { "agentId": "main", "key": "agent:main:main", "model": "gpt-5" },
    { "agentId": "work", "key": "agent:work:main", "model": "claude-opus-4-6" }
  ]
}
```

## Cleanup maintenance

Run maintenance now (instead of waiting for the next write cycle):

```bash theme={"theme":{"light":"min-light","dark":"min-dark"}}
agdi sessions cleanup --dry-run
agdi sessions cleanup --agent work --dry-run
agdi sessions cleanup --all-agents --dry-run
agdi sessions cleanup --enforce
agdi sessions cleanup --enforce --active-key "agent:main:telegram:direct:123"
agdi sessions cleanup --json
```

`agdi sessions cleanup` uses `session.maintenance` settings from config:

* Scope note: `agdi sessions cleanup` maintains session stores/transcripts only. It does not prune cron run logs (`cron/runs/<jobId>.jsonl`), which are managed by `cron.runLog.maxBytes` and `cron.runLog.keepLines` in [Cron configuration](https://agdiai-597e782f.mintlify.site/automation/cron-jobs.md#configuration) and explained in [Cron maintenance](https://agdiai-597e782f.mintlify.site/automation/cron-jobs.md#maintenance).

* `--dry-run`: preview how many entries would be pruned/capped without writing.
  * In text mode, dry-run prints a per-session action table (`Action`, `Key`, `Age`, `Model`, `Flags`) so you can see what would be kept vs removed.

* `--enforce`: apply maintenance even when `session.maintenance.mode` is `warn`.

* `--active-key <key>`: protect a specific active key from disk-budget eviction.

* `--agent <id>`: run cleanup for one configured agent store.

* `--all-agents`: run cleanup for all configured agent stores.

* `--store <path>`: run against a specific `sessions.json` file.

* `--json`: print a JSON summary. With `--all-agents`, output includes one summary per store.

`agdi sessions cleanup --all-agents --dry-run --json`:

```json theme={"theme":{"light":"min-light","dark":"min-dark"}}
{
  "allAgents": true,
  "mode": "warn",
  "dryRun": true,
  "stores": [
    {
      "agentId": "main",
      "storePath": "/home/user/.agdi/agents/main/sessions/sessions.json",
      "beforeCount": 120,
      "afterCount": 80,
      "pruned": 40,
      "capped": 0
    },
    {
      "agentId": "work",
      "storePath": "/home/user/.agdi/agents/work/sessions/sessions.json",
      "beforeCount": 18,
      "afterCount": 18,
      "pruned": 0,
      "capped": 0
    }
  ]
}
```

Related:

* Session config: [Configuration reference](https://agdiai-597e782f.mintlify.site/gateway/configuration-reference.md#session)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.