# rotary (rx4) — the agent harness engine [![crates.io](https://img.shields.io/crates/v/rx4.svg)](https://crates.io/crates/rx4) [![License: MPL-2.0](https://img.shields.io/badge/License-MPL--2.0-blue.svg)](LICENSE) [![MSRV: 1.89](https://img.shields.io/badge/MSRV-1.89-blue.svg)](https://www.rust-lang.org) Pure agent harness engine. Models write; rotary gives them tools, memory, loops, permissions, sessions, and control planes. Hosts embed it as a library or drive it over IPC; policy and UI stay in the host. ## Wasm and Cloudflare Workers The `lite` feature exposes a real, resumable `rx4::lite::Agent` without a native runtime, filesystem, process executor, HTTP client, or random-number dependency: ```toml [dependencies] rx4 = { version = "0.8", default-features = false, features = ["lite"] } ``` Commit `Cargo.lock` for reproducible builds. See [the lite host contract](docs/lite.md) for the API and supported capabilities. [Roundhouse](https://github.com/softwarecorporation/roundhouse) supplies a real Workers/Wasm host, durable alarm scheduling, permission-gated application recovery, and independent verification. Native remains the default. Features are additive: `native,lite` exposes both agents on a native target. Existing native feature flags imply `native`; hosts that previously disabled all defaults without selecting any feature must now select `native` explicitly. Use only `lite` for Wasm; enabling native tools/providers on wasm32 is unsupported. ## Native dependency security Rotary requires Rust 1.89 and uses rusqlite 0.41 and rustix at least 1.1.6 for patched native SQLite and Linux support. Native memory/session features remain supported. Lite does not enable either dependency. The optional `zkr` dependency requires the patched [zkr 0.5.1 registry release](https://crates.io/crates/zkr/0.5.1). Cargo resolves it directly from crates.io; no Git dependency or sibling checkout is required. ## Quick start ### Library Slim hosts disable crate defaults and name only the features they need: ```bash cargo add rx4 --no-default-features --features builtin-tools,providers ``` ```rust use rx4::{HarnessBuilder, Policy, Scope}; #[tokio::main] async fn main() -> Result<(), Box> { let mut agent = HarnessBuilder::new() .scope(Scope::Coding) .policy(Policy::workspace_write()) .builtin_tools(["read", "write", "edit", "bash", "grep", "find", "ls", "todo"]) .instructions("Keep changes small and preserve the public API.") .build()?; // The builder returns a normal Agent. Hosts still attach a provider, // approver, hooks, and persistence before choosing when to prompt. // See `examples/provider_agent.rs` for provider setup. // agent.prompt("fix the failing test").await?; Ok(()) } ``` Run the bundled examples: ```bash cargo run --example minimal_agent cargo run --example harness_builder cargo run --example custom_tool cargo run --example sessions OPENAI_API_KEY=sk-... cargo run --example provider_agent --features providers ``` See [examples/README.md](examples/README.md) for what each one covers. For an opt-in generic contract and deliberate builtin selection, see the [harness builder](docs/HARNESS.md#generic-harness-builder). It returns the ordinary `Agent`; it does not create a product host or choose host lifecycle and scheduling policy. ### Binary The `rx4` binary is gated on the `cli` feature, so a bare `cargo install rx4` does **not** produce it: ```bash cargo install rx4 --features cli,ipc,providers,builtin-tools,mcp ``` ```bash rx4 chat rx4 exec "fix the failing test" rx4 serve /tmp/rx4.sock rx4 doctor ``` See [docs/INSTALL.md](docs/INSTALL.md) for Homebrew notes and [docs/FEATURES.md](docs/FEATURES.md) for the full feature flag table. ## What it exposes A scope is a work mode, not an agent name. - **Agent loop** with streaming events, parallel tool batches, and guardrails. - **Builtin tool loadout** — file (`read`/`write`/`edit`), shell (`bash`/`exec`), search (`grep`/`find`/`ls`), plus `web_fetch`, `todo`, `spawn_agent`, plan-mode, and LSP helpers. - **Scopes** — `coding`, `research`, `plan`, `ask`, `computer_use`. - **Permissions** — `Policy` + pluggable `Authorizer`; `workspace_write` default. - **Providers** — OpenAI, Anthropic, Ollama, and any OpenAI-compatible endpoint. - **Sessions** — fork/merge tree with JSONL and optional SQLite persistence. - **Skills, graph memory, dream scheduler, computer-use, MCP, LSP** — opt-in capabilities. rotary exposes capabilities, not policy: scheduling, enabled flags, and lifecycle decisions belong to the host. ### Subagent authority Model-facing `spawn_agent` inherits its parent agent's authority: policy and shell rules, custom authorization and approval gates, active scope, sandboxing, and remaining budget. A child configuration can narrow this authority but cannot widen it. Hosts that register their own `SubagentManager` should pass `agent.subagent_authority()` to `with_authority` when the manager is reachable from an agent. A manager without that snapshot remains an explicit host-owned authority boundary for backward-compatible host-created subagents. ### Hashline, prewalk, AVO The engine owns the tagged edit protocol (`rx4::hashline`), the one-way investigate→smol switch (`rx4::prewalk`, `RX4_SMOL_MODEL`), and AVO helpers (`rx4::avo`: `P_t`, two-part `f`, commit-if-better, stall). Hosts enable them; they should not fork the protocol. See [docs/HARNESS.md](docs/HARNESS.md). ### Opt-in autoresearch `AutoresearchSession` persists `.auto/` metadata; `AutoresearchController` adds detached Git worktrees, checkpoint rollback, median aggregation, guards, budgets, typed events, and explicit final-patch acceptance. It is host-driven and never mutates the real checkout automatically. See [docs/AUTORESEARCH.md](docs/AUTORESEARCH.md). ## Docs - [Documentation index](docs/README.md) - [Install](docs/INSTALL.md) · [Features](docs/FEATURES.md) · [Providers](docs/PROVIDERS.md) · [Events](docs/EVENTS.md) - [Hosting guide](docs/HOSTS.md) · [Architecture](docs/ARCHITECTURE.md) · [Computer-use](docs/COMPUTER-USE.md) - [telekinesis](https://github.com/softwarecorporation/telekinesis) — CLI/TUI product host - [apollo](https://github.com/softwarecorporation/apollo) — AI agent host ## License MPL-2.0