Introduction to Longshot
Longshot is a massively parallel autonomous coding system that takes natural-language build requests and transforms them into working code. It decomposes any project into hundreds of granular tasks and executes them simultaneously in isolated cloud sandboxes.Architecture
Understand the system components and how they work together
How it works
Learn the execution flow from request to completion
Installation
Get started with Longshot CLI installation
Configuration
Configure LLM endpoints, workers, and sandboxes
What makes Longshot different
Longshot is designed for massive parallelism and stateless execution. Unlike traditional coding agents that work sequentially, Longshot:- Decomposes intelligently: A root planner breaks requests into granular tasks, with subplanners handling complex scopes recursively (up to 3 levels deep)
- Executes in parallel: Runs up to 50 workers simultaneously, each in an isolated Modal sandbox with its own repository clone
- Stays stateless: Workers are ephemeral, state lives only in Git, and the orchestrator runs locally while execution happens in the cloud
- Self-heals: A reconciler monitors build health and automatically spawns fix tasks when tests break or conflicts arise
Core capabilities
Parallel task execution
- Full repository clone
- Independent file system
- Dedicated LLM session
- Automatic branch management
Intelligent decomposition
The system uses a three-tier planning hierarchy:- Root Planner: Analyzes the build request and creates high-level tasks based on
SPEC.md,FEATURES.json, and current repository state - Subplanners: Decompose tasks with large scopes (4+ files) into smaller subtasks, up to 3 levels deep
- Workers: Execute atomic tasks in isolated sandboxes using the Pi coding agent
Scope-based routing: Tasks with fewer than 4 files go directly to workers. Larger tasks are automatically routed through subplanners for decomposition.
Self-healing reconciliation
A background reconciler continuously monitors main branch health:Merge queue with conflict handling
Branches flow through a serial merge queue with:- Priority ordering: Fix tasks (priority 1) merge before feature tasks (priority 5)
- Automatic rebasing: Failed merges trigger automatic rebase + retry (up to 2 attempts)
- Conflict resolution: After retries exhausted, creates a conflict-fix task with detailed instructions
Example workflow
Here’s how Longshot handles a typical build request:Root planner analyzes
Reads
SPEC.md, examines repository structure, and creates initial tasks:task-001: Set up Express server with TypeScripttask-002: Implement JWT authentication middlewaretask-003: Create user registration endpointtask-004: Create todo CRUD endpoints (scope: 5 files)task-005: Add API integration tests
Tasks dispatch to workers
- Tasks 1-3, 5 → Direct to workers (small scope)
- Task 4 → Routes to subplanner (5 files exceeds threshold)
- Subplanner decomposes into:
task-004-sub-1,task-004-sub-2, etc. - Each subtask dispatches to a worker
- Subplanner decomposes into:
Workers complete and push branches
Each worker:
- Clones the target repository
- Creates a task-specific branch
- Uses Pi agent to implement changes
- Commits and pushes the branch
- Returns a handoff report with diff, concerns, and metrics
Reconciler ensures health
After merges, reconciler runs:If failures detected → creates
fix-001 task with high priorityKey design principles
Ephemeral workers
Workers are completely stateless:Git as source of truth
All state lives in Git:- Repository structure defines current state
- Branches represent in-progress work
- Commits create an audit trail
- Main branch is the single source of truth
Continuous conversation planning
The root planner maintains a continuous LLM session:System requirements
For end users (CLI):
- Python 3.12+
- Node.js 22+ (downloaded automatically by CLI)
- Modal account (for cloud sandboxes)
- LLM API endpoint (OpenAI-compatible)
- Node.js 22+
- pnpm
- Python 3.12+
- uv
- Modal CLI (
modal setup)
Next steps
Architecture deep dive
Explore the technical architecture and component interactions
Execution flow
Follow a request through the entire system lifecycle