A tool protocol, agent runtime, and coding harness for principled agent concurrency.
Infinity is an ecosystem for building AI agents that can wait for things, work in parallel, and cost nothing when idle. It consists of three layers:
- Reactive Agent Protocol (RAP): An async tool protocol with native support for subscriptions, long-running operations, and agent hibernation.
- Infinity Runtime: A time-sliced agent runtime that processes work in short bursts and releases resources between them, whether deployed as a serverless function or running as a local daemon.
- Infinity Code: A coding agent built on the runtime, with sandboxed editing, durable concurrent threads, and background sessions.
RAP replaces MCP's synchronous request/response model with fire-and-forget tool calls. The agent invokes a tool via HTTP, the tool acknowledges immediately, and the agent shuts down. When the tool finishes (100ms or 3 days later) it POSTs the result to a callback URL and the agent wakes up.
This enables:
- Subscriptions: Tools register ongoing event streams (GitHub webhooks, price alerts, Slack messages). Each event wakes the agent, which processes it and goes back to sleep.
- Long-running operations: A CI pipeline or deployment takes 20 minutes? The agent hibernates at zero cost and resumes when it completes.
- MCP compatibility: Any MCP server works through a proxy layer. You keep the full MCP ecosystem and gain async execution for tools that need it.
The Infinity Runtime is stateless and ephemeral. Each execution slice follows a three-phase cycle:
- Load: Restore conversation history and state from durable storage.
- Complete: Run the LLM, stream the response, collect tool calls.
- Dispatch & Exit: Fire off tool calls via HTTP, persist state, shut down.
Nothing runs between slices. An agent waiting for a 3-day CI pipeline costs exactly the same as one that was never created. In the cloud, the process literally exits. Locally, it idles on a channel at zero CPU. Multiple agents share compute because they're never all active simultaneously; work is serialized through FIFO queues.
Agents can spawn child threads for parallel work. Each thread has its own conversation context, message stream, and lifecycle:
- Threads inherit the parent's history up to the spawn point, then diverge.
- Children report results back via message passing. The parent sees reports as synthetic events without its context being polluted.
- Subscription events are automatically routed to isolated child threads for processing.
- Threads are durable: they survive restarts, process interruptions, and cold starts.
This enables patterns like parallel code review (one thread per file), research-while-implementing, and long-running event processing, all with proper context isolation.
Prerequisites: Rust, Ripgrep (brew install ripgrep), Jujutsu (optional, brew install jj).
# Install the CLI
cargo install infinity-agent-cli --git https://github.com/hydro-project/infinity --features bundled-web
# Install the local sandbox RAP server
infinity rap install --user --git https://github.com/hydro-project/infinity --crate sandbox-local
# Run it in any repo
cd your-repo
infinityTo update: infinity update
See the Getting Started guide for a walkthrough of running a RAP agent locally with a custom tool server.
The cloud runtime deploys to AWS Lambda via CDK. Agents persist state to Aurora DSQL, route messages through SQS FIFO, and hibernate at true zero compute. See Cloud Deployment.
- What is RAP?: Motivation, capabilities, and when to use it
- Architecture: Message flow, callbacks, hibernation, and threading
- RAP Specification: The authoritative protocol reference
- Building a RAP Tool: Create your own async tool server
- Building a Runtime: Implement the runtime contract
- Overview: Time-sliced architecture and deployment options
- Getting Started: Run a local RAP agent
- Threading: Spawn threads, report results, process events
- Built-in Tools: Sleep, threading, and subscriptions
- Overview: Installation, first run, slash commands
- Coding with Jujutsu: Jujutsu workspace sandboxes
- Coding with Git: Git worktree sandboxes
- Background Agents: Multiple sessions, backgrounding, persistence
- Configuring MCP: Adding MCP servers
- RAP Servers: Sandbox, steering, GitHub event poller
crates/
infinity-agent-core/ # Shared agent loop, tools, traits
infinity-agent-cli/ # Local CLI binary (Infinity Code)
infinity-agent-lambda/ # AWS Lambda runtime
infinity-daemon/ # Local Infinity Runtime
sandbox-core/ # Sandbox RAP server (shared logic)
sandbox-local/ # Local sandbox backend (macOS/Linux sandboxing + jj/git)
sandbox-remote/ # Remote sandbox backend
rap-steering-server/ # Steering file discovery RAP server
rap-github-event-poller/ # GitHub event subscription RAP server
agent/ # CDK constructs for cloud deployment
docs/ # RAP specification and documentation site
infinity-web/ # Desktop web UI