{"slug": "brain-v2-a-minimal-and-extensible-agent-server-for-building-agent-applications", "title": "Brain v2 – A minimal and extensible agent server for building agent applications", "summary": "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.", "body_md": "\n\n```\n              ______ ______ _______ _______ _______\n  ▄████▄     |   __ \\   __ \\   _   |_     _|    |  |\n▄██▄██▄██▄   |   __ <      <       |_|   |_|       |\n  ▀▀  ▀▀     |______/___|__|___|___|_______|__|____|\n```\n\n**A minimal and extensible agent server for building agent applications**\n\n[Quickstart](https://aexhq.github.io/brain/docs/quickstart/) ·\n[Docs](https://aexhq.github.io/brain/docs/) ·\n[API reference](https://aexhq.github.io/brain/docs/api/) ·\n[Examples](https://github.com/aexhq/brain/blob/main/examples) ·\n[Roadmap](https://aexhq.github.io/brain/docs/roadmap/)\n\nBrain 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.\n\nBrain 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.\n\n- **[Sessions](https://aexhq.github.io/brain/docs/guides/sessions/)** : agent conversations that outlive connections and restarts.\n- **[Events](https://aexhq.github.io/brain/docs/reference/events/)** : an ordered record of what the agent does, streamed live or replayed.\n- **[Harnesses](https://aexhq.github.io/brain/docs/adapters/harness/)** : pluggable agent loops that drive the model and manage context.\n- **[Tools](https://aexhq.github.io/brain/docs/tools/)** : capabilities implemented in your application, clients, or services.\n- **[Checkpoints](https://aexhq.github.io/brain/docs/guides/persistence/)** : portable session state for recovering and moving sessions.\n\n``` js\nimport { Brain } from \"@aexhq/brain\";\n\nconst brain = new Brain(\"http://127.0.0.1:8080\", process.env.BRAIN_API_KEY!);\nconst session = await brain.create({ harness: \"pi\", config: { model: \"openai/gpt-4.1-mini\", tools: [\"echo\"] } });\nconst input = await brain.send(session.id, { type: \"user.message\", text: \"Use echo to say hello.\" });\n\nfor await (const event of brain.observe(session.id)) {\n  const data = event.data as { text?: string; message?: string; status?: string };\n  if (event.type === \"assistant.message\") console.log(data.text);\n  if (event.input_id !== input.id) continue;\n  if (event.type === \"session.error\") throw new Error(data.message);\n  if (event.type === \"session.status\" && data.status === \"idle\") break;\n}\n```\n\nThe `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.\n\n- **Choose where tools run.** Compose functions into your application, attach client functions, or connect services in any language.\n- **Decide what the agent can do.** The model sees exactly the tools you enable for each session.\n- **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.\n- **Move sessions between servers.** Checkpoints let another server recover a session after a failure or take it over in a planned handoff.\n- **Isolate every customer.** Keep each customer's sessions and tools separate, and give each client only the access it needs.\n- **Run it yourself.** Brain is open source and self-hosted, with structured logs and OpenTelemetry traces and metrics.\n\nYou need Go 1.26+, Node.js 24+, and an API key from a model provider such as OpenAI.\n\n1. \n**Start Brain.** Clone the repository, build the Pi harness, and start the server:\n\n```\ngit clone https://github.com/aexhq/brain.git\ncd brain\nnpm --prefix runners/pi ci --ignore-scripts\nnpm --prefix runners/pi run build\nexport BRAIN_API_KEY=\"replace-with-a-random-token-of-at-least-24-bytes\"\nexport OPENAI_API_KEY=\"your-provider-key\"\ngo run ./cmd/brain -config examples/local.json\n```\n\n 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) .\n2. \n**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.\n3. \n**Run the example session.** In a second terminal in the checkout, install the SDK for the example and start a session:\n\n```\nexport BRAIN_API_KEY=\"replace-with-a-random-token-of-at-least-24-bytes\"\nnpm install --no-save --package-lock=false @aexhq/brain@2.1.0\nnode examples/session.mjs \"Explain what makes a good agent tool.\"\n```\n\nThe [Quickstart](https://aexhq.github.io/brain/docs/quickstart/) walks through the same steps in PowerShell, Python, and cURL.\n\n| I want to… | Read | \n|---|---|\n| Run my first session | [Quickstart](https://aexhq.github.io/brain/docs/quickstart/) | \n| Understand how Brain runs a session | [Architecture](https://aexhq.github.io/brain/docs/architecture/) | \n| Stream events, interrupt turns, and resume sessions | [Session lifecycle](https://aexhq.github.io/brain/docs/guides/sessions/) | \n| Write a tool service | [Distributed tools](https://aexhq.github.io/brain/docs/tools/) | \n| Connect a remote MCP server | [MCP tools](https://aexhq.github.io/brain/docs/tools/mcp/) | \n| Issue tokens and isolate customers | [Authentication](https://aexhq.github.io/brain/docs/guides/authentication/) | \n| Back up sessions and move them between servers | [Persistence & recovery](https://aexhq.github.io/brain/docs/guides/persistence/) | \n| Deploy and monitor Brain | [Operations & observability](https://aexhq.github.io/brain/docs/guides/operations/) | \n| 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/) | \n| 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/) | \n| See what's coming next | [Roadmap](https://aexhq.github.io/brain/docs/roadmap/) | \n\nGive 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.\n\nInstall 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+.\n\n```\nnode scripts/setup.mjs\nnode scripts/check.mjs\n```\n\n[Development & verification](https://aexhq.github.io/brain/docs/development/) covers what the checks run, how CI publishes releases, and how to preview the docs.\n\nBrain is released under the [MIT License](https://github.com/aexhq/brain/blob/main/LICENSE).\n\n[Docs](https://aexhq.github.io/brain/docs/) ·\n[Roadmap](https://aexhq.github.io/brain/docs/roadmap/) ·\n[Architecture](https://aexhq.github.io/brain/docs/architecture/) ·\n[License](https://github.com/aexhq/brain/blob/main/LICENSE) ·\n[Issues](https://github.com/aexhq/brain/issues)", "url": "https://wpnews.pro/news/brain-v2-a-minimal-and-extensible-agent-server-for-building-agent-applications", "canonical_source": "https://github.com/aexhq/brain", "published_at": "2026-10-21 20:49:11+00:00", "updated_at": "2026-10-21 21:13:24.200910+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-infrastructure", "agent-protocols"], "entities": ["AexHQ", "Brain v2", "Claude Managed Agents", "OpenAI Agents SDK", "OpenAI", "Go", "Node.js"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/brain-v2-a-minimal-and-extensible-agent-server-for-building-agent-applications", "markdown": "https://wpnews.pro/news/brain-v2-a-minimal-and-extensible-agent-server-for-building-agent-applications.md", "text": "https://wpnews.pro/news/brain-v2-a-minimal-and-extensible-agent-server-for-building-agent-applications.txt", "jsonld": "https://wpnews.pro/news/brain-v2-a-minimal-and-extensible-agent-server-for-building-agent-applications.jsonld"}}