Verification Source: Companion bot autonomous loop + game project harness scheduled tasks (2026-03) Validity Conditions: Projects with 2+ autonomous agents or operating scheduled automation tasks
Core Principles
Communication between agents must happen through files. Real-time calls create dependencies; files enable asynchrony.
Role Separation Patterns
When there are two or more agents, roles must be clearly divided.
Director / Implementer Pattern
User (Director) → Decides "what to build"
Primary Agent (Implementer) → Writes actual code/files
Autonomous Agents → Monitoring, reporting, polling, periodic analysis
Key rule: The implementer agent must not assume the director role. When an agent starts deciding "what to build next" on its own, direction drifts.
Scope of Autonomous Agents
What autonomous agents must not do: - No modifying core logic files - No write operations to external APIs without user confirmation - No modifying other agents' Core files
File-Based Message Passing
State sharing between agents is done through files.
State File Pattern
Tasks/loop_state.json → What stage is the current loop at
Tasks/build_result.json → Build success/failure result
Agent_Agenda/PD_YYYYMMDD.md → What happened today
task_lessons.md → Patterns accumulated from repeated execution
Clear read/write ownership:
| File | Writing Agent | Reading Agent |
|------|------------|------------|
| loop_state.json | Implementation loop agent | Polling agent |
| PD_*.md | PD report task | User, analysis agent |
| task_lessons.md | Each task itself | Same task on next execution |
Scheduled Task Design Principles
When designing autonomously-executing tasks:
Design Early Termination Conditions First
Execution starts → Are there already sufficient results for today?
→ Yes: Record "no new information" and terminate
→ No: Begin main work
Without this, the same task runs 3 times a day and produces duplicate outputs.
Bake Lesson Accumulation into the Structure
Discovery during execution → Record in task_lessons.md under the relevant task section
Confirmed 3 times → Promote to "established pattern"
Established pattern → Reflect in task SKILL.md
Ouroboros Time Limits
weekly-codex-distill: 15 min
daily-pd-report: 10 min
bot-self-reflection: 5 min
On timeout, record "incomplete" and defer to the next execution.
Agent Loop Design Patterns
When an autonomous loop runs indefinitely:
State Machine-Based Loop
State: pending_review → Run review agent
State: awaiting_input → Run polling agent
State: implementing → Run implementation agent
State: done → Terminate loop
Key point: The state machine must reside in Core. If a Shell agent modifies state transition rules, the loop becomes unpredictable.
Loop Exit Conditions
Environment Isolation: Cowork VM vs Windows
Cowork scheduled tasks run in a Linux VM. Windows tools (gh.exe, PowerShell) do not execute directly in this VM.
Available in Cowork VM (Linux):
✅ git log, git diff, git commit
✅ File read/write
✅ Python, Node.js scripts
Not available in Cowork VM:
❌ git push (no Windows gh authentication)
❌ Windows app manipulation
❌ Windows registry access
Solution: Automation requiring git push → route via mcp__Windows-MCP__PowerShell