Agent Orchestration Strategy
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Agent Orchestration Strategy in Continuous Claude is designed to maintain high-fidelity context across long-running development sessions by utilizing a "Clear instead of Compact" approach. Traditional context compaction is often lossy; this system replaces it with a structured lifecycle where session state is preserved in external markdown ledgers, the context window is wiped clean, and then reloaded from the ledger to continue work with full fidelity.
The strategy employs a dual-mode Model Context Protocol (MCP) pattern that prioritizes reusable, agent-agnostic scripts over direct script writing. This minimizes token overhead—achieving up to a 99.6% reduction—and allows for specialized sub-agents to handle specific phases of development, such as exploration, planning, and implementation.
Sources: CLAUDE_ONBOARDING.md:10-23, CLAUDE.md:6-12
Hierarchical Agent Execution
Continuous Claude uses a tiered approach to task execution based on complexity. Simple tasks involve direct MCP tool calls, while complex workflows (>2 tools) utilize the Scripts-Based Execution framework.
Sub-Agent Spawning
For specialized tasks, the system spawns sub-agents. A primary example is the codebase-explorer sub-agent, which is invoked for token-efficient codebase exploration using tools like repomix to generate compressed code structures.
Sources: CLAUDE.md:28-30, CLAUDE_ONBOARDING.md:44-46
Operational Intelligence Flow
The following diagram illustrates the decision logic an agent follows when determining how to execute a request:
The flow ensures that agents do not reinvent workflows but rather discover and parameterize existing ones.
Sources: scripts/SCRIPTS.md:18-27, CLAUDE.md:37-47
Session Lifecycle and Continuity
Orchestration is centered around the management of session context limits. When context reaches a 70%+ threshold, the agent must transition states to avoid lossy compaction.
Lifecycle Phases
- Session Start: The agent auto-loads the current ledger (
CONTINUITY_CLAUDE-*.md). - Active Work: The agent executes plans and updates implementation status.
- Threshold Management: At 70%+ context, the agent invokes
/continuity_ledgerto save the "Now", "Next", and "Done" states. - Clear & Resume: The agent issues
/clearto reset the environment and re-loads the ledger to resume.
Sources: CLAUDE_ONBOARDING.md:33-36, CLAUDE_ONBOARDING.md:120-125
State Tracking Components
| Component | Persistence | Purpose |
|---|---|---|
CONTINUITY_CLAUDE-*.md | Ephemeral | Active session state, overwritten each update. |
thoughts/handoff/*.md | Permanent | Cross-session handoffs for transitioning between major tasks. |
thoughts/shared/plans/*.md | Permanent | Implementation plans to guide sub-agent execution. |
artifact-index/context.db | Local/Permanent | SQLite database indexing all plans and handoffs for RAG-enhanced retrieval. |
Sources: CLAUDE_ONBOARDING.md:25-31, scripts/artifact_index.py:27-38
RAG-Enhanced Review and Analysis
The orchestration strategy includes a feedback loop where implementation is reviewed against original plans. This is facilitated by the braintrust_analyze.py script and the Context Graph.
Implementation Review Logic
Agents utilize an "LLM-as-Judge" pattern to compare the git diff of a session against the thoughts/shared/plans/ document. The verdict is based on identifying P0 gaps—missing requirements that must be addressed before a handoff is considered valid.
This diagram shows how RAG is used to inform implementation reviews using past performance data stored in the local SQLite database.
Sources: scripts/braintrust_analyze.py:465-515, scripts/braintrust_analyze.py:590-630
Script and Skill Integration
Orchestration relies on the distinction between Scripts (CLI-based Python workflows) and Skills (Claude Code native format).
- Scripts: Reusable templates located in
./scripts/that accept CLI arguments. They provide a 99.6% token reduction by avoiding the need for the agent to write custom logic from scratch. - Skills: Native
.claude/skills/directories that reference these scripts, allowing Claude Code to auto-discover capabilities.
Script Execution Pattern
# The standard harness for executing MCP orchestration logic
uv run python -m runtime.harness scripts/multi_tool_pipeline.py \
--repo-path "." \
--max-commits 5
Sources: scripts/README.md:10-25, CLAUDE.md:123-130
Conclusion
The Agent Orchestration Strategy emphasizes externalizing state and automating repetitive workflows through a script-first architecture. By enforcing strict lifecycle stages—Plan, Research, Implement, Validate, and Commit—Continuous Claude ensures that agents remain focused and efficient even as project complexity grows, while the Context Graph provides the necessary "memory" to avoid repeating past implementation failures.
Sources: CLAUDE_ONBOARDING.md:102-118, scripts/braintrust_analyze.py:640-655