---
name: "Prevent duplicate stage agents on same story"
---

# Story 230: Prevent duplicate stage agents on same story

## User Story

As a supervisor, I want start_agent to reject a second coder (or QA, or mergemaster) on a story that already has one running, so that two agents don't operate in the same worktree and corrupt each other's work.

## Acceptance Criteria

- [ ] start_agent rejects a second coder-stage agent on a story that already has a Running or Pending coder, with a clear error message naming both agents
- [ ] The check covers all non-Other pipeline stages (Coder, Qa, Mergemaster), not just Coder
- [ ] The check fires for both explicit agent_name requests and auto-selected agents
- [ ] Auto-assign (auto_assign_available_work) is unaffected — it already has its own is_story_assigned_for_stage guard
- [ ] Regression test: concurrent start_agent calls with two different coder names on the same story — exactly one succeeds
- [ ] Regression test: two coders on different stories still works fine

## Out of Scope

- TBD
