Skip to content

Commit 051e0b3

Browse files
committed
docs(agents): add malformed plan handling guidance to orchestrator
Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 1e17812 commit 051e0b3

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

agents/opencoder.md

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

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

179+
## Handling Malformed Plans
180+
181+
The planner usually returns well-formatted plans, but gracefully handle edge cases when parsing fails.
182+
183+
### Missing Fields
184+
185+
When a task is missing `**Files:**` or `**Done when:**`:
186+
187+
```markdown
188+
### Task 2: Refactor config module
189+
190+
**Priority:** Medium
191+
**Complexity:** Medium
192+
**Description:** Split monolithic config into separate files
193+
```
194+
195+
**Handling:**
196+
- Use defaults: `Files: unknown`, `Done when: task description completed`
197+
- Log: "Warning: Task 2 missing Files and Done when fields, using defaults"
198+
- Proceed with the task - the builder can infer from the description
199+
200+
### Tasks Without Numbers
201+
202+
If planner outputs `### Task: Title` instead of `### Task 1: Title`:
203+
204+
```markdown
205+
### Task: Add error handling
206+
...
207+
### Task: Update tests
208+
...
209+
```
210+
211+
**Handling:**
212+
- Process tasks in the order they appear
213+
- Assign sequential numbers: Task 1, Task 2, etc.
214+
- Log: "Warning: Tasks missing numbers, processing in document order"
215+
216+
### Non-Standard Headings
217+
218+
If planner uses different heading formats:
219+
220+
```markdown
221+
## Task 1: Add validation ← H2 instead of H3
222+
**Task 2: Fix bug** ← Bold instead of heading
223+
Task 3 - Update docs ← Plain text with dash
224+
```
225+
226+
**Handling:**
227+
- Be flexible: look for "Task" followed by a number (or just "Task:")
228+
- Match patterns: `Task\s*\d*[:\-]?\s*(.+)`
229+
- Log: "Warning: Non-standard task format, attempting flexible parsing"
230+
- If truly unparseable, treat the entire response as a single task
231+
232+
### Empty or Too Few Tasks
233+
234+
When planner returns fewer than 3 tasks or no actionable tasks, see [Recovery Flow Example 3: Planner Returns No Actionable Tasks](#example-3-planner-returns-no-actionable-tasks) for the re-invocation strategy.
235+
236+
### Graceful Degradation Summary
237+
238+
| Issue | Default Behavior | Log Level |
239+
|-------|------------------|-----------|
240+
| Missing `Files:` | Use "unknown" | Warning |
241+
| Missing `Done when:` | Use "task description completed" | Warning |
242+
| No task numbers | Assign sequential numbers | Warning |
243+
| Non-standard headings | Flexible regex matching | Warning |
244+
| Unparseable format | Treat as single task | Warning |
245+
| Empty response | Re-invoke planner | Error |
246+
247+
**Principle:** Always attempt to extract actionable work. Only re-invoke the planner if the response is completely empty or contains zero parseable tasks.
248+
179249
## Handling Builder Results
180250

181251
The builder reports completion status in a structured format. Handle each case appropriately:

0 commit comments

Comments
 (0)