Skip to content

Archive old agent directories after cost tracking refactor #85

@eltmon

Description

@eltmon

Problem

After work completes, agent directories in ~/.panopticon/agents/ accumulate indefinitely. Currently there are 200+ directories from historical work.

Blocked On

PAN-81: Event-sourced cost tracking

The current cost calculation (/api/costs/by-issue) iterates through agent directories to find workspace paths for session file parsing. Until PAN-81 implements hook-based cost collection with its own persistence, we cannot safely delete or archive agent directories without losing cost data.

Proposed Solution (After PAN-81)

  1. Add status: "completed" to state.json when work finishes normally
  2. Add "Archive old agents" button to Health tab UI
  3. Implement archive logic:
    • Move directories older than X days (configurable) with status: "stopped" or "completed" to ~/.panopticon/agents-archive/
    • Or simply delete (cost data now lives in event log)
  4. Optional: Auto-archive on dashboard startup

Related

  • PAN-84 implemented filter-only approach as interim solution (hides old agents from Health tab)
  • PAN-81 will eliminate dependency on agent directories for cost calculation

Acceptance Criteria

  • Old agent directories can be cleaned up without losing cost data
  • Archive button available in Health tab UI
  • Configurable age threshold for archiving
  • Confirmation dialog before archiving

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions