---
name: "Auto-assign broken after stage field was added to agent config"
---

# Bug 153: Auto-assign broken after stage field was added to agent config

## Description

Bug 150 changed agent pipeline role detection from name-based matching (pipeline_stage function) to a stage field in project.toml. The auto_assign_available_work function in server/src/agents.rs (line 1212) uses find_free_agent_for_stage (line 1728) to match agents to pipeline stages. After the stage field change, auto-assign stopped working — free coders are not picked up for items in 2_current/.

Likely causes:
- find_free_agent_for_stage still calls the old pipeline_stage() by name instead of reading the config stage field
- Or the PipelineStage enum comparison is failing due to a mismatch between config values and enum variants
- Or auto_assign_available_work is not being triggered after agent completion

Key files:
- server/src/agents.rs line 1212: auto_assign_available_work
- server/src/agents.rs line 1728: find_free_agent_for_stage
- server/src/config.rs: agent config with new stage field
- .story_kit/project.toml: stage values on each agent

## How to Reproduce

1. Have items in 2_current/ with free coders available
2. Wait for auto_assign_available_work to trigger
3. Free coders are not assigned to waiting items

## Actual Result

Free coders sit idle while items wait in current. Manual start_agent works fine.

## Expected Result

auto_assign_available_work should detect free coders and assign them to waiting items, using the new stage field from project.toml.

## Acceptance Criteria

- [ ] Bug is fixed and verified
