---
name: "Clean up agent state on story archive and add TTL for completed entries"
---

# Story 133: Clean up agent state on story archive and add TTL for completed entries

## User Story

As a user, I want completed and archived agent entries to be cleaned up automatically so that the agent pool reflects reality and stale entries do not accumulate or confuse the UI.

## Acceptance Criteria

- [ ] When a story is archived (move_story_to_archived), all agent entries for that story_id are removed from the HashMap
- [ ] Completed and Failed agent entries are automatically removed after a configurable TTL (default 1 hour)
- [ ] list_agents never returns agents for archived stories, even without the filesystem filter fallback
- [ ] A test demonstrates that archiving a story removes its agent entries from the pool
- [ ] A test demonstrates that completed entries are reaped after TTL expiry

## Out of Scope

- TBD
