{"slug": "show-hn-keel-one-event-sourced-context-graph-for-all-your-agents", "title": "Show HN: Keel – One event-sourced context graph for all your agents", "summary": "Angel Kurten released Keel 0.27.1, an alpha-stage event-sourced context layer that gives every AI agent in a product a shared bitemporal context graph per tenant, accessed through five MCP tools. Keel ingests structured domain events from Postgres, webhooks, Kafka and SQS rather than documents, and declares each vertical in a YAML \"cartridge\" so the core stays domain-agnostic; Kurten argues existing memory layers such as Zep, Mem0, AgentCore Memory and Neo4j's MKG model memory per user or per agent and do not start from domain events or model the tenant. The container ships at ghcr.io/angelkurten/keel with an HTTP JSON API, semantic search, an agent registry and SDKs for TypeScript, Python, Go and PHP, running on an in-memory store, SQLite or MySQL.", "body_md": "**Stop rebuilding the pipeline for every agent.**\n\nDocs: [angelkurten.github.io/keel](https://angelkurten.github.io/keel/) · Why: [We built four agents and four copies of our customer context](https://angelkurten.com/blog/keel-four-agents-four-copies-of-context)\n\nKeel is a context layer for the AI agents inside a product: a vertical SaaS, a consumer app, an internal tool. Domain events from your product go in; a bitemporal context graph per tenant comes out, whatever your unit is (an end-customer, a household, a team); every agent you build reads and writes it through the same five MCP tools.\n\nYou describe your vertical once, in a *cartridge* (ontology, event catalog, semantic rules, memory policies). Keel's core knows nothing about your domain. Your second agent connects in a day instead of weeks, because there is no second pipeline to write.\n\nStatus: 0.27.1, alpha. Container: `ghcr.io/angelkurten/keel`. The five tools over MCP and an HTTP JSON API (`/v1`), Postgres, webhook, Kafka and SQS adapters, semantic search, consolidation, an agent registry and SDKs for TypeScript, Python, Go and PHP, on the in-memory store, SQLite (`--db keel.db`, stdlib, no server to run) or MySQL (`--db mysql://...`).\n\nEvery new agent in a product repeats the same work: extract the customer's data, normalize it, decide what \"critical\" means, keep its own memory, expose its own tools to the model. Four agents, four copies of the customer's context, four definitions of \"critical\", four memories that never talk.\n\nExisting memory layers (Zep, Mem0, AgentCore Memory, Neo4j's MKG) ingest text and documents and model memory per user or per agent. None of them start from **domain events**, and none model the **tenant** your product already has: the end-customer of a B2B SaaS, the household of a consumer app, the team of an internal tool.\n\n1. **Cartridges.** A vertical is declared in YAML plus a few ten-line handlers. The core stays generic. Write a cartridge for fleets, clinics, logistics, or your own product.\n2. **Events in, not documents.** Keel ingests structured facts with time (Postgres tables, webhooks, Kafka, SQS). Ingestion is deterministic and cheap. The graph is exact because it is born from events, not inferred from text.\n3. **Every fact carries its provenance.** Source,`valid_from` ,`valid_to` ,`recorded_at` , and who corrected it. Audit-ready by construction.\n4. **One graph per tenant.** One subgraph per end-customer, household or team, with its own permissions and expiry.\n\n```\ncontext(subject, as_of?, depth?, as_known_at?, task?, detail?, exclude?, only?)\n  -> what is true now, at as_of, or as known at a past moment; rules and their verdicts;\n     depth=1 adds the neighbors; detail=\"concise\" for about a third of the tokens; only=[...] just those predicates\nhistory(subject?, since?, until?, predicate?, scope?, as_known_at?, task?, changed_since?, limit?)\n  -> what was true and when we learned it; without a subject, what changed since a watermark\nsearch(text?, kind?, rule?, limit?, after?, mode?, min_score?, related_to?, via?, detail?, depth?, per_kind?, exclude?, as_of?, where?)\n  -> text or semantic search, or every entity of a kind / where a rule fires, paged;\n     related_to (and via) keeps only one subject's neighbors; detail=\"concise\" puts each result's facts in it;\n     per_kind=n the best of every kind: the context for a task in one call\n     where={name: value} by an attribute's or a fact's value; each result says what matched (matched, snippet);\n     kind may be a list of kinds\nannotate(subject, predicate, value, scope?, evidence?, by?, task?, key?, status?)\n  -> an agent (or a person) writes what it learned; key makes retries safe; status=\"proposed\" waits for review\nrelated(subject, relation?, as_of?, depth?)\n  -> neighbors by relation type, up to three hops\n```\n\n`search(mode=\"semantic\")` finds subjects by meaning: ids in the query first, then a dense and a lexical leg fused, then an optional reranker. Where vectors live and which model makes them are adapters you choose: in memory, Chroma, Weaviate, any OpenAI-compatible embeddings endpoint, or your own vector database and model ([how](https://github.com/angelkurten/keel/blob/master/docs/connect.md#semantic-search), [example](https://github.com/angelkurten/keel/blob/master/examples/custom_adapters.py)).\n\nExpose them over MCP (`keel serve`) and point any agent framework at them. Declare `agents:` in the cartridge and `keel serve --agent <id>` binds a server to one of them: what it may read and write is enforced by the layer, not by the agent.\n\n```\nuv sync --extra dev\nuv run keel validate examples/fleet --events examples/fleet/events.jsonl\nuv run keel ingest examples/fleet examples/fleet/events.jsonl\nuv run keel context examples/fleet examples/fleet/events.jsonl unit:MXK-4821\n```\n\nThen write your own cartridge: see [docs/first-cartridge.md](https://github.com/angelkurten/keel/blob/master/docs/first-cartridge.md) (20 minutes). Settings (database, secret, embeddings keys) go in a `.env`: copy [`.env.example`](https://github.com/angelkurten/keel/blob/master/.env.example) ([reference](https://github.com/angelkurten/keel/blob/master/docs/connect.md#configuration)).\n\nIn your own product it is a library: `uv add keel-context` (or `pip install keel-context`); the import is `import keel`. From another language, generate a typed client from your cartridge: `keel sdk typescript|python|go|php examples/fleet -o <file>`, with a small runtime per language (see [docs/sdks.md](https://github.com/angelkurten/keel/blob/master/docs/sdks.md)).\n\nPoint an MCP client at the five tools:\n\n```\nuv sync --extra mcp\nuv run keel serve examples/fleet --tenant acme-logistics --events examples/fleet/events.jsonl\n```\n\nWith Claude Code, one command registers it and the agent sees exactly five tools:\n\n```\nclaude mcp add keel -- uv run --directory $PWD keel serve examples/fleet --tenant acme-logistics --events examples/fleet/events.jsonl\n```\n\nCodex CLI (OpenAI) works the same way from `~/.codex/config.toml`; the four read tools are annotated read-only, so it runs them without prompting. Both clients answered the same questions through the same five tools: see [connect](https://github.com/angelkurten/keel/blob/master/docs/connect.md#serve-the-tools-over-mcp). A backend, or many tenants from one process, use the same five as a JSON API: `keel serve --transport http` (`/v1/context`, `/v1/events`, ... with OpenAPI; tenant and agent per request).\n\nPoll an outbox table in your Postgres (a cursor file makes restarts resume, not re-ingest):\n\n``` python\nimport psycopg\nfrom keel.adapters.postgres import PostgresTableAdapter\n\nadapter = PostgresTableAdapter(lambda: psycopg.connect(DSN), table=\"keel_events\", cursor_path=\".keel/cursor\")\ningestor = Ingestor(cartridge, SqliteStore(\"keel.db\"))  # durable; MemoryStore() for a throwaway graph\ningestor.ingest(adapter.follow(interval=5))\n```\n\nOr consume a bus: `KafkaAdapter.connect(...)` and `SqsAdapter.connect(...)` in `keel.adapters.bus` (`--extra kafka`, `--extra sqs`), at-least-once, acknowledged only after the batch is committed. Or receive envelopes over HTTP (`uv sync --extra webhook`):\n\n``` python\nfrom keel.adapters.webhook import build_app\n\napp = build_app(ingestor, token=\"shared-secret\")  # POST /events, Authorization: Bearer <token>\n```\n\nThe table shape and the envelope fields are in `keel/adapters/postgres.py` and `keel/envelope.py`. `keel export <tenant> --db keel.db` writes one tenant's whole audit trail as JSONL, closed facts and provenance included.\n\n```\n  your app (Postgres)     webhooks   Kafka / SQS\n            \\               |            /\n             v              v           v\n   +-------------------------------------------------+      +------------------+\n   |  event envelope: tenant, type, subject, time     |      |  cartridge       |\n   |  ingestor + handler registry                     | <--- |  ontology        |\n   |  bitemporal context graph, one subgraph/tenant   |      |  event catalog   |\n   |  memory scopes: global / tenant / task / agent   |      |  handlers        |\n   |  five MCP tools                                   |      |  semantic rules  |\n   +-------------------------------------------------+      |  memory policies |\n            |              |             |                   +------------------+\n         agent A        agent B       agent N (no pipeline)\n```\n\nDesign rules the core enforces:\n\n- **Events are the truth.** An append-only log; the graph is derived and can be replayed. What agents and people wrote is kept across a replay.\n- **Pointers, not copies.** The graph holds references to your rows, the semantics, and earned memory. Never a copy of your tables.\n- **Explicit time.** Facts close, they are not overwritten.\n- **Scopes, not a flat store.**`global` >`tenant` >`task` >`agent` . Nothing is promoted to a wider scope by accident. Agent memory is read only by the agent that wrote it; task memory tied to a task id only by calls that pass that task (`context(task=)` ,`history(task=)` ); global memory lives in a reserved partition every tenant reads and no event writes.\n\n```\nkeel/            core: envelope, handlers, store, scopes, cartridge loader, ingest, tools, cli\ncartridges/      your own cartridges (empty here)\nexamples/        fleet (reference), crm, finance and clinics: four domains, one core, no core change between them;\n                 each a cartridge, its events and its test; fleet also has a minimal agent and a multi-agent workflow\nsdk/             SDK runtimes: typescript, go, php (the Python client ships in keel)\nevals/           the semantic-search eval bench\ndocs/            site sources (mkdocs.yml at the root): first-cartridge, connect, sdks, SPEC\ntests/\n```\n\nA summary; the full plan, with what each release shipped, is in [ROADMAP.md](https://github.com/angelkurten/keel/blob/master/ROADMAP.md).\n\nShipped:\n\n- Event envelope, handler registry, deterministic ingest with dedupe by event id and replay\n- Bitemporal store: in memory, SQLite and MySQL, behind a store protocol with a conformance suite\n-  Memory scopes with TTL, evidence policy, expiry and consolidation into durable facts (`keel expire` ,`keel consolidate` )\n- The five tools over MCP (stdio and HTTP) and a JSON API, with an agent registry (people included)\n- Adapters: Postgres outbox, webhook, Kafka, SQS\n- Rules that compose, follow relations and measure durations\n-  Transaction time (`as_known_at` ), changes since a watermark, task ids, idempotent writes, proposals, conflicts, traces\n- SDKs generated from the cartridge: TypeScript, Python, Go, PHP\n- Bulk ingest (a million events in under a minute and a half on MySQL)\n- Semantic search: hybrid, ids first, rerankers, pluggable vector index and embedder, with an eval bench\n\nOpen:\n\n- Real agent queries from pilots in the semantic-search eval bench\n- Postgres CDC adapter\n- Cartridge catalog, hosted Keel, enterprise features (2027)\n\nApache 2.0. The event envelope, the cartridge format and the five tools are the standard; they will always be free.", "url": "https://wpnews.pro/news/show-hn-keel-one-event-sourced-context-graph-for-all-your-agents", "canonical_source": "https://github.com/angelkurten/keel", "published_at": "2026-10-18 19:40:03+00:00", "updated_at": "2026-10-18 20:19:32.875863+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-infrastructure", "ai-tools", "artificial-intelligence"], "entities": ["Keel", "Angel Kurten", "Zep", "Mem0", "AgentCore Memory", "Neo4j", "Postgres", "Kafka"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/show-hn-keel-one-event-sourced-context-graph-for-all-your-agents", "markdown": "https://wpnews.pro/news/show-hn-keel-one-event-sourced-context-graph-for-all-your-agents.md", "text": "https://wpnews.pro/news/show-hn-keel-one-event-sourced-context-graph-for-all-your-agents.txt", "jsonld": "https://wpnews.pro/news/show-hn-keel-one-event-sourced-context-graph-for-all-your-agents.jsonld"}}