Dual-Loop (Inner/Outer Agent Delegation)
The Dual-Loop architecture splits work between a strategic Outer Loop (Supervisor/Director) and an execution-focused Inner Loop (tactical coding sub-agent). The Outer Loop organizes tasks, delegates via Strategy Packets, verifies output, and generates Correction Packets.
1. Setup & Interactive Orientation (Outer Loop)
- Decomposition: Break work down into atomic, testable Work Packages (WPs).
- Interactive CLI & Model Selection: Ask user for preferred CLI (
agy,claude,copilot,codex,llama) and model. Consultreferences/cheapest_models.json. - Workspace Isolation: Receive isolated git worktree or directory branch from orchestrator.
2. Strategy Packet Generation & Dispatch
- Author Strategy Packet (
handoffs/task_packet_NNN.md):- Scope, target files, acceptance criteria, and explicit "NO GIT" rule for the Inner Loop.
- Dispatch sub-agent with standard input redirected (
< /dev/nullto preventSIGTTINhalts):python scripts/run_agent.py handoffs/task_packet_001.md <target_file> handoffs/result.md \ "Execute strategy packet exactly." --cli <cli> --model "<model>" < /dev/null
3. Supervised Verification Gates
Upon completion signal, the Outer Loop verifies output:
- Delta Audit: Run
git diffto verify only authorized paths were modified; zero stub placeholders (TODO,TBD). - Automated Test Run: Run unit and integration tests mechanically.
- Outcome Resolution:
- PASS: Mark complete, update task tracker, proceed to closure.
- FAIL: Issue a Correction Packet categorized by severity:
- 🔴 CRITICAL: Fails compile/tests. Return immediate error diagnostics.
- 🟡 MODERATE: Breaks architecture/conventions. Cite specific rule.
- 🟢 MINOR: Style only. Supervisor fixes directly.
4. Retrospective & Closure
- Conduct post-run self-assessment survey (
references/post_run_survey.md). - If friction reoccurs 3+ times, flag for triple-loop escalation.
- Merge verified branch and emit handoff summary.
Operational References
- Architecture Diagram:
references/diagrams/dual_loop_architecture.mmd - Acceptance Criteria:
references/acceptance-criteria.md - Fallback Protocol:
references/fallback-tree.md