Skip to content

Commit b00eef5

Browse files
leonvanzylclaude
andcommitted
refactor: orchestrator pre-selects features for all agents
Replace agent-initiated feature selection with orchestrator pre-selection for both coding and testing agents. This ensures Mission Control displays correct feature numbers for testing agents (previously showed "Feature #0"). Key changes: MCP Server (mcp_server/feature_mcp.py): - Add feature_get_by_id tool for agents to fetch assigned feature details - Remove obsolete tools: feature_get_next, feature_claim_next, feature_claim_for_testing, feature_get_for_regression - Remove helper functions and unused imports (text, OperationalError, func) Orchestrator (parallel_orchestrator.py): - Change running_testing_agents from list to dict[int, Popen] - Add claim_feature_for_testing() with random selection - Add release_testing_claim() method - Pass --testing-feature-id to spawned testing agents - Use unified [Feature #X] output format for both agent types Agent Entry Points: - autonomous_agent_demo.py: Add --testing-feature-id CLI argument - agent.py: Pass testing_feature_id to get_testing_prompt() Prompt Templates: - coding_prompt.template.md: Update to use feature_get_by_id - testing_prompt.template.md: Update workflow for pre-assigned features - prompts.py: Update pre-claimed headers for both agent types WebSocket (server/websocket.py): - Simplify tracking with unified [Feature #X] pattern - Remove testing-specific parsing code Assistant (server/services/assistant_chat_session.py): - Update help text with current available tools Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 357083d commit b00eef5

10 files changed

Lines changed: 277 additions & 564 deletions

File tree

.claude/templates/coding_prompt.template.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ Then use MCP tools to check feature status:
2929
```
3030
# 6. Get progress statistics (passing/total counts)
3131
Use the feature_get_stats tool
32-
33-
# 7. Get the next feature to work on
34-
Use the feature_get_next tool
3532
```
3633

3734
Understanding the `app_spec.txt` is critical - it contains the full requirements
@@ -48,7 +45,7 @@ chmod +x init.sh
4845

4946
Otherwise, start servers manually and document the process.
5047

51-
### STEP 3: CHOOSE ONE FEATURE TO IMPLEMENT
48+
### STEP 3: GET YOUR ASSIGNED FEATURE
5249

5350
#### TEST-DRIVEN DEVELOPMENT MINDSET (CRITICAL)
5451

@@ -63,20 +60,17 @@ Features are **test cases** that drive development. This is test-driven developm
6360
- WRONG: "Flashcard page doesn't exist yet" → skip feature
6461
- RIGHT: "Flashcard page doesn't exist yet" → build flashcard page → implement filter → test feature
6562

66-
Get the next feature to implement:
63+
**Note:** Your feature has been pre-assigned by the orchestrator. Use `feature_get_by_id` with your assigned feature ID to get the details.
6764

68-
```
69-
# Get the highest-priority pending feature
70-
Use the feature_get_next tool
71-
```
72-
73-
Once you've retrieved the feature, **immediately mark it as in-progress**:
65+
Once you've retrieved the feature, **mark it as in-progress** (if not already):
7466

7567
```
76-
# Mark feature as in-progress to prevent other sessions from working on it
77-
Use the feature_mark_in_progress tool with feature_id=42
68+
# Mark feature as in-progress
69+
Use the feature_mark_in_progress tool with feature_id={your_assigned_id}
7870
```
7971

72+
If you get "already in-progress" error, that's OK - continue with implementation.
73+
8074
Focus on completing one feature perfectly and completing its testing steps in this session before moving on to other features.
8175
It's ok if you only complete one feature in this session, as there will be more sessions later that continue to make progress.
8276

@@ -337,10 +331,10 @@ The feature tools exist to reduce token usage. **DO NOT make exploratory queries
337331
# 1. Get progress stats (passing/in_progress/total counts)
338332
feature_get_stats
339333
340-
# 2. Get the NEXT feature to work on (one feature only)
341-
feature_get_next
334+
# 2. Get your assigned feature details
335+
feature_get_by_id with feature_id={your_assigned_id}
342336
343-
# 3. Mark a feature as in-progress (call immediately after feature_get_next)
337+
# 3. Mark a feature as in-progress
344338
feature_mark_in_progress with feature_id={id}
345339
346340
# 4. Mark a feature as passing (after verification)
@@ -349,7 +343,7 @@ feature_mark_passing with feature_id={id}
349343
# 5. Mark a feature as failing (if you discover it's broken)
350344
feature_mark_failing with feature_id={id}
351345
352-
# 6. Skip a feature (moves to end of queue) - ONLY when blocked by dependency
346+
# 6. Skip a feature (moves to end of queue) - ONLY when blocked by external dependency
353347
feature_skip with feature_id={id}
354348
355349
# 7. Clear in-progress status (when abandoning a feature)
@@ -361,8 +355,9 @@ feature_clear_in_progress with feature_id={id}
361355
- Do NOT try to fetch lists of all features
362356
- Do NOT query features by category
363357
- Do NOT list all pending features
358+
- Your feature is pre-assigned by the orchestrator - use `feature_get_by_id` to get details
364359

365-
**You do NOT need to see all features.** The feature_get_next tool tells you exactly what to work on. Trust it.
360+
**You do NOT need to see all features.** Work on your assigned feature only.
366361

367362
---
368363

.claude/templates/testing_prompt.template.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,15 @@ chmod +x init.sh
4040

4141
Otherwise, start servers manually.
4242

43-
### STEP 3: CLAIM A FEATURE TO TEST
43+
### STEP 3: GET YOUR ASSIGNED FEATURE
4444

45-
Atomically claim ONE passing feature for regression testing:
45+
Your feature has been pre-assigned by the orchestrator. Use `feature_get_by_id` to get the details:
4646

4747
```
48-
Use the feature_claim_for_testing tool
48+
Use the feature_get_by_id tool with feature_id={your_assigned_id}
4949
```
5050

51-
This atomically claims a random passing feature that:
52-
- Is not being worked on by coding agents
53-
- Is not already being tested by another testing agent
51+
The orchestrator has already claimed this feature for testing (set `testing_in_progress=true`).
5452

5553
**CRITICAL:** You MUST call `feature_release_testing` when done, regardless of pass/fail.
5654

@@ -157,9 +155,8 @@ echo "[Testing] Session complete - verified/fixed feature #{id}" >> claude-progr
157155

158156
### Feature Management
159157
- `feature_get_stats` - Get progress overview (passing/in_progress/total counts)
160-
- `feature_claim_for_testing` - **USE THIS** - Atomically claim a feature for testing
158+
- `feature_get_by_id` - Get your assigned feature details
161159
- `feature_release_testing` - **REQUIRED** - Release claim after testing (pass tested_ok=true/false)
162-
- `feature_get_for_regression` - (Legacy) Get random passing features without claiming
163160
- `feature_mark_failing` - Mark a feature as failing (when you find a regression)
164161
- `feature_mark_passing` - Mark a feature as passing (after fixing a regression)
165162

agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ async def run_autonomous_agent(
117117
yolo_mode: bool = False,
118118
feature_id: Optional[int] = None,
119119
agent_type: Optional[str] = None,
120+
testing_feature_id: Optional[int] = None,
120121
) -> None:
121122
"""
122123
Run the autonomous agent loop.
@@ -128,6 +129,7 @@ async def run_autonomous_agent(
128129
yolo_mode: If True, skip browser testing in coding agent prompts
129130
feature_id: If set, work only on this specific feature (used by orchestrator for coding agents)
130131
agent_type: Type of agent: "initializer", "coding", "testing", or None (auto-detect)
132+
testing_feature_id: For testing agents, the pre-claimed feature ID to test
131133
"""
132134
print("\n" + "=" * 70)
133135
print(" AUTONOMOUS CODING AGENT")
@@ -220,7 +222,7 @@ async def run_autonomous_agent(
220222
if agent_type == "initializer":
221223
prompt = get_initializer_prompt(project_dir)
222224
elif agent_type == "testing":
223-
prompt = get_testing_prompt(project_dir)
225+
prompt = get_testing_prompt(project_dir, testing_feature_id)
224226
elif feature_id:
225227
# Single-feature mode (used by orchestrator for coding agents)
226228
prompt = get_single_feature_prompt(feature_id, project_dir, yolo_mode)

autonomous_agent_demo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ def parse_args() -> argparse.Namespace:
141141
help="Agent type (used by orchestrator to spawn specialized subprocesses)",
142142
)
143143

144+
parser.add_argument(
145+
"--testing-feature-id",
146+
type=int,
147+
default=None,
148+
help="Feature ID to regression test (used by orchestrator for testing agents)",
149+
)
150+
144151
# Testing agent configuration
145152
parser.add_argument(
146153
"--testing-ratio",
@@ -197,6 +204,7 @@ def main() -> None:
197204
yolo_mode=args.yolo,
198205
feature_id=args.feature_id,
199206
agent_type=args.agent_type,
207+
testing_feature_id=args.testing_feature_id,
200208
)
201209
)
202210
else:

client.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,20 @@ def get_playwright_headless() -> bool:
5454
FEATURE_MCP_TOOLS = [
5555
# Core feature operations
5656
"mcp__features__feature_get_stats",
57-
"mcp__features__feature_get_next",
58-
"mcp__features__feature_claim_next", # Atomic get+claim for parallel execution
59-
"mcp__features__feature_get_for_regression",
57+
"mcp__features__feature_get_by_id", # Get assigned feature details
6058
"mcp__features__feature_mark_in_progress",
6159
"mcp__features__feature_mark_passing",
6260
"mcp__features__feature_mark_failing", # Mark regression detected
6361
"mcp__features__feature_skip",
6462
"mcp__features__feature_create_bulk",
6563
"mcp__features__feature_create",
6664
"mcp__features__feature_clear_in_progress",
65+
"mcp__features__feature_release_testing", # Release testing claim
6766
# Dependency management
6867
"mcp__features__feature_add_dependency",
6968
"mcp__features__feature_remove_dependency",
7069
"mcp__features__feature_set_dependencies",
71-
# Parallel execution support
70+
# Query tools
7271
"mcp__features__feature_get_ready",
7372
"mcp__features__feature_get_blocked",
7473
"mcp__features__feature_get_graph",

0 commit comments

Comments
 (0)