PMO Skill — Main Process Role Pattern
Core Principle
Main process = dialog + dispatch only. Never execute actual work.
The main agent process must never run commands, SSH operations, git operations, or any I/O-bound tasks directly. All execution goes to subagents. The main process stays free to dialog with the user.
Role Definition
| Responsibility | Main Process | Subagent |
|---|---|---|
| User dialog | ✅ | ❌ |
| Task dispatch | ✅ | ❌ |
| Task execution | ❌ | ✅ |
| Result reporting | ✅ | ✅ |
| Decision making | ✅ | ❌ |
| Status coordination | ✅ | ❌ |
Execution Model
Spawn, Don't Block
When a task requires work:
- Spawn a subagent with
task=<description> - Do NOT wait/poll in a loop
- Continue dialog freely
- Results arrive via push events
# ❌ Wrong - blocks main process
exec("ssh ...") # Don't do this
result = subprocess.run(...)
# ✅ Correct - spawn and return immediately
sessions_spawn(task="SSH and check status", runtime="subagent", mode="run")
Fire-and-Forget Subagents
Subagents run independently. Main process:
- Spawns with full task description
- Does NOT track progress polling
- Waits for completion event
- Reports result when delivered
No Cross-Node Direct Delegation
In multi-node setups (e.g., two AI nodes collaborating):
- Each node spawns its own subagents only
- Nodes do NOT spawn subagents on behalf of each other
- Inter-node coordination goes through established protocols (ic, MQTT, etc.)
- Cross-node task delegation requires explicit user instruction
If coordination is needed between two AI nodes:
- Main process discusses with user
- User approves and instructs
- Message sent via inter-node protocol (ic, MQTT bus, etc.)
- Remote node spawns its own subagents
Skill Design Constraints
When authoring skills that implement this pattern:
No Hardcoded Identity
- ❌ No AI names ("Nek", "Nyx", "OfficeClaw")
- ❌ No node identifiers (IP addresses, hostnames)
- ❌ No user IDs, Telegram IDs, chat IDs
- ❌ No specific skill names that imply identity
Generic Triggers
- Use role-based triggers: "PMO", "coordinator", "主进程"
- Use pattern triggers: "不要自己跑", "spawn subagent"
- Use generic tool references: "SSH to router", not "SSH to 192.168.16.2"
Configuration-Driven
- Store credentials/endpoints in environment variables or config files
- Reference via environment:
${SSH_HOST},${ROUTER_PASSWORD} - Never hardcode secrets in skill content
Error Handling
Subagent Failure
- Subagent failure delivers error result via push
- Main process reviews error and decides next action
- Can spawn retry or escalate to user
- Never silently swallow errors
User Questions During Subagent Run
- Main process answers freely from context
- If new data needed, spawn additional subagent
- Do NOT wait for original subagent to complete first
Anti-Patterns
| Anti-Pattern | Why Wrong | Correct Approach |
|---|---|---|
| "Let me check..." + exec in main | Blocks dialog | Spawn subagent |
| Estimating subagent duration | Always wrong | Fire-and-forget |
| Direct SSH to remote node | Bypasses protocol | Use ic/MQTT |
| Hardcoding node IP/hostname | Not portable | Use DNS/env var |
| Delegating to other AI node directly | Breaks coordination | Go through user |
Workflow Summary
- User request arrives
- Main process assesses — does it need external data?
- If yes → spawn subagent with full context, do NOT wait
- Continue dialog with user about anything
- Subagent result arrives via push event
- Main process reports result to user
- Repeat
This pattern ensures the main process is never blocked, always responsive, and operates at the coordination layer rather than execution layer.
