Ralph Orchestrator Documentation
repository·main·Indexed 25 days ago
https://github.com/mikeyobrien/ralph-orchestratorA hat-based orchestration framework implementing the 'Ralph Wiggum technique' for autonomous task completion via continuous iteration. It features specialized personas (hats), backpressure gates, and a Rust-native bootstrap runtime (ralph-api) for RPC v1 control. The system includes an E2E test harness (ralph-e2e) with cassette-based deterministic testing, a Telegram integration for human-in-the-loop interaction, and an MCP server for workspace management.
What's inside Ralph Orchestrator
- Ralph's event system serves as the communication backbone for hat orchestration. It allows agents to emit signals that trigger hat switches and backpressure mechanisms throughout the orchestration lifecycle.
Overview of Ralph Orchestrator Agent Skills
mainThe
skills/directory provides a canonical public skill package for external agent harnesses to operate Ralph. It includes three distinct skills:ralph-hats: Used for creating, inspecting, validating, and improving hat collections.ralph-loop: Used for running, monitoring, resuming, merging, and debugging Ralph loops.ralph-docs: Used for introspecting and improving Ralph via the publishedllms.txtdoc map. This skill helps answer questions about Ralph's implementation and scopes code changes within theralph-orchestratorrepository.
Note: These are public agent skills and are separate from Ralph's internal
ralph tools skillregistry.Overview of Ralph Orchestrator Architecture
mainRalph Orchestrator is a multi-agent orchestration framework for AI coding assistants (such as Claude, Kiro, Gemini, and others) that uses an event-driven loop. It coordinates agents through "hats" (personas) that communicate via a pub/sub event bus with topic-based routing.
Core Components
- User Interfaces:
ralph-cli(CLI),ralph-tui(Terminal UI), Web Dashboard (React), andralph-telegram(Telegram Bot). - API Layer:
ralph-api(Axum REST/WS) and@ralph-web/server(Fastify + tRPC). - Core Engine:
ralph-core(Orchestration logic) andralph-proto(Protocol types). - Agent Backends:
ralph-adapterswhich integrates various AI backends.
- User Interfaces:
Overview of Prompt-Driven Development (PDD)
mainPrompt-Driven Development (PDD) is a methodology used to transform a rough idea into a detailed design document, an implementation plan, and a todo list. The process is iterative and involves refining requirements, conducting research, creating comprehensive designs, and developing actionable implementation plans.Overview of ralph-cli commands
mainThe
ralph-clibinary serves as the main entry point for the Ralph Orchestrator. It handles argument parsing, command routing, and runtime logging configuration.Available top-level commands include:
run,preflight,hooks,doctor,tutorial,events,init,clean,emit,plan,code-task(aliastask),tools,loops,hats,tui,web,mcp,bot,completions.
Overview of Ralph crates
mainRalph is composed of several specialized crates. Use the following guide to identify which crate meets your needs:
ralph-proto: Provides core protocol types includingEvent,Hat, andTopic.ralph-core: Contains the orchestration engine, includingEventLoopandConfig.ralph-adapters: Provides backend integrations and CLI backends.ralph-tui: Provides Terminal UI components (Experimental).ralph-cli: The primary binary entry point for CLI commands.
Overview of Ralph Orchestrator Features
mainRalph provides several core capabilities for AI orchestration:
- Multi-Backend Support: Integrates with Claude Code, Kiro, Gemini CLI, Codex, Forge, Amp, Copilot CLI, and OpenCode.
- Hat System: Uses specialized personas with distinct behaviors that communicate via typed events.
- Backpressure Enforcement: Uses gates (such as tests, linting, or typechecking) to reject incomplete or incorrect work.
- Memories & Tasks: Provides persistent learning across sessions and tracks runtime work.
- Interactive TUI: Includes a real-time terminal user interface for monitoring activity.
- Presets: Includes 31 built-in workflows and a catalog of examples.
Overview of ralph-api
mainTheralph-apicrate is a Rust-native bootstrap runtime for the RPC v1 control plane. It provides the core communication layer for the Ralph Orchestrator, including HTTP and WebSocket endpoints, authentication abstractions, and idempotency primitives for mutating methods.Understand Agent Waves for parallel execution
mainAgent Waves provide a mechanism for intra-loop parallelism within Ralph's orchestration loop. Instead of executing hats sequentially, a dispatcher hat can fan out work to multiple concurrent backend instances (workers), collect their results, and aggregate them in a single orchestration run.
Key Use Cases:
- Deep research (parallel topic exploration)
- Multi-perspective analysis
- Parallel code review
- Scatter-gather patterns
- Multi-agent debate patterns
Core Primitives:
- Wave-aware event emission: Events are tagged with correlation metadata (
wave_id,wave_index,wave_total). - Concurrent hat execution: The loop runner spawns multiple backend processes in parallel.
- Aggregator gate: A specific hat that buffers results and activates only once all correlated results have arrived.
Explore the Orchestrator API Reference
mainThe
ralph_orchestratormodule provides the core orchestration capabilities. For detailed information on specific components, refer to the following API documentation sections:- Configuration API: Manage orchestrator settings and parameters.
- Agent API: Control and configure different agent types.
- Metrics API: Access performance and operational metrics.
- CLI Reference: Command-line interface usage and flags.
Understand the scope of Agent Waves v1
mainAgent Waves v1 provides a framework for concurrent execution and event correlation.
Included in v1:
- Wave CLI tools: Commands for managing waves via
ralph wave start,ralph wave emit, andralph wave end. - Event correlation metadata: Every event includes
wave_id,wave_index, andwave_totalfor tracking. - Concurrent execution: Backend spawning in the loop runner respects a defined
concurrencylimit. - Aggregation: Supports
aggregate.mode: wait_for_allwith a specified timeout. - Context injection: Downstream hat descriptions are injected into prompts for Natural Language (NL) dispatch.
- Failure handling: Implements best-effort failure handling.
- Accounting: Provides per-instance activation and cost accounting.
- Workspace: Uses a shared workspace (no isolation).
- Constraints: Does not support nested waves.
Deferred to v2+:
- Worktree isolation (
isolation: worktree) - Nested waves
- Additional aggregation modes (
first_n,quorum,external_event) - Configurable failure modes (
on_failure: fail_fast) - Wave-level cost limits (
max_wave_cost) - Dedicated aggregator backends
- Multi-round debate optimization
- Wave CLI tools: Commands for managing waves via
Understand the Ralph Wiggum Technique
mainThe Ralph Wiggum technique is an approach to autonomous AI task completion based on continuous iteration. Instead of directing an AI through step-by-step instructions, you define success criteria upfront and allow the AI to iterate in a loop until those criteria are met.
Core Principles
- Fresh Context Each Iteration: Each cycle starts with a clean slate, re-reading the prompt and codebase to prevent getting stuck in local minima.
- Disk Is State: The only persistent state used by the agent is what is written to disk (e.g.,
PROMPT.md, the codebase, Git history, and.ralph/agent/memories.md). - Eventual Consistency: The technique relies on the idea that given enough iterations, a solution will emerge for any achievable task.
- Predictable Failure Modes: Failures occur through observable limits such as iteration count, cost, time, or loop detection (repetitive outputs).
When to Use
- Recommended for: Large refactors, migrations, batch operations (docs, tests), greenfield scaffolding, and tasks with well-defined completion criteria.
- Avoid for: Ambiguous requirements, tasks requiring human judgment, security-sensitive code, or exploratory work.