2026-01-15 06:12:54 +00:00
---
2026-01-30 03:15:10 +01:00
summary: "CLI reference for `openclaw sessions` (list stored sessions + usage)"
2026-01-15 06:12:54 +00:00
read_when:
- You want to list stored sessions and see recent activity
2026-01-31 16:04:03 -05:00
title: "sessions"
2026-01-15 06:12:54 +00:00
---
2026-01-30 03:15:10 +01:00
# `openclaw sessions`
2026-01-15 06:12:54 +00:00
List stored conversation sessions.
``` bash
2026-01-30 03:15:10 +01:00
openclaw sessions
2026-02-23 17:39:48 -05:00
openclaw sessions --agent work
openclaw sessions --all-agents
2026-01-30 03:15:10 +01:00
openclaw sessions --active 120
2026-04-04 08:28:41 +01:00
openclaw sessions --verbose
2026-01-30 03:15:10 +01:00
openclaw sessions --json
2026-01-15 06:12:54 +00:00
```
2026-02-23 17:39:48 -05:00
Scope selection:
- default: configured default agent store
2026-04-04 08:28:41 +01:00
- `--verbose` : verbose logging
2026-02-23 17:39:48 -05:00
- `--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` )
2026-03-12 16:44:46 +00:00
`openclaw 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.
2026-02-23 17:39:48 -05:00
JSON examples:
`openclaw sessions --all-agents --json` :
``` json
{
"path" : null ,
"stores" : [
{ "agentId" : "main" , "path" : "/home/user/.openclaw/agents/main/sessions/sessions.json" } ,
{ "agentId" : "work" , "path" : "/home/user/.openclaw/agents/work/sessions/sessions.json" }
] ,
"allAgents" : true ,
"count" : 2 ,
"activeMinutes" : null ,
"sessions" : [
{ "agentId" : "main" , "key" : "agent:main:main" , "model" : "gpt-5" } ,
2026-03-19 10:31:43 -07:00
{ "agentId" : "work" , "key" : "agent:work:main" , "model" : "claude-opus-4-6" }
2026-02-23 17:39:48 -05:00
]
}
```
## Cleanup maintenance
Run maintenance now (instead of waiting for the next write cycle):
``` bash
openclaw sessions cleanup --dry-run
openclaw sessions cleanup --agent work --dry-run
openclaw sessions cleanup --all-agents --dry-run
openclaw sessions cleanup --enforce
2026-03-13 01:58:33 -07:00
openclaw sessions cleanup --enforce --active-key "agent:main:telegram:direct:123"
2026-02-23 17:39:48 -05:00
openclaw sessions cleanup --json
```
`openclaw sessions cleanup` uses `session.maintenance` settings from config:
- Scope note: `openclaw 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 ](/automation/cron-jobs#configuration ) and explained in [Cron maintenance ](/automation/cron-jobs#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` .
2026-04-04 08:28:41 +01:00
- `--fix-missing` : remove entries whose transcript files are missing, even if they would not normally age/count out yet.
2026-02-23 17:39:48 -05:00
- `--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.
`openclaw sessions cleanup --all-agents --dry-run --json` :
``` json
{
"allAgents" : true ,
"mode" : "warn" ,
"dryRun" : true ,
"stores" : [
{
"agentId" : "main" ,
"storePath" : "/home/user/.openclaw/agents/main/sessions/sessions.json" ,
"beforeCount" : 120 ,
"afterCount" : 80 ,
"pruned" : 40 ,
"capped" : 0
} ,
{
"agentId" : "work" ,
"storePath" : "/home/user/.openclaw/agents/work/sessions/sessions.json" ,
"beforeCount" : 18 ,
"afterCount" : 18 ,
"pruned" : 0 ,
"capped" : 0
}
]
}
```
Related:
- Session config: [Configuration reference ](/gateway/configuration-reference#session )