Skip to content

Commit df20d6f

Browse files
committed
feat(workflow): enhance agent input/output definitions and validation for multi-agent workflows
1 parent 8dbaad0 commit df20d6f

3 files changed

Lines changed: 103 additions & 7 deletions

File tree

prompts/templates/ali/chained/step-04-prompts.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ description: "Create prompt files and register placeholders"
1010
Create the actual prompt files for all agents:
1111
- Create folder structure
1212
- Generate prompt files for each agent
13+
- Define input and output for each agent
1314
- Create shared files
1415
- Register NEW placeholders in config
1516

@@ -260,6 +261,25 @@ Remove previous agent output from list.
260261

261262
**For all agents, after context decided:**
262263

264+
"**What output does '\{agent.name\}' produce?**
265+
266+
Since agents are isolated and can't see each other's work, we need to define what this agent outputs so the next agent can receive it.
267+
268+
*[If agent produces artifacts/plans/code:]*
269+
I recommend: `.codemachine/artifacts/\{agent.id\}-output.md`
270+
271+
*[If Q&A/interactive agent that only collects info:]*
272+
This agent collects user input - it may not need a file output if the next agent can access conversation context.
273+
274+
**Output filename** (or 'none' for Q&A agents):"
275+
276+
Wait. Store as `agent.outputFile`.
277+
278+
*[If output file specified, confirm placeholder:]*
279+
"This will be registered as placeholder `\{agent_id\}_output` for the next agent to receive."
280+
281+
---
282+
263283
"**Should this agent's prompt be split into smaller files?**
264284

265285
Based on '\{agent.name\}', I \{recommend/don't recommend\} splitting because \{reasoning\}.
@@ -306,18 +326,28 @@ Moving to '\{next_agent.name\}'..."
306326

307327
"**Context Summary:**"
308328

309-
| Agent | Input From | Outputs To | Placeholders |
310-
|-------|------------|------------|--------------|
311-
| \{agent1\} | - | \{agent2\} | \{list\} |
312-
| \{agent2\} | \{agent1\} | \{agent3\} | \{list\} |
329+
| Agent | Input Type | Input Source | Output File | Output Placeholder |
330+
|-------|------------|--------------|-------------|-------------------|
331+
| \{agent1\} | \{type\} | \{source or '-'\} | \{file\} | \{placeholder\} |
332+
| \{agent2\} | placeholder | \{agent1_output\} | \{file\} | \{placeholder\} |
313333

314334
*[Show data flow visually:]*
315335

316336
"**Data Flow:**
317337
```
318-
\{agent1\} → \{agent2\} → \{agent3\}
338+
\{agent1\} → writes \{output-file\} → registered as \{placeholder\}
339+
340+
\{agent2\} → receives \{placeholder\} → writes \{output-file\} → registered as \{placeholder\}
341+
342+
\{agent3\} → receives \{placeholder\} → ...
319343
```"
320344
345+
*[If any agent has no input defined (except first agent):]*
346+
"**Note:** The following agents have no input defined - they won't receive context from previous agents:
347+
- \{list\}
348+
349+
Is this intentional? (Q&A agents may not need input from previous agents)"
350+
321351
"**Shared files to create:**"
322352
- \{deduplicated list\}
323353
@@ -1436,7 +1466,10 @@ For each shared:
14361466
<persona path="prompts/templates/\{workflow_name\}/\{agent-id\}/persona.md" created="true" />
14371467
<prompt path="prompts/templates/\{workflow_name\}/\{agent-id\}/\{prompt.md or workflow.md\}" created="true">
14381468
<goal>\{agent goal\}</goal>
1439-
<output>\{expected output\}</output>
1469+
<input-type>\{placeholder|codebase-read|user-qa|specification\}</input-type>
1470+
<input-source>\{placeholder name or description\}</input-source>
1471+
<output-file>\{output filename or 'none'\}</output-file>
1472+
<output-placeholder>\{placeholder name for next agent\}</output-placeholder>
14401473
<has-sub-agent-coordination>\{true/false\}</has-sub-agent-coordination>
14411474
</prompt>
14421475
<!-- For each chained step (if multi-step) -->
@@ -1517,6 +1550,11 @@ For each shared:
15171550
<controller>\{Yes/No\}</controller>
15181551
<shared-files>\{count\}</shared-files>
15191552
<total-files>\{count\}</total-files>
1553+
<agent-chain>
1554+
<agents-with-input>\{count\}</agents-with-input>
1555+
<agents-with-output>\{count\}</agents-with-output>
1556+
<placeholder-chains>\{count\}</placeholder-chains>
1557+
</agent-chain>
15201558
</summary>
15211559
</step-04>
15221560
```

prompts/templates/ali/chained/step-05-workflow-generation.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,27 @@ After appending:
506506
- Verify all used placeholders are registered
507507
- Result: "✓ All placeholders registered" or "⚠️ Unregistered: \{name\}"
508508

509+
**Check 5: Agent Input/Output Chain** (for multi-agent workflows)
510+
- For workflows with 2+ agents, verify each agent has defined input/output
511+
- Verify agent outputs are registered as placeholders for subsequent agents
512+
- Verify each non-first agent has input defined (placeholder from previous agent, codebase read, or user Q&A)
513+
- Exception: Q&A/interactive agents that only collect user input don't need file output
514+
- Result: "✓ Agent chain properly connected" or "⚠️ Agent '\{id\}' has no input defined - it won't receive context from previous agents"
515+
516+
*[If Check 5 fails:]*
517+
"**Agent chain incomplete.**
518+
519+
The following agents have no defined input - they won't know what previous agents produced:
520+
\{list agents without input\}
521+
522+
Options:
523+
1. Go back to Step 04 and define input/output for these agents
524+
2. Confirm these are standalone agents that don't need previous context
525+
526+
How would you like to proceed?"
527+
528+
Wait for response. Do not generate workflow until resolved.
529+
509530
**If any issues found:**
510531
"**Issues Found:**"
511532
List each issue.
@@ -588,6 +609,7 @@ codemachine workflow \{workflow_name\}
588609
<files-exist>\{true|false\}</files-exist>
589610
<workflow-integrity>\{true|false\}</workflow-integrity>
590611
<placeholders-registered>\{true|false\}</placeholders-registered>
612+
<agent-chain-connected>\{true|false\}</agent-chain-connected>
591613
<issues-fixed count="\{count\}">
592614
<!-- If any issues were fixed -->
593615
<issue type="\{type\}" path="\{path\}" action="\{action taken\}" />
@@ -639,7 +661,8 @@ Run: `codemachine workflow \{workflow_name\}`"
639661
- Missing files recreated if any
640662
- Workflow.js file created
641663
- All config files updated (main.agents.js, sub.agents.js, modules.js, placeholders.js)
642-
- Final validation passed (IDs, files, integrity, placeholders)
664+
- Final validation passed (IDs, files, integrity, placeholders, agent chain)
665+
- Agent input/output chain validated for multi-agent workflows
643666
- User educated about keyboard shortcuts
644667
- Run command provided
645668
- **Step-05 XML appended to plan file**
@@ -651,6 +674,7 @@ Run: `codemachine workflow \{workflow_name\}`"
651674
- Workflow.js not created
652675
- Config files not updated
653676
- Validation failures not addressed
677+
- Proceeding with multi-agent workflow where agents have no input defined (they won't receive context)
654678
- Not showing how to run the workflow
655679
- Skipping keyboard shortcuts education
656680
- **Not appending to plan file**

prompts/templates/ali/workflow.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,39 @@ When user chooses to brainstorm in Step 01, select techniques from this list bas
222222

223223
{ali_brain_methods}
224224

225+
## Agent Isolation & Placeholders
226+
227+
Each agent runs in isolation - it has no knowledge of what agents came before or after it, or what they produced. Placeholders are the mechanism for passing context between agents.
228+
229+
Without placeholders, a multi-agent workflow is just disconnected agents that can't build on each other's work.
230+
231+
### Input & Output
232+
233+
Every agent should define:
234+
- **Input**: How the agent receives context
235+
- **Output**: What the agent produces (with exact filename so it can become a placeholder)
236+
237+
| Input Type | Use Case |
238+
|------------|----------|
239+
| Placeholder | Receiving output from previous agent (`{planner_output}`) |
240+
| Codebase Read | Agent collects context by reading files |
241+
| User Q&A | Interactive agent - input comes from user answers |
242+
| Specification | First agent receiving initial spec (`{specification}`) |
243+
244+
| Output Type | Description |
245+
|-------------|-------------|
246+
| Named Output | Specify exact filename: `{agent-id}-output.md` - becomes placeholder for next agent |
247+
| No Output | Only for Q&A/interactive agents that collect info but don't produce artifacts |
248+
249+
### How It Works
250+
251+
```
252+
Agent A runs → writes to `planner-output.md` → registered as {planner_output}
253+
Agent B runs → receives {planner_output} → builds on Agent A's work
254+
```
255+
256+
Step 04 collects input/output definitions. Step 05 validates placeholders are properly configured before generating the workflow.
257+
225258
## Key Rules
226259

227260
1. **Never skip steps** - Each step builds on previous (5 steps total), prompts are injected sequentially
@@ -233,6 +266,7 @@ When user chooses to brainstorm in Step 01, select techniques from this list bas
233266
7. **Append to plan file immediately** - When user confirms, append data to plan file right away
234267
8. **Use TodoWrite** - Track progress through steps with the todo list
235268
9. **Guide user to correct step** - You don't have full context until you reach the right step. If user asks about something that belongs to a later step, guide them to proceed step-by-step. Process selected conditions in order. Example: if user selected `agents` + `prompts` and asks about prompts, say "Before we talk about prompts, let's handle agents first since it's earlier in your journey. Press Enter to proceed to agents."
269+
10. **Define input/output for agents** - Each agent needs to know where its context comes from (input) and what it produces (output). This enables placeholder chaining between agents.
236270

237271
## Workflow Plan File
238272

0 commit comments

Comments
 (0)