Accept story 41: Agent Completion Notification via MCP

Add wait_for_agent MCP tool that blocks until an agent reaches a terminal
state (completed, failed, stopped). Returns final status with session_id,
worktree_path, and git commits made by the agent.

- Subscribe-before-check pattern avoids race conditions
- Handles lagged receivers, channel closure, and configurable timeout
- Default timeout 5 minutes, includes git log of agent commits in response
- 11 new tests covering all paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-20 13:16:04 +00:00
parent fa5d013fe2
commit c6a04f5e53
3 changed files with 387 additions and 16 deletions

View File

@@ -0,0 +1,21 @@
---
name: Agent Completion Notification via MCP
test_plan: pending
---
# Story 41: Agent Completion Notification via MCP
## User Story
As a CLI user coordinating sub-agents, I want to be notified when an agent completes without manually polling, so that I can review results promptly without babysitting the process.
## Acceptance Criteria
- [ ] MCP tool wait_for_agent(story_id, agent_name) blocks until the agent reaches a terminal state (completed, failed, stopped)
- [ ] Returns the agent's final status and summary info (session_id, worktree_path, any commit made)
- [ ] Respects a timeout parameter so callers aren't stuck forever
- [ ] Works as a background call from Claude Code CLI so the user can keep working while waiting
## Out of Scope
- TBD