Execution Modes
Relevant source files
The following files were used as context for generating this wiki page:
Execution modes in the opencode-swarm project define the operational state and level of autonomy for the multi-agent system. These modes dictate how the Architect orchestrates tasks, manages quality gates, and interacts with the user. They range from exploratory "brainstorming" to fully autonomous implementation phases.
The system uses a priority-based mode detection logic to determine the correct state of the swarm based on the existence of project files like .swarm/plan.md or .swarm/spec.md, and explicit user commands.
Sources: src/agents/architect.ts:805-820, src/hooks/system-enhancer.ts:1300-1310
Core Operational Modes
The Architect agent operates in several distinct modes to manage the lifecycle of a software development project.
Discovery and Planning Modes
- BRAINSTORM: A structured requirements discovery mode used when a problem is exploratory. It utilizes specific discovery protocols before committing to a specification.
- SPECIFY: Triggered when no specification exists. It focuses on producing a testable
.swarm/spec.mdwith numbered functional requirements (FR) and success criteria (SC). - PLAN: Activates to create or ingest an implementation plan. This mode uses the
save_plantool to structure phases and tasks. - DISCOVER: A pre-planning codebase scan where the Explorer agent identifies languages, frameworks, and existing patterns.
Sources: src/agents/architect.ts:833-858, src/agents/architect.ts:896-914
Implementation and Review Modes
- EXECUTE: The primary implementation mode where the Architect delegates tasks to the Coder agent, enforces quality gates, and manages retries.
- CRITIC-GATE: A mandatory safety mode that stops implementation until the Critic agent approves the plan.
- PHASE-WRAP: Activates at the end of a phase to run rescans, documentation updates, and capture retrospectives before marking a phase as complete.
Sources: src/agents/architect.ts:928-958
Workflow Mode Detection
The system evaluates the environment in a specific priority order to select the active mode.
The diagram shows the priority logic used to determine the Architect's operational mode.
Sources: src/agents/architect.ts:805-831
Autonomous and Advanced Modes
Beyond standard operational states, the system supports specialized high-autonomy and high-performance modes.
Full-Auto Mode
Full-Auto mode enables autonomous orchestration where the Critic serves as the sole quality gate (critic_oversight). In this mode, the system follows a strict "Constitution" that prioritizes rejection over acceptance unless positive evidence of correctness is provided.
| Feature | Description |
|---|---|
| Default Posture | Reject-first; requires positive evidence for approval. |
| Quality Gate | critic_oversight is the final authority. |
| Escalation | Technical questions are self-resolved; product decisions are escalated to humans. |
Sources: src/agents/critic.ts:474-510, src/hooks/system-enhancer.ts:1095-1100
Turbo and Lean-Turbo Modes
These modes are designed for high-speed execution. Turbo focuses on rapid orchestration, while Lean-Turbo utilizes specialized runners and planners to minimize overhead.
- Turbo Mode: Indicated by a specific system banner, it streamlines the delegation process.
- Lean-Turbo: Involves specific logic for acquiring locks and running phases with reduced agent chatter.
Sources: src/hooks/system-enhancer.ts:50-55, src/hooks/system-enhancer.ts:1145-1160
Implementation Pipeline (MODE: EXECUTE)
When in EXECUTE mode, the Architect follows a tiered QA pipeline based on the risk classification of the changes.
The sequence shows the standard implementation and QA gate flow in EXECUTE mode.
Sources: src/agents/architect.ts:326-380, src/agents/architect.ts:934-950
Change Tiers and Pipelines
The pipeline depth is determined by the "Tier" classification of the task:
- TIER 0 (Metadata): Plan/Context changes. Only requires lint + diff.
- TIER 1 (Docs): Documentation changes. Stage A + 1 Reviewer.
- TIER 2 (Standard): src/ files. Stage A + Reviewer + Test Engineer.
- TIER 3 (Critical): Security-sensitive files. Stage A + 2 Reviewers + 2 Test Engineers (Adversarial).
Sources: src/agents/architect.ts:326-350
Specialized Agent Modes
Agents themselves can switch into specific sub-modes depending on the Architect's delegation:
Explorer Modes
- Integration Impact Analysis: Activates when contract changes are detected. Analyzes breaking changes and affected consumers.
- Documentation Discovery: Automatically indexes project documentation (README, CONTRIBUTING, etc.) into constraints.
- Curator Mode: Consolidates session knowledge into briefings or phase digests.
Sources: src/agents/explorer.ts:60-120, src/agents/explorer.ts:140-160
Critic Modes
- Sounding Board: A pre-escalation filter that provides honest pushback on Architect reasoning.
- Phase Drift Verifier: Independently verifies implementation against the original plan.
- Hallucination Verifier: Checks for fabricated APIs or unsupported claims.
Sources: src/agents/critic.ts:215-230, src/agents/critic.ts:320-350
Conclusion
Execution modes provide the structural framework for the opencode-swarm's multi-agent coordination. By transitioning through discovery, planning, and execution phases—and enforcing rigorous QA tiers—the system ensures that autonomous code generation remains aligned with project specifications and security constraints.
Sources: src/agents/architect.ts:25-50, src/agents/architect.ts:950-960