AgentState
Open source (MIT), self-host anytime, free to start — no credit card.
State and coordination layer for AI agent fleets.
You're building AI agents — not a distributed systems backend. Stop reinventing state management, locking, delegation, and history storage. Just call an API.
AgentState gives agent fleets five primitives — everything needed to coordinate work, track decisions, and share state across many concurrent agents.
Built for vibe coders. No SDK needed — give your coding agent the API docs and let it wire things up. Or use the REST API directly with any language, any framework.
Features
Five primitives
- States — Versioned key/value state with an append-only event log; query across all agents in a fleet
- Leases — Distributed locks for exactly-one-writer coordination across N concurrent agents (recipe)
- Claims — Verifiable assertions with attached evidence you can audit later (recipe)
- Capability Tokens — Scoped, revocable delegation so sub-agents get only the access they need (recipe)
- Conversations — Full message history with CRUD, search, tags, bulk export, and AI-generated titles
Supporting capabilities
- API Key Auth — SHA-256 hashed keys with project scoping
- AI-Powered — Auto-generate titles and follow-up questions
- Cursor Pagination — Efficient, stable pagination for large datasets
- Bulk Export — Export conversations with messages in one call
- External ID Lookup — Map your own IDs to AgentState conversations
- Full-Text Search — Search across message content with snippets
- Tags — Organize conversations with tags and filter by tag
- Bulk Operations — Bulk delete and export conversations
- Request Tracing — X-Request-Id header on every response
- Webhooks — HMAC-signed delivery for
conversation.createdevents — see docs/webhooks.md - MCP Server — Remote (
/api/mcp, OAuth 2.1) and local stdio (@agentstate/mcp) Model Context Protocol servers for Cursor, Claude Desktop, and Windsurf — see docs/mcp.md
Quick Start
npm install @agentstate/sdk
import { AgentState } from "@agentstate/sdk";
const client = new AgentState({ apiKey: "as_live_..." });
const conv = await client.createConversation({
messages: [{ role: "user", content: "Hello" }],
});
Or use the REST API directly:
# Create a conversation
curl -X POST https://agentstate.app/api/v1/conversations \
-H "Authorization: Bearer as_live_your_key" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Hello!"},
{"role": "assistant", "content": "Hi! How can I help?"}
]
}'
# Retrieve it (replace $CONVERSATION_ID with the id from the response above)
curl https://agentstate.app/api/v1/conversations/$CONVERSATION_ID \
-H "Authorization: Bearer as_live_your_key"
API Endpoints
All endpoints are served under /api/v1/. See the API Reference for full details.
Tech Stack
- Runtime: Cloudflare Workers (single Worker)
- Database: Cloudflare D1 (SQLite at edge)
- API Framework: Hono
- ORM: Drizzle ORM
- Dashboard: Astro + React islands + Clerk + Tailwind v4
- Package Manager: Bun
- Linter: Biome
- Tests: Vitest
Development
bun install
# API (port 8787)
cd packages/api && bunx wrangler dev
# Dashboard (port 4321, separate dev server)
cd packages/dashboard && bun run dev
See CLAUDE.md for full dev commands and conventions.
Documentation
See CLAUDE.md for development guide and conventions.
License
MIT