feat: Make inter-agent communication prompt mode-aware
Planning modes (plan, refine) get a minimal block with just cw ask syntax. Execution modes get the full protocol: commands table, shell recipe for listener lifecycle, targeting guidance, when/when-not decision criteria, good/bad examples, and answering guidelines.
This commit is contained in:
@@ -143,12 +143,18 @@ Agent output is persisted to `agent_log_chunks` table and drives all live stream
|
||||
Agents can communicate with each other via the `conversations` table, coordinated through CLI commands.
|
||||
|
||||
### Prompt Integration
|
||||
`buildInterAgentCommunication(agentId)` function in `prompts/shared.ts` generates per-agent communication instructions. Called in `manager.ts` after agent record creation — the actual agent ID is injected directly into the prompt (no manifest.json indirection). Appended to the prompt regardless of mode. Instructions include:
|
||||
1. Set up a background listener via temp-file redirect: `cw listen > $CW_LISTEN_FILE &`
|
||||
2. Periodically check the temp file for incoming questions between work steps
|
||||
3. Answer via `cw answer`, clear the file, restart the listener
|
||||
4. Ask questions to peers via `cw ask --from <agentId> --agent-id|--task-id|--phase-id`
|
||||
5. Kill the listener and clean up the temp file before writing `signal.json`
|
||||
`buildInterAgentCommunication(agentId, mode)` function in `prompts/shared.ts` generates per-agent communication instructions. Called in `manager.ts` after agent record creation — the actual agent ID is injected directly into the prompt (no manifest.json indirection).
|
||||
|
||||
**Mode-aware branching:**
|
||||
|
||||
- **Planning modes** (`plan`, `refine`): Minimal block — just the agent ID and `cw ask` syntax for emergencies. These agents define high-level structure, not implementation details, so real-time coordination is almost never needed.
|
||||
- **Execution + coordination modes** (`execute`, `detail`, `discuss`, `verify`, `merge`, `review`): Full protocol including:
|
||||
1. Commands table with accurate CLI behavior descriptions
|
||||
2. Numbered shell recipe for background listener lifecycle (start → check → answer → restart → cleanup)
|
||||
3. Targeting guidance (`--agent-id` vs `--task-id` vs `--phase-id`)
|
||||
4. Decision criteria: when to ask (uncommitted interfaces, shared file conflicts) and when NOT to ask (answer in codebase, answer in input files, not blocked, confirming approach)
|
||||
5. Good/bad examples using `<example label>` pattern
|
||||
6. Answering guidelines (be specific — include code snippets, file paths, type signatures)
|
||||
|
||||
### Agent Identity
|
||||
`manifest.json` includes `agentId` and `agentName` fields. The manager passes these from the DB record after agent creation. The agent ID is also injected directly into the prompt's communication instructions.
|
||||
|
||||
Reference in New Issue
Block a user