Orchestrator Protocol Specification
Version: 1.1.0 Status: ACTIVE Created: 2026-01-18 Updated: 2026-01-26 Author: Protocol Specification Subagent Epic: T1575 Session: session_20260118_132917_801b75 See Also: Version Guide for version relationshipsRFC 2119 Conformance
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in BCP 14 RFC 2119 RFC 8174 when, and only when, they appear in all capitals.Part 1: Overview
1.1 Purpose
Vision Document: See ORCHESTRATOR-VISION.md for the foundational philosophy: “Stay high-level. Delegate everything. Read only manifests. Spawn in order.”This specification defines the behavioral protocol for orchestrating multi-agent research workflows in CLEO. It establishes immutable rules for orchestrator behavior, subagent delegation, manifest-based coordination, and session startup procedures.
1.2 Authority
This specification is AUTHORITATIVE for:- Orchestrator behavioral constraints and delegation rules
- Subagent output protocol and CLEO task integration
- Manifest schema and query patterns
- Session startup protocol for conversation continuity
- Task linking and research-to-task cross-referencing
- ORCHESTRATOR-SPEC.md for tmux-based multi-agent orchestration
- IMPLEMENTATION-ORCHESTRATION-SPEC.md for 7-agent pipeline
- MULTI-SESSION-SPEC.md for session scope binding
- SUBAGENT_PROTOCOL.md for research output format
1.3 Scope
This protocol governs:- Orchestrator behavior - High-level coordination without implementation
- Subagent delegation - Work assignment and output collection
- Manifest coordination - Lightweight state passing between agents
- Session continuity - Resuming work across conversation boundaries
Part 2: Orchestrator Behavior Rules
2.1 Core Constraints
The orchestrator agent is the conversation-level coordinator. It MUST adhere to these immutable constraints:| Rule ID | Constraint | Rationale |
|---|---|---|
| ORC-001 | MUST stay high-level; MUST NOT implement code | Context preservation; delegation efficiency |
| ORC-002 | MUST delegate ALL work to subagents | Separation of concerns; parallel execution |
| ORC-003 | MUST NOT read full research files into context | Token efficiency; context window protection |
| ORC-004 | MUST spawn agents in dependency order | Correctness; avoid wasted work |
| ORC-005 | MUST use manifest for research summaries | O(1) lookup vs O(n) file reading |
| ORC-006 | MUST verify protocol injection before spawn | Ensures subagent compliance |
| ORC-007 | MUST check context thresholds before spawn | Prevents context overflow |
| ORC-008 | MUST verify previous agent compliance before next spawn | Maintains protocol chain integrity |
| ORC-009 | MUST auto-stop when context reaches critical threshold | Graceful session handoff |
2.2 Delegation Decision Tree
2.3 Permitted Orchestrator Actions
The orchestrator MAY perform these actions directly:| Action | Tool | Example |
|---|---|---|
| Check task state | cleo session list, cleo list, cleo show | cleo session list --status active |
| Query manifest | cat MANIFEST.jsonl | jq | jq -s '.[-1]' MANIFEST.jsonl |
| Plan task sequence | None (internal reasoning) | Dependency analysis |
| Spawn subagent | Task tool | <task>Research X</task> |
| Create epic/tasks | cleo add | cleo add "Epic" --type epic |
2.4 Prohibited Orchestrator Actions
The orchestrator MUST NOT perform these actions:| Prohibited Action | Why | Delegate To |
|---|---|---|
| Read full research files | Token explosion | Subagent with targeted Read |
| Implement code changes | Context pollution | Coder subagent |
| Run tests | Specialized knowledge | Testing subagent |
| Write documentation | Detailed work | Docs subagent |
| Merge/commit code | HITL gate | Human or authorized agent |
Part 3: Subagent Protocol
3.1 Subagent Injection Block
Every research subagent prompt MUST include this instruction block:3.2 Subagent Workflow
3.3 Subagent Return Contract
| Requirement | Rule Level | Validation |
|---|---|---|
| Output file exists | MUST | test -f <path> |
| Manifest entry appended | MUST | grep <id> MANIFEST.jsonl |
| Response is completion message only | MUST | String match |
| Task completed in CLEO | SHOULD | cleo show <id> status=done |
| Research linked to task | SHOULD | Task notes contain research ID |
Part 4: Session Startup Protocol
4.1 Every New Conversation
When a new conversation starts, the orchestrator MUST execute this startup sequence:4.2 Decision Matrix
Based on startup checks, orchestrator MUST take one of these actions:| Condition | Action |
|---|---|
| Active session exists with focus | Resume session; continue from focused task |
| Active session exists, no focus | Query manifest for needs_followup; spawn next agent |
| No active session, manifest has followup | Create session; spawn agent for first followup task |
| No active session, no manifest followup | Ask user for direction |
4.3 Session Resume Flow
Part 5: Manifest Schema
5.1 Required Fields
| Field | Type | Required | Constraint | Purpose |
|---|---|---|---|---|
id | string | MUST | Unique slug with date | Lookup key |
file | string | MUST | Matches output filename | File reference |
title | string | MUST | Human-readable | Display name |
date | string | MUST | ISO 8601 (YYYY-MM-DD) | Temporal ordering |
status | enum | MUST | complete|partial|blocked | Progress tracking |
topics | array | MUST | 1+ string items | Categorization |
key_findings | array | MUST | 3-7 string items | Executive summary |
actionable | boolean | MUST | true/false | Requires action? |
needs_followup | array | MUST | Task IDs or empty | Handoff coordination |
5.2 Optional Fields
| Field | Type | Purpose |
|---|---|---|
timestamp | string | ISO 8601 datetime for precise ordering |
linked_tasks | array | CLEO task IDs this research relates to |
agent_type | string | Subagent role identifier (see 5.2.1) |
tokens_spent | number | Token usage estimate (informational only) |
5.2.1 agent_type Field
Theagent_type field categorizes subagent output by role, enabling filtering and analysis of research by agent specialization.
| Value | Description | Use Case |
|---|---|---|
research | Default. Investigative/exploratory work | Topic research, competitive analysis |
implementation | Code implementation tasks | Feature development, bug fixes |
validation | Testing and verification | Test writing, compliance checks |
documentation | Documentation creation | Docs writing, README updates |
analysis | Technical analysis | Architecture review, code review |
agent_type MUST be one of the above values. If not present, defaults to "research".
Filtering by agent_type:
agent_type in their manifest entries to enable orchestrators and users to filter research by work type.
5.3 needs_followup Semantics
Theneeds_followup array is the primary handoff mechanism:
| Value | Meaning | Orchestrator Action |
|---|---|---|
Empty array [] | No downstream work | Move to next independent task |
Task IDs ["T1234"] | Specific tasks ready | Spawn agents for listed tasks |
["BLOCKED:<reason>"] | Work blocked | Flag for human review |
5.4 Manifest Query Patterns
Orchestrator SHOULD use these jq patterns for manifest queries:Part 6: Task Linking Protocol
6.1 Research-to-Task Linking
When research relates to a CLEO task, subagents SHOULD establish the link: Method 1: CLEO research link command6.2 Bidirectional Traceability
| Direction | Storage | Query |
|---|---|---|
| Task → Research | Task notes field | cleo show <task-id> |
| Research → Task | Manifest linked_tasks | jq 'select(.linked_tasks)' MANIFEST.jsonl |
6.3 Link Timing
| Event | Link Action |
|---|---|
| Subagent starts task | Focus task; no link yet |
| Research complete | Add task to manifest linked_tasks |
| Task complete | Add research ID to task notes |
Part 7: Dependency Resolution
7.1 Dependency Order Enforcement
Orchestrator MUST spawn agents in dependency order:7.2 Parallel Spawn Rules
| Rule | Constraint |
|---|---|
| Parallel OK | Tasks in same wave with no inter-dependencies |
| Serial REQUIRED | Task depends on another in same or later wave |
| Overlap PROHIBITED | Same task claimed by multiple agents |
7.3 Spawn Decision
Part 8: Error Handling
8.1 Subagent Failure Modes
| Failure | Detection | Recovery |
|---|---|---|
| No output file | test -f <path> fails | Re-spawn with clearer instructions |
| No manifest entry | grep <id> fails | Manual entry or rebuild |
| Wrong return message | String mismatch | Accept but log warning |
| Task not completed | Status != done | Orchestrator completes manually |
| Partial status | status: partial | Spawn continuation agent |
| Blocked status | status: blocked | Flag for human review |
8.2 Orchestrator Recovery
8.3 Session Recovery
Part 9: Context Protection
9.1 Token Budget Allocation
| Component | Max Tokens | Strategy |
|---|---|---|
| Orchestrator context | 10K | Manifest summaries only |
| Subagent prompt | 4K | Task description + injection block |
| Subagent research | 50K | Full file reading permitted |
| Return message | 100 | Fixed completion message |
9.2 Context Protection Rules
| Rule ID | Constraint |
|---|---|
| CTX-001 | Orchestrator MUST NOT read research files > 100 lines |
| CTX-002 | Orchestrator MUST use cleo research list over raw manifest read |
| CTX-003 | Orchestrator MUST use cleo show --brief for task summaries |
| CTX-004 | Subagent MUST NOT return content in response message |
| CTX-005 | Manifest key_findings MUST be 3-7 items, one sentence each |
9.3 Context-Driven Pause Protocol
The orchestrator MUST implement context-driven pausing to prevent context overflow and ensure graceful session handoffs.9.3.1 Context Thresholds
| Threshold | Percentage | Status | Action |
|---|---|---|---|
| OK | 0-69% | ok | Continue orchestration |
| Warning | 70-79% | warning | Wrap up current work, spawn final subagents |
| Critical | 80-100% | critical | STOP immediately, generate HITL summary |
9.3.2 Pre-Spawn Context Check
Before spawning any subagent, orchestrator MUST callorchestrator_should_pause():
9.3.3 Pre-Spawn Compliance Check
Before spawning the next agent, orchestrator MUST verify the previous agent’s compliance:- Context threshold: Not at critical level
- Task status: Target task is pending
- Previous compliance: Previous agent created manifest entry (if previous_task_id provided)
9.3.4 Protocol Injection Validation
All spawn prompts MUST contain the SUBAGENT PROTOCOL injection block. The orchestrator validates this viaorchestrator_verify_protocol_injection():
- ORC-006: MUST verify protocol injection before spawn
- E_PROTOCOL_MISSING (exit 60): Returned when marker not found
- Auto-fix available:
cleo research injectprovides the protocol block
9.3.5 Auto-Stop Procedure
When context reaches critical threshold withautoStopOnCritical: true:
- Generate HITL Summary: Progress, remaining tasks, resume command
- End Session: Clean session end with summary note
- Return Handoff: JSON with complete resume instructions
9.3.6 HITL Summary Format
Human-in-the-Loop summary provides complete context for resumption:Part 10: Integration Points
10.1 CLEO Commands for Orchestration
| Command | Purpose | When Used |
|---|---|---|
cleo session start --scope epic:T1575 | Begin orchestration | First agent spawn |
cleo focus set <id> | Mark active work | Subagent start |
cleo complete <id> | Mark task done | Subagent finish |
cleo research link <tid> <rid> | Link research to task | After research complete |
cleo analyze --parent <epic> | Find next work | Orchestrator planning |
cleo deps <id> | Check dependencies | Before spawn decision |
cleo research list | List research entries (context-efficient) | Manifest query |
cleo research list --type <type> | Filter by agent_type | Find specific research types |
cleo research show <id> | Get research entry details | Deep-dive on specific research |
cleo research pending | Get entries with needs_followup | Find next agent work |
cleo research links <task-id> | Get research linked to task | Traceability check |
cleo orchestrator should-pause | Check context threshold | Before each spawn |
cleo orchestrator pre-spawn-check | Combined pre-spawn validation | Before spawning next agent |
cleo orchestrator check-and-stop | Check and auto-stop if critical | Spawn decision point |
cleo research inject | Get protocol injection block | Building subagent prompts |
10.2 File Locations
| File | Purpose | Created By |
|---|---|---|
claudedocs/agent-outputs/ | Research output directory | cleo research init |
MANIFEST.jsonl | Research index | Subagents (append) |
SUBAGENT_PROTOCOL.md | Protocol reference | cleo research init |
INJECT.md | Copy-paste injection block | cleo research init |
10.3 Related Specifications
| Spec | Relationship |
|---|---|
| ORCHESTRATOR-SPEC.md | tmux-based multi-agent spawning |
| IMPLEMENTATION-ORCHESTRATION-SPEC.md | 7-agent implementation pipeline |
| MULTI-SESSION-SPEC.md | Session scope isolation |
| SUBAGENT_PROTOCOL.md | Research output format |
Part 11: Compliance Checklist
11.1 Orchestrator Compliance
Core Behavior (ORC-001 to ORC-005):- Never reads full research files (ORC-003)
- Always spawns in dependency order (ORC-004)
- Uses manifest for summaries (ORC-005)
- Delegates all implementation work (ORC-002)
- Executes session startup protocol
- Verifies protocol injection in spawn prompt (ORC-006)
- Checks context thresholds before spawn (ORC-007)
- Verifies previous agent compliance (ORC-008)
- Auto-stops at critical threshold (ORC-009)
| Function | Rule | Purpose |
|---|---|---|
orchestrator_verify_protocol_injection() | ORC-006 | Validates SUBAGENT PROTOCOL marker in prompt |
orchestrator_should_pause() | ORC-007, ORC-009 | Checks context percentage against thresholds |
orchestrator_verify_compliance() | ORC-008 | Verifies previous agent created manifest entry |
orchestrator_pre_spawn_check() | All | Combined validation before spawn |
11.2 Subagent Compliance
- Writes output file to correct path
- Appends manifest entry with all required fields
- Returns only completion message (no content in response)
- Sets focus before work (
cleo focus set <id>) - Completes task when done (
cleo complete <id>) - Sets needs_followup for handoff
- Sets agent_type appropriately (research|implementation|validation|documentation|analysis)
11.3 Manifest Compliance
- All required fields present (id, file, title, date, status, topics, key_findings, actionable, needs_followup)
- Status is valid enum value (complete|partial|blocked)
- key_findings is 3-7 items, one sentence each
- Date is ISO 8601 format (YYYY-MM-DD)
- needs_followup contains valid task IDs or BLOCKED: entries
- agent_type (if present) is valid enum value
11.4 Compliance Verification Gates
Pre-spawn compliance verification ensures the orchestration chain maintains integrity:Appendix A: Quick Reference
A.1 Orchestrator Mantra
A.2 Subagent Mantra
A.3 Manifest Query Cheatsheet
A.4 Pre-Spawn Check Cheatsheet
Appendix B: Revision History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-01-18 | Initial specification |
| 1.1.0 | 2026-01-26 | Added ORC-006 to ORC-009 enforcement rules; Context-driven pause protocol (9.3); agent_type field documentation (5.2.1); Compliance verification gates (11.4); Pre-spawn check functions |
Specification v1.1.0 - Orchestrator Protocol Epic: T1575 - Orchestrator Protocol Implementation Task: T2379 - Update Specification Documents
