Brain v2 – A minimal and extensible agent server for building agent applications AexHQ released Brain v2, an open-source, self-hosted agent server positioned as an alternative to Claude Managed Agents and the OpenAI Agents SDK, letting teams run agent loops on their own infrastructure with the models they choose. Brain v2 provides session-oriented primitives — sessions that survive disconnects and restarts, an ordered event stream that can be replayed, pluggable harnesses, application-defined tools, and portable checkpoints for recovering or handing off sessions between servers — and requires Go 1.26+, Node.js 24+, and a model provider API key such as OpenAI's. The release matters because it gives developers a vendor-neutral way to keep each customer's sessions and tools isolated while retaining structured logs and OpenTelemetry traces and metrics. ▄████▄ | \ \ | | | | ▄██▄██▄██▄ | < < | | | | | ▀▀ ▀▀ | / | | | | | | | A minimal and extensible agent server for building agent applications Quickstart https://aexhq.github.io/brain/docs/quickstart/ · Docs https://aexhq.github.io/brain/docs/ · API reference https://aexhq.github.io/brain/docs/api/ · Examples https://github.com/aexhq/brain/blob/main/examples · Roadmap https://aexhq.github.io/brain/docs/roadmap/ Brain is a single application you deploy as a service to run the agents behind your products. It's an open-source alternative to Claude Managed Agents and the OpenAI Agents SDK, running on your own infrastructure with the models you choose. Brain gives you session-oriented primitives for building agents. Your application starts sessions, streams what the agent does, and connects tools from application code and services. Brain runs the agent loop and records each session's history, so you can replay a session or recover it after a failure. - Sessions https://aexhq.github.io/brain/docs/guides/sessions/ : agent conversations that outlive connections and restarts. - Events https://aexhq.github.io/brain/docs/reference/events/ : an ordered record of what the agent does, streamed live or replayed. - Harnesses https://aexhq.github.io/brain/docs/adapters/harness/ : pluggable agent loops that drive the model and manage context. - Tools https://aexhq.github.io/brain/docs/tools/ : capabilities implemented in your application, clients, or services. - Checkpoints https://aexhq.github.io/brain/docs/guides/persistence/ : portable session state for recovering and moving sessions. js import { Brain } from "@aexhq/brain"; const brain = new Brain "http://127.0.0.1:8080", process.env.BRAIN API KEY ; const session = await brain.create { harness: "pi", config: { model: "openai/gpt-4.1-mini", tools: "echo" } } ; const input = await brain.send session.id, { type: "user.message", text: "Use echo to say hello." } ; for await const event of brain.observe session.id { const data = event.data as { text?: string; message?: string; status?: string }; if event.type === "assistant.message" console.log data.text ; if event.input id == input.id continue; if event.type === "session.error" throw new Error data.message ; if event.type === "session.status" && data.status === "idle" break; } The echo tool comes from the example tool server https://github.com/aexhq/brain/blob/main/examples/tools/README.md , a small service you run next to Brain. - Choose where tools run. Compose functions into your application, attach client functions, or connect services in any language. - Decide what the agent can do. The model sees exactly the tools you enable for each session. - Reconnect at any time. Sessions keep running when clients disconnect and survive server restarts, so any client can reconnect and continue from the last event it read. - Move sessions between servers. Checkpoints let another server recover a session after a failure or take it over in a planned handoff. - Isolate every customer. Keep each customer's sessions and tools separate, and give each client only the access it needs. - Run it yourself. Brain is open source and self-hosted, with structured logs and OpenTelemetry traces and metrics. You need Go 1.26+, Node.js 24+, and an API key from a model provider such as OpenAI. 1. Start Brain. Clone the repository, build the Pi harness, and start the server: git clone https://github.com/aexhq/brain.git cd brain npm --prefix runners/pi ci --ignore-scripts npm --prefix runners/pi run build export BRAIN API KEY="replace-with-a-random-token-of-at-least-24-bytes" export OPENAI API KEY="your-provider-key" go run ./cmd/brain -config examples/local.json To run the published container image instead, follow Run Brain in a container https://aexhq.github.io/brain/docs/guides/operations/ run-brain-in-a-container . 2. Install an SDK. Add the SDK to your application with npm install @aexhq/brain or pip install aex-brain . Client applications need neither a checkout nor Go. 3. Run the example session. In a second terminal in the checkout, install the SDK for the example and start a session: export BRAIN API KEY="replace-with-a-random-token-of-at-least-24-bytes" npm install --no-save --package-lock=false @aexhq/brain@2.1.0 node examples/session.mjs "Explain what makes a good agent tool." The Quickstart https://aexhq.github.io/brain/docs/quickstart/ walks through the same steps in PowerShell, Python, and cURL. | I want to… | Read | |---|---| | Run my first session | Quickstart https://aexhq.github.io/brain/docs/quickstart/ | | Understand how Brain runs a session | Architecture https://aexhq.github.io/brain/docs/architecture/ | | Stream events, interrupt turns, and resume sessions | Session lifecycle https://aexhq.github.io/brain/docs/guides/sessions/ | | Write a tool service | Distributed tools https://aexhq.github.io/brain/docs/tools/ | | Connect a remote MCP server | MCP tools https://aexhq.github.io/brain/docs/tools/mcp/ | | Issue tokens and isolate customers | Authentication https://aexhq.github.io/brain/docs/guides/authentication/ | | Back up sessions and move them between servers | Persistence & recovery https://aexhq.github.io/brain/docs/guides/persistence/ | | Deploy and monitor Brain | Operations & observability https://aexhq.github.io/brain/docs/guides/operations/ | | Call Brain from my backend | TypeScript SDK https://aexhq.github.io/brain/docs/sdks/typescript/ or Python SDK https://aexhq.github.io/brain/docs/sdks/python/ | | Look up routes and config fields | HTTP API https://aexhq.github.io/brain/docs/api/ and Host configuration https://aexhq.github.io/brain/docs/reference/configuration/ | | See what's coming next | Roadmap https://aexhq.github.io/brain/docs/roadmap/ | Give your coding agent Brain's docs as plain text: llms-full.txt https://aexhq.github.io/brain/llms-full.txt has every page in one file, and llms.txt https://aexhq.github.io/brain/llms.txt lists the pages. Install the dependencies and run every local check before you open a pull request. The checks need Go 1.26+, Node.js 24+, and Python 3.11+. node scripts/setup.mjs node scripts/check.mjs Development & verification https://aexhq.github.io/brain/docs/development/ covers what the checks run, how CI publishes releases, and how to preview the docs. Brain is released under the MIT License https://github.com/aexhq/brain/blob/main/LICENSE . Docs https://aexhq.github.io/brain/docs/ · Roadmap https://aexhq.github.io/brain/docs/roadmap/ · Architecture https://aexhq.github.io/brain/docs/architecture/ · License https://github.com/aexhq/brain/blob/main/LICENSE · Issues https://github.com/aexhq/brain/issues