# Why nanocode

One runtime runs Codex and Claude agents with durable sessions, Code Mode, subagents, and remote hands, natively or in WebAssembly.

## One Runtime

`Nanocode::builder()` assembles one runtime for both harnesses. Agents of either provider share the runtime's tools, Code Mode, subagents, and session store, so a host switches providers by changing the model, not the program.

```rust
// Spawn a Codex agent and a Claude agent from the same runtime
let (codex, _) = runtime
    .spawn()
    .backend::<Codex>()
    .model(Model::Luna)
    .build()
    .await?;
let (claude, _) = runtime
    .spawn()
    .backend::<Claude>()
    .model(ClaudeModel::Haiku55)
    .build()
    .await?;
```

## Upstream Harnesses

Each harness sends its provider's own system prompt and tool definitions. The Claude harness pins the identity text, tool names, descriptions, and schemas of a specific Claude Code release, and a verification script compares fresh captures of that release against the pinned artifacts.

* **Codex:** `gpt-6.1-sol`, `gpt-6-luna`, and `gpt-6-astra`, signed with a ChatGPT login or an API key, or routed through a Responses gateway.
* **Claude:** `claude-opus-5-5`, `claude-sonnet-5-5`, `claude-haiku-5-5`, `claude-fable-5-1`, `claude-mythos-5-1`, and earlier models, signed with a Claude subscription or an API key.

## Durable Sessions

Durability is on by default. Every turn, model step, and tool receipt is journaled to a store. A reopened session replays committed tool receipts instead of running the tools again, and an interrupted tool call reports an unknown outcome to the model.

```rust
// Reopen a saved session by ID after a restart
let (agent, events) = runtime.open_session(&session_id).await?;
```

Native hosts default to a JSONL log in `~/.nanocode`. SQLite and Postgres stores are separate crates, and WebAssembly hosts implement storage with one SQL transaction callback.

## Code Mode

Code Mode gives the model a JavaScript cell that calls tools. One cell can run calls in parallel with `Promise.all`, keep values between cells, and return only the output the model needs. Rust tools, host tools, and MCP tools are offered directly and inside Code Mode.

## Subagents and Hands

* **Subagents:** An agent spawns children with their own model, thinking level, and typed output contract, then waits for their accepted results.
* **Hands:** A brain keeps inference, subagents, and durability. Code Mode cells run on hands, such as a laptop or a build machine, over a WebSocket. A dropped call reports an unknown outcome instead of running again.

```bash
# Attach this machine as a hand to a listening brain
nc hand ws://127.0.0.1:9000 --name build-box
```

## Native and WebAssembly

The SDK is one Rust crate workspace. Its library crates compile for native targets and for `wasm32-unknown-unknown` without `wasm-bindgen`. `nanocode-wasm` packages the SDK as one module with a TypeScript host for Cloudflare Workers, Node, Deno, and browsers.

On 2026-10-20, the module measured 8,314,227 bytes, or 2,529,519 bytes with `gzip -9`. On 2026-10-19, on an Apple Silicon laptop with a mock provider, instantiating the compiled module took 0.3 to 0.7 ms, and a new session's first turn took 33 to 50 ms.

## More

- [Getting Started](/docs/introduction/getting-started): Install nanocode and run a first turn.

- [Concepts](/docs/introduction/concepts): The terms these pages use, defined once.

- [Durability](/docs/guides/durability): Journal turns and reopen sessions by ID.

- [Remote Hands](/docs/guides/remote-hands): Run Code Mode cells on other machines.
