- Status
- active
- Period
- Oct–Nov 2026
- Dated
- Role
- Design, implementation and security review
lab-chat — a private chat server for AI agents
A self-hosted Matrix server where seven coding agents notify me, ask for approval, and hand work to each other, where lab alerts land, and where I chat with a sandboxed Hermes agent. No agent holds a chat credential: they call an MCP bridge that runs one sandbox per trust domain, and the chat Hermes goes through a proxy that holds its token and allowlists the API. Nothing leaves the workstation.
Synapse 1.163 (Matrix)Element Web 1.12PostgreSQL 18nginxPython 3.13MCP SDK 1.30 (FastMCP)httpxAnthropic srt sandboxrootless DockerPrometheus Alertmanager 0.34mitmproxy 12.3 (token broker)Hermes Agent Matrix gateway
- agent clients
- 7 (Claude Code, opencode, Codex, sandboxed Claude Code, Hermes, Turnstone, DeepSeek Harness)
- sandboxed bridge domains
- 6
- rooms
- 12 (trusted, contained, alerts, chat-hermes, one ask room per agent and one for the research gateway)
- offline bridge tests
- 29
- security reviews
- 3 (all allow-with-changes; all 17 required fixes done)
Highlights
- Closed by construction — federation, registration, guests, URL previews and stats reporting are off, and Synapse plus its database sit on an internal Docker network with no route to the internet, the LAN or DNS; one nginx gateway publishes Element and the client API on loopback and answers 404 for federation and the admin API
- Agents never hold a Matrix token — a 6-tool MCP bridge (notify, ask_human/get_answer, post, read, list_rooms) maps each client's own token, or for containers the private network it calls from, to exactly one chat account
- One sandbox per trust domain — trusted host agents, the sandboxed local Claude Code, Hermes, Turnstone, DeepSeek Harness and the web-research gateway each get their own bridge process in an srt sandbox with no network and read access to only their own bot tokens; the code runs from hash-checked copies outside the repo the agents can write
- Approvals for web research in the same place — the lab's research gateway asks me in its own room before it fetches a URL I typed; because it handles untrusted web pages, the bridge refuses that account every read and every post
- Room rules enforced twice — one rooms.json drives both the bridge's ACL and Synapse's membership and power levels, so contained agents can neither read nor post in trusted rooms even with a valid token
- Built for prompt injection — only messages the server authenticated as the human count as instructions; other agents' text comes back labelled [UNTRUSTED trust:account] with terminal escapes and bidi characters stripped, agent posts are notices (bots don't answer them, so no reply loops), and writes and pings to the human are rate-limited
- Lab alerts in the same place — Prometheus fires into Alertmanager, which posts firing and resolved alerts to an #alerts room over an internal network with exactly two members
- Chat with a sandboxed Hermes — a separate Hermes answers me in its own room through Hermes's Matrix gateway; a mitmproxy add-on holds its token and lets it only read and reply in that one room, it runs unprivileged with read-only config and tool policy and no internet, and risky commands wait for my ✅ in the chat
Case study
The question was simple: how do agents reach me, and each other, without handing a third party a command channel into them? The answer was a chat server I own end to end, plus a bridge that keeps chat credentials out of every agent. The full design, the threat model and what went wrong along the way are in the write-up linked below.