Skip to content

Repository files navigation

AgentState

CInpmPyPILicense: MITPRs Welcome

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
  • 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";constclient=newAgentState({apiKey: "as_live_..."});constconv=awaitclient.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.

MethodPathDescription
POST/api/v1/conversationsCreate conversation
GET/api/v1/conversationsList conversations (cursor pagination)
GET/api/v1/conversations/:idGet conversation (includes messages by default; ?fields=!messages to exclude)
PUT/api/v1/conversations/:idUpdate title/metadata
DELETE/api/v1/conversations/:idDelete with messages
POST/api/v1/conversations/:id/messagesAppend messages
GET/api/v1/conversations/:id/messagesList messages
POST/api/v1/conversations/:id/generate-titleAI title generation
POST/api/v1/conversations/:id/follow-upsAI follow-up questions
GET/api/v1/conversations/searchFull-text search
POST/api/v1/conversations/exportBulk export with messages
GET/api/v1/tagsList project tags
POST/api/v1/conversations/:id/tagsAdd tags
DELETE/api/v1/conversations/:id/tags/:tagRemove tag
GET/api/v1/analytics/summaryUsage summary
GET/api/v1/analytics/timeseriesTime series data
GET/api/v1/analytics/tagsTag statistics
PUT/api/v1/states/:stateKeyCreate or replace state
GET/api/v1/states/:stateKeyRead state
POST/api/v1/states/queryQuery states
DELETE/api/v1/states/:stateKeyDelete state
GET/api/v1/states/:stateKey/eventsList state events
POST/api/v1/states/:stateKey/leaseCreate lease
POST/api/v1/leases/:id/renewRenew lease
DELETE/api/v1/leases/:idRelease lease
POST/api/v1/capability-tokensCreate capability token
GET/api/v1/capability-tokensList capability tokens
DELETE/api/v1/capability-tokens/:idRevoke capability token
POST/api/v1/claimsCreate claim
GET/api/v1/claimsList claims
GET/api/v1/claims/:idGet claim with evidence
POST/api/v1/claims/:id/verifyVerify claim

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 (353 tests)

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

GuideDescription
Documentation IndexComplete docs index
Getting StartedZero to working in 2 minutes
API ReferenceComplete REST API documentation
V2 Migration GuideMigrate from V1 to V2 API
TypeScript SDKSDK installation, methods, and examples
Python SDKPython package for AgentState
Framework IntegrationVercel AI SDK, Cloudflare Workers AI, LangGraph
Environment VariablesAll env vars and Cloudflare bindings
Core MemoryDurable maintenance notes for future agents
RoadmapWhat's shipped, what's next, and how to influence direction
ContributingHow to contribute, branch conventions, and PR template

See CLAUDE.md for development guide and conventions.

License

MIT

About

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages