Aex Brain

Introduction

Brain's durable session engine and the four things that plug into it.

Brain runs agent sessions. It owns one canonical journal per session, activates an Agentloop, executes the model and Tool effects the loop requests, and exposes journal projections over HTTP and SSE.

Run it as a server your app talks to over HTTP, or embed the brain crate in a Rust service you already own.

Brain is under early development. Contracts are replaced in place until the first stable release, and there is no upgrade path from earlier builds.

The four parts

PartYou supplyBrain does
AgentloopA raw WebAssembly Component placed in an EnvironmentActivates it there and performs its model and Tool requests
ModelA provider, model name, and credentialSeals the credential for the session and makes calls
ToolA typed contract, its implementation, and where it runsCommits the call before dispatch and records its outcome
EnvironmentA named place that runs Tools and the loopSets it up, invokes, cancels, detaches, and tears it down

Application code composes these values explicitly. component(...) wraps already-built Wasm, brainEnv({ name }) is Brain's own Environment, hostEnv({ name }) is your own process, an environment(...) extension is anything reached over HTTP, and every Tool and Agentloop factory takes { env, ...options }.

The durable rule

Brain commits every external-effect intent to the session journal before dispatch and sends it once. It never automatically retries an effect. A known result, a known failure, or an unknown outcome is committed before the Agentloop observes it.

The public event feed, session status, transcript, and Agentloop kv are projections of the same journal. SSE is a live notification path; reconnecting clients resume from a committed sequence.

Where to go next

  • Quickstart — run a server and create a first session.
  • Sessions — journal, turns, suspension, and recovery.
  • Agentloop — raw Components and explicit placement.
  • Tools — one Tool form, placed where it runs.
  • Environments — the brain env, the host env, and yours.
  • API reference — generated from the protocol types.

On this page