Skip to content

Feature: command to bulk-delete closed sessions #206

@whtoo

Description

@whtoo

Problem

Currently, acpx kimi sessions close <name> only marks a session as `[closed]` in the sessions list but does not delete the session files from `~/.acpx/sessions/`. Over time this leads to:

  • Hundreds of orphaned session files accumulating on disk (in our case: 190 closed sessions = ~2.4GB)
  • The sessions list shows a cluttered mix of open and closed entries
  • No way to bulk-clean closed sessions without manual file deletion

Proposed Solution

Add a `prune` subcommand to `acpx sessions`:

```bash

Prune all closed sessions for current agent/cwd

acpx kimi sessions prune

Dry-run: show what would be deleted

acpx kimi sessions prune --dry-run

Prune sessions closed before a given date

acpx kimi sessions prune --before 2026-03-01

Prune sessions older than N days

acpx kimi sessions prune --older-than 7

Also delete session history files (.stream.ndjson)

acpx kimi sessions prune --include-history
```

Behavior

  1. Query the sessions list for the current agent
  2. Filter sessions with status = `[closed]`
  3. Apply optional date/age filters
  4. Delete:
    • `{session_id}.json` (session metadata)
    • `{session_id}.stream.ndjson` and `{session_id}.stream.N.ndjson` (if `--include-history`)
  5. Print summary: X sessions pruned, Y MB freed

Motivation

  • Disk hygiene: sessions can grow large (hundreds of MB per session with long conversations)
  • UX: keeps `sessions list` output clean and actionable
  • Alternative: implementing file deletion inside `sessions close` is also acceptable, but a separate `prune` command gives users more control

Alternatives Considered

Approach Pros Cons
`sessions close` also deletes files Simple, no new command Breaking change if users rely on file persistence
`sessions prune` (proposed) Granular control, dry-run possible Slightly more complex
Automatic pruning on close Zero maintenance May delete data users want to keep

This is purely a CLI UX improvement; the session state is already tracked in memory so no protocol changes needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions