openclaw sessions

保存済みの会話セッションを一覧表示します。

openclaw sessions
openclaw sessions --agent work
openclaw sessions --all-agents
openclaw sessions --active 120
openclaw sessions --json

スコープの選択:

  • デフォルト: 設定済みデフォルトエージェントストア
  • --agent <id>: 1つの設定済みエージェントストア
  • --all-agents: 設定済みの全エージェントストアを集約
  • --store <path>: 明示的なストアパス(--agent--all-agents との併用不可)

openclaw sessions --all-agents は設定済みのエージェントストアを読み取ります。GatewayとACPのセッション検出はより広範で、デフォルトの agents/ ルートまたはテンプレート化された session.store ルート配下で見つかったディスクのみのストアも含みます。検出されたストアはエージェントルート内の通常の sessions.json ファイルに解決される必要があり、シンボリックリンクやルート外のパスはスキップされます。

JSON例:

openclaw sessions --all-agents --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" },
    { "agentId": "work", "key": "agent:work:main", "model": "claude-opus-4-5" }
  ]
}

クリーンアップメンテナンス

次の書き込みサイクルを待たずにメンテナンスを即座に実行します:

openclaw sessions cleanup --dry-run
openclaw sessions cleanup --agent work --dry-run
openclaw sessions cleanup --all-agents --dry-run
openclaw sessions cleanup --enforce
openclaw sessions cleanup --enforce --active-key "agent:main:telegram:direct:123"
openclaw sessions cleanup --json

openclaw sessions cleanup は設定の session.maintenance 設定を使用します:

  • スコープに関する注意: openclaw sessions cleanup はセッションストア/トランスクリプトのみを管理します。cronランログ(cron/runs/<jobId>.jsonl)はプルーニングしません。cronランログは Cron configurationcron.runLog.maxBytescron.runLog.keepLines で管理され、Cron maintenance で説明されています。

  • --dry-run: 書き込みなしで、プルーニング/キャップされるエントリ数をプレビューします。

    • テキストモードでは、dry-runはセッションごとのアクションテーブル(ActionKeyAgeModelFlags)を表示し、保持対象と削除対象を確認できます。
  • --enforce: session.maintenance.modewarn の場合でもメンテナンスを適用します。

  • --active-key <key>: 特定のアクティブキーをディスクバジェットのエビクションから保護します。

  • --agent <id>: 1つの設定済みエージェントストアに対してクリーンアップを実行。

  • --all-agents: 設定済みの全エージェントストアに対してクリーンアップを実行。

  • --store <path>: 特定の sessions.json ファイルに対して実行。

  • --json: JSONサマリーを表示。--all-agents の場合、出力にはストアごとのサマリーが含まれます。

openclaw sessions cleanup --all-agents --dry-run --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
    }
  ]
}

関連ドキュメント: