Overview
CLEO implements a 2-tier universal subagent architecture for multi-agent coordination:cleo-subagent) with context-specific protocols - NOT skill-specific agents.
Protocol Constraints (RFC 2119)
The subagent protocol defines mandatory and recommended rules following RFC 2119 keywords (MUST, MUST NOT, SHOULD, MAY).BASE-001
MUST append ONE line to MANIFEST.jsonlRequired - Single-line JSON entry enables O(1) lookup
BASE-002
MUST NOT return content in responseRequired - Preserves orchestrator context window
BASE-003
MUST complete task via
cleo completeRequired - Updates task status and audit trailBASE-004
MUST write output file before manifestRequired - Ensures manifest references valid file
BASE-005
MUST set focus before starting workRequired - Signals active task for tracking
BASE-006
MUST NOT fabricate informationRequired - Anti-hallucination requirement
BASE-007
SHOULD link research to taskRecommended - Enables bidirectional discovery
Rationale
| Constraint | Purpose |
|---|---|
| BASE-001 | Manifest enables O(1) lookup of key findings without reading full files |
| BASE-002 | Full content would bloat orchestrator context window (10K token budget) |
| BASE-003 | Task completion updates status, logs to audit trail, triggers hooks |
| BASE-004 | Prevents manifest pointing to missing/incomplete file |
| BASE-005 | Focus tracking enables session state and context alerts |
| BASE-006 | Partial/blocked status preferred over fabricated content |
| BASE-007 | Research links create bidirectional graph for future agents |
Lifecycle Phases
The subagent follows a strict 5-phase lifecycle:SPAWN
Orchestrator invokes Task tool with:
- Fully-resolved prompt (no
@references or{{TOKENS}}) subagent_type: "cleo-subagent"- Pre-validated task existence
INJECT
Subagent receives:
- Base protocol (lifecycle, constraints, output format)
- Conditional protocol (skill-specific requirements)
- Task context (ID, epic, acceptance criteria)
EXECUTE
Follow skill-specific instructions:
- Read task:
cleo show {{TASK_ID}} - Set focus:
cleo focus set {{TASK_ID}} - Perform work (research, implementation, specification, etc.)
OUTPUT
Write deliverables:
- Output file:
{{OUTPUT_DIR}}/{{TASK_ID}}-<slug>.<ext> - Manifest entry: Single-line JSON to
{{MANIFEST_PATH}} - Complete task:
cleo complete {{TASK_ID}} - Link research (optional):
cleo research link {{TASK_ID}} <id>
Execution Sequence
Token System
Pre-Resolution Requirement
Subagents receive fully-resolved prompts with all tokens substituted.Standard Tokens
| Token | Description | Example |
|---|---|---|
{{TASK_ID}} | Current task identifier | T2402 |
{{EPIC_ID}} | Parent epic identifier | T2392 |
{{DATE}} | Current date (ISO format) | 2026-01-26 |
{{TOPIC_SLUG}} | URL-safe topic name | authentication-research |
{{OUTPUT_DIR}} | Output directory path | claudedocs/agent-outputs |
{{MANIFEST_PATH}} | Manifest file path | claudedocs/agent-outputs/MANIFEST.jsonl |
Task Context Tokens
| Token | Source Field | Example |
|---|---|---|
{{TASK_TITLE}} | task.title | ”Implement user authentication” |
{{TASK_DESCRIPTION}} | task.description | ”Add JWT-based auth system…” |
{{TOPICS_JSON}} | task.labels | ["auth", "security"] |
{{DEPENDS_LIST}} | task.depends | ”T2398, T2401” |
{{ACCEPTANCE_CRITERIA}} | Parsed from description | ”- [ ] Login endpoint\n- [ ] Token refresh” |
Command Tokens (CLEO Defaults)
| Token | CLEO Default | Purpose |
|---|---|---|
{{TASK_SHOW_CMD}} | cleo show | Read task details |
{{TASK_FOCUS_CMD}} | cleo focus set | Set active task |
{{TASK_COMPLETE_CMD}} | cleo complete | Mark task complete |
{{TASK_LINK_CMD}} | cleo research link | Link research to task |
Token Types
| Type | Syntax | Resolution | Example |
|---|---|---|---|
| File reference | @file.md | Read and inline | @docs/guide.md |
| Glob pattern | @dir/*.md | Glob, read, concat | @protocols/*.md |
| Placeholder | {{VAR}} | Substitute value | {{TASK_ID}} |
| Environment | ${ENV} | Environment variable | ${HOME} |
| Command | !`cmd` | Execute and inline | !`date +%Y-%m-%d` |
Output Requirements
File Naming Convention
claudedocs/agent-outputs/T2402-cleo-subagent-base.mddocs/specs/T2398-protocol-spec.mddocs/designs/T2400-skill-loading.md
Output File Structure
Manifest Entry Format
Required Fields
| Field | Type | Description | Example |
|---|---|---|---|
id | string | Unique entry ID (T####-slug format) | "T2402-protocol" |
file | string | Relative path from manifest directory | "T2402-protocol.md" |
title | string | Human-readable title | "CLEO Subagent Protocol" |
date | string | ISO date (YYYY-MM-DD) | "2026-01-26" |
status | enum | complete, partial, blocked | "complete" |
agent_type | string | Agent category | "research", "implementation", "specification" |
Optional Fields
| Field | Type | Default | Description |
|---|---|---|---|
topics | array | [] | Categorization tags |
key_findings | array | [] | 3-7 one-sentence findings |
actionable | boolean | true | Whether findings require action |
needs_followup | array | [] | Task IDs requiring attention |
linked_tasks | array | [] | Related task IDs |
Key Findings Guidelines
Key findings should be:
- 3-7 items maximum (keep manifest compact)
- One sentence each (no paragraphs)
- Action-oriented (what was learned/decided/built)
- No implementation details (those go in output file)
Return Messages
| Agent Type | Status | Message |
|---|---|---|
| Research | Complete | Research complete. See MANIFEST.jsonl for summary. |
| Research | Partial | Research partial. See MANIFEST.jsonl for details. |
| Research | Blocked | Research blocked. See MANIFEST.jsonl for blocker details. |
| Implementation | Complete | Implementation complete. See MANIFEST.jsonl for summary. |
| Specification | Complete | Specification complete. See MANIFEST.jsonl for summary. |
| Design | Complete | Design complete. See MANIFEST.jsonl for summary. |
| Analysis | Complete | Analysis complete. See MANIFEST.jsonl for summary. |
Error Handling
Status Classification
- Complete
- Partial
- Blocked
Condition: All objectives achievedManifest:Actions:
- Write output file with full content
- Append manifest entry
- Complete task via
cleo complete - Return success message
Partial Completion Protocol
When unable to complete all objectives:
Example Partial Manifest:
Retryable Errors
Exit codes 7, 20, 21, 22, 60-63 are retryable with exponential backoff:Blocker Categories
| Category | Example | Action |
|---|---|---|
| Missing context | Required file not provided | Request from orchestrator |
| Permission denied | Tool not allowed | Escalate |
| Resource unavailable | External service down | Retry with backoff |
| Ambiguous requirements | Conflicting instructions | Clarify before proceeding |
Skill Loading Mechanism
Key Principle
Skills are context injections, NOT agents. The orchestrator selects and injects skill content - subagents cannot load skills themselves.
Protocol Stack Architecture
Every spawn combines two layers:Base Protocol
Loaded for ALL subagents:- Lifecycle phases (SPAWN → INJECT → EXECUTE → OUTPUT → RETURN)
- Output requirements (file + manifest)
- RFC 2119 constraints (BASE-001 through BASE-007)
- Error handling patterns
skills/_shared/subagent-protocol-base.md
Conditional Protocols (7 Types)
Research
Keywords: research, investigate, exploreInformation gathering and analysis
Consensus
Keywords: vote, validate, decideMulti-agent decision making
Specification
Keywords: spec, rfc, designDocument creation with RFC 2119
Decomposition
Keywords: epic, plan, decomposeTask breakdown and planning
Implementation
Keywords: implement, build, createCode execution and testing
Contribution
Keywords: PR, merge, sharedWork attribution and commits
Release
Keywords: release, version, publishVersion management and deployment
Dispatch Pipeline
The orchestrator selects protocols usinglib/skill-dispatch.sh:
Dispatch Priority
- Label-based: Task labels match skill tags
- Type-based: Task type maps to protocol
- Keyword-based: Title/description matches dispatch triggers
- Fallback:
ct-task-executor(default)
Loading Strategies
| Strategy | Content Loaded | Token Budget | Use Case |
|---|---|---|---|
| Minimal | Frontmatter + first 50 lines | ~500 tokens | Simple tasks, tight context |
| Standard | Full SKILL.md | ~2-5K tokens | Most tasks (default) |
| Comprehensive | SKILL.md + references/ | ~5-15K tokens | Complex multi-step tasks |
Anti-Patterns
Subagent Anti-Patterns
Returning Content in Response
Returning Content in Response
Problem: Bloats orchestrator context window (10K budget)Solution: Return ONLY summary message, content in fileBad:Good:
Pretty-Printed JSON in Manifest
Pretty-Printed JSON in Manifest
Problem: Multiple lines break manifest parsingSolution: Single-line JSON with no formattingBad:Good:
Loading Skills via @ References
Loading Skills via @ References
Problem: Subagents cannot resolve Good:
Orchestrator pre-resolves and inlines skill content
@ patternsSolution: Skills injected by orchestrator (fully resolved)Bad:Skipping Focus
Skipping Focus
Problem: Violates BASE-005, breaks session trackingSolution: Always Good:
cleo focus set before workBad:Orchestrator Anti-Patterns
| Pattern | Problem | Solution |
|---|---|---|
| Reading full files | Context bloat | Read manifest summaries only |
| Implementing code | Role violation | Delegate to cleo-subagent |
| Parallel spawns | Race conditions | Sequential per dependency wave |
| Unresolved tokens | Subagent failure | Verify tokenResolution.fullyResolved |
Completion Checklist
Before returning, verify all requirements:Output File Written
Output file written to
{{OUTPUT_DIR}}/{{TASK_ID}}-<slug>.<ext>Verifies BASE-004 complianceManifest Entry Appended
Single-line JSON entry appended to
{{MANIFEST_PATH}}Verifies BASE-001 complianceQuick Reference
Subagent Lifecycle Commands
Orchestrator Commands
Return Message Templates
| Type | Template |
|---|---|
| Research | Research complete. See MANIFEST.jsonl for summary. |
| Implementation | Implementation complete. See MANIFEST.jsonl for summary. |
| Specification | Specification complete. See MANIFEST.jsonl for summary. |
| Design | Design complete. See MANIFEST.jsonl for summary. |
| Analysis | Analysis complete. See MANIFEST.jsonl for summary. |
Related Documentation
Project Lifecycle
RCSD-IVTR pipeline specification
Protocol Stack
Base + conditional protocol architecture
RCSD Pipeline
Research → Consensus → Spec → Decompose
Orchestrator Skill
Tier 0 orchestrator protocol
Version History
| Version | Date | Changes |
|---|---|---|
| 1.0.0 | 2026-01-26 | Initial protocol specification |
