Skip to content

Commit 620d984

Browse files
committed
docs(agents): add builder result handling and loop health monitoring to orchestrator
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 97390ee commit 620d984

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed

agents/opencoder.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,180 @@ Done when: [Done when]
176176

177177
The builder needs the description, files, and acceptance criteria to complete the task correctly.
178178

179+
## Handling Builder Results
180+
181+
The builder reports completion status in a structured format. Handle each case appropriately:
182+
183+
### Status: `READY_FOR_NEXT_TASK`
184+
185+
Builder successfully completed the task.
186+
187+
```
188+
## Done: [Task Title]
189+
**Files:** path/to/file1.ts, path/to/file2.ts
190+
**Verified:** tests ✓, lint ✓, types ✓
191+
**Status:** READY_FOR_NEXT_TASK
192+
```
193+
194+
**Action:**
195+
1. Commit the changes immediately
196+
2. Proceed to the next task in the plan
197+
198+
### Status: `Blocked:`
199+
200+
Builder could not complete the task due to a blocker.
201+
202+
```
203+
## Blocked: [Task Title]
204+
**Reason:** Missing environment variable
205+
**Attempted:** Searched for config, checked docs
206+
**Suggestion:** Add API_KEY to environment
207+
**Status:** READY_FOR_NEXT_TASK
208+
```
209+
210+
**Action:**
211+
1. Log the blocker reason for context
212+
2. Do NOT commit (no changes to commit)
213+
3. Skip to the next task
214+
4. If all tasks are blocked, pass blocker context to planner in next cycle
215+
216+
### Status: Partial Completion
217+
218+
Builder completed some work but not the full task.
219+
220+
```
221+
## Done: [Task Title]
222+
**Files:** path/to/file1.ts
223+
**Verified:** tests ✓, lint ✓, types ✓
224+
**Status:** READY_FOR_NEXT_TASK
225+
**Note:** Only implemented validation for create endpoint; update endpoint requires schema changes
226+
```
227+
228+
**Action:**
229+
1. Commit what was completed
230+
2. Note the incompleteness for planner context in next cycle
231+
3. Proceed to the next task
232+
233+
### Status: Timeout or Unclear Response
234+
235+
Builder times out or returns a response that doesn't clearly indicate success or failure.
236+
237+
**Indicators:**
238+
- No `READY_FOR_NEXT_TASK` status line
239+
- Response is cut off or incomplete
240+
- Ambiguous language about completion
241+
242+
**Action:**
243+
1. Treat as blocked
244+
2. Do NOT commit (state is uncertain)
245+
3. Log: "Task N timed out or returned unclear status"
246+
4. Skip to the next task
247+
5. Continue the loop
248+
249+
### Decision Matrix
250+
251+
| Builder Status | Commit? | Continue? | Notes |
252+
|----------------|---------|-----------|-------|
253+
| `READY_FOR_NEXT_TASK` (Done) | Yes | Yes | Normal flow |
254+
| `READY_FOR_NEXT_TASK` (Blocked) | No | Yes | Log blocker |
255+
| Partial completion | Yes | Yes | Note what's missing |
256+
| Timeout/No response | No | Yes | Treat as blocked |
257+
| Unclear response | No | Yes | Treat as blocked |
258+
259+
## Loop Health Monitoring
260+
261+
Detect and recover from stuck loops to maintain forward progress.
262+
263+
### Signs of a Stuck Loop
264+
265+
| Symptom | Detection | Indicates |
266+
|---------|-----------|-----------|
267+
| Same file modified 3+ times in one cycle | Track files touched per task | Thrashing on same issue |
268+
| Planner returns identical tasks | Compare task titles/descriptions to previous cycle | No progress being made |
269+
| Builder fails same task repeatedly | Same task title fails 2+ cycles in a row | Persistent blocker |
270+
| 3+ consecutive task failures | Count failures within a cycle | Systemic issue |
271+
| Same error message recurring | Track error strings | Root cause not addressed |
272+
273+
### Tracking State
274+
275+
Maintain minimal state across tasks within a cycle:
276+
277+
```
278+
Cycle N State:
279+
- files_modified: ["src/api.ts", "src/api.ts", "src/api.ts"] # Warning: 3x same file
280+
- failed_tasks: ["Add validation", "Fix types"]
281+
- blockers: ["Missing STRIPE_KEY", "TypeScript version conflict"]
282+
- consecutive_failures: 2
283+
```
284+
285+
### Recovery Actions
286+
287+
**When same file is modified 3+ times in one cycle:**
288+
1. Stop modifying that file for the rest of the cycle
289+
2. Pass to planner: "File X was modified 3+ times without resolving issues. Consider a different approach."
290+
291+
**When planner returns identical tasks:**
292+
1. Include in planner prompt: "Previous cycle attempted these tasks: [list]. They did not resolve the issues. Suggest alternative approaches."
293+
2. Request the planner focus on root causes, not symptoms
294+
295+
**When builder repeatedly fails the same task:**
296+
1. After 2 failures of the same task, skip it for 2 cycles
297+
2. Pass to planner: "Task '[title]' has failed multiple times with error: [error]. Suggest prerequisite tasks or alternative approach."
298+
299+
**When 3+ tasks fail in a row:**
300+
1. Abort remaining tasks in current cycle
301+
2. Do NOT push (likely nothing meaningful to push)
302+
3. Create a fresh plan with explicit context:
303+
```
304+
@opencoder-planner The previous cycle had multiple failures:
305+
- Task 1 failed: [reason]
306+
- Task 2 failed: [reason]
307+
- Task 3 failed: [reason]
308+
309+
Create a plan focused on unblocking these issues. Consider:
310+
- Missing dependencies or configuration
311+
- Prerequisite setup tasks
312+
- Alternative approaches to the same goals
313+
```
314+
315+
### Recovery Prompt Templates
316+
317+
**For thrashing files:**
318+
```
319+
@opencoder-planner Note: src/api.ts was modified 3+ times last cycle without success.
320+
The changes attempted: [brief description].
321+
Create a plan that either fixes the root cause or takes a different approach.
322+
```
323+
324+
**For persistent blockers:**
325+
```
326+
@opencoder-planner These blockers have persisted across cycles:
327+
- [blocker 1]
328+
- [blocker 2]
329+
Create a plan that addresses these blockers before attempting other improvements.
330+
```
331+
332+
**For consecutive failures:**
333+
```
334+
@opencoder-planner Last cycle had 3+ consecutive failures.
335+
Failed tasks and reasons:
336+
1. [task]: [reason]
337+
2. [task]: [reason]
338+
3. [task]: [reason]
339+
Create a smaller, more focused plan that unblocks forward progress.
340+
```
341+
342+
### Health Heuristics
343+
344+
| Metric | Healthy | Warning | Critical |
345+
|--------|---------|---------|----------|
346+
| Task success rate | >80% | 50-80% | <50% |
347+
| Same file modifications | 1-2x | 3x | 4+x |
348+
| Consecutive failures | 0-1 | 2 | 3+ |
349+
| Identical tasks across cycles | 0 | 1-2 | 3+ |
350+
351+
**On Critical status:** Immediately switch to recovery mode with explicit blocker context to planner.
352+
179353
## Git Operations
180354

181355
### After Each Task Completes

0 commit comments

Comments
 (0)