Labsco
Moai-Team-LLC logo

AgenticMind

β˜… 4

from Moai-Team-LLC

Auditable, self-improving knowledge & memory for AI agents over MCP β€” citation-enforced answers and a replayable why-trace, self-hosted on Postgres.

πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedAccount requiredAdvanced setup
<div align="center"> <img src="assets/agenticmind-logo.png" alt="AgenticMind" width="118" />

AgenticMind

The auditable, self-improving knowledge & memory layer for AI agents.

Grounded answers with provable citations, a full why-trace for every answer, and a corpus that improves itself β€” served to any agent over MCP. Zero-key, multilingual, and self-hostable on Postgres alone.

CI Conventional Commits License: Apache 2.0 Implements: Agentic Product Standard Runtime: Node or Bun DB: Postgres + pgvector Stars

Quickstart Β· See it work Β· Agent tools Β· How it works Β· Why Β· The Standard β†—

<sub>If this is useful, a ⭐ helps others find it β€” and tells us to keep going.</sub>

</div>

Not "memory storage for an agent." AgenticMind is the substrate an agent points at when it needs answers it can trust, a trail it can audit, and a knowledge base that compounds.

Most agent memory is a vector store with save() and search(). That buys you fuzzy recall and zero accountability: you can't tell why an answer came back, whether it's current, or whether a source even supports it. AgenticMind treats knowledge as a first-class, auditable, self-improving substrate β€” and exposes it to any agent over the Model Context Protocol.

✨ Why AgenticMind

  • πŸ“Œ Citation-enforced β€” every claim in an answer is keyed to a numbered source. No source, no claim.
  • πŸ” Fully auditable β€” a replayable why-trace for every answer: what was retrieved, ranked, and used.
  • ♻️ Self-improving β€” validated answers are promoted back into the corpus by a judge-gated compounding loop, driven by programmatic signals (not human thumbs).
  • 🧩 Tiered retrieval β€” chunks β†’ typed fact cards β†’ knowledge graph; hybrid vector + full-text, recency-aware.
  • πŸ” Safe by construction β€” scoped, least-privilege MCP tokens, fail-closed auth, guardrails on input and output.
  • 🐘 One datastore β€” Postgres + pgvector carries vectors, full-text, the graph (recursive CTE), and the durable queue. No Redis, no Neo4j, no vector-DB sprawl.

πŸ”§ How it works

Copy & paste β€” that's it
flowchart TD
  A["πŸ€– Agent"] -->|"MCP request"| R["Tiered retrieval<br/>pgvector + full-text + graph"]
  R --> Y["Citation-enforced synthesis"]
  Y -->|"grounded answer + [citations]"| A
  Y --> T[("Replayable why-trace")]
  Y -->|"programmatic signals"| L["Judge-gated compounding loop"]
  L -->|"promotes validated knowledge"| R

A request comes in over MCP β†’ the engine retrieves across three tiers β†’ synthesises an answer where every claim cites a source β†’ logs a replayable trace β†’ and feeds programmatic signals into a loop that promotes validated knowledge back into the corpus.

🎬 See it work

A real kl_ask_global call against a corpus seeded with the Agentic Product Standard. The question deliberately has two halves β€” one the corpus can answer, one it can't:

<div align="center"> <img src="assets/demo.gif" alt="A live kl_ask_global call: a citation-enforced answer that refuses the unsupported half, with a replayable why-trace" width="780" /> </div>
Copy & paste β€” that's it
// β†’ kl_ask_global
{ "question": "When should I use a multi-agent architecture instead of a single agent,
                and what must every agent ship with according to the standard?" }

// ← response (trimmed)
{
  "answer": "The provided sources do not specify when to use a multi-agent architecture
             versus a single agent. … According to the Agentic Product Standard, every
             agent must ship with a written Agent Contract [1]. This contract must cover
             ownership, forbidden actions, acceptance criteria, failure modes, escalation
             rules, and logging requirements [1].",
  "citations": [
    { "number": 1, "title": "Agent Contract requirement",
      "materialId": "ba44971b-…", "score": 0.46, "origin": "chunk" }
  ],
  "model": "google/gemini-3.1-flash-lite-preview",
  "retrievalMs": 606, "generationMs": 890,
  "phases": [ {"phase":"embed","ms":552}, {"phase":"retrieve","ms":37},
              {"phase":"synth","ms":890}, {"phase":"output_filter","ms":2} ],
  "telemetryId": "cc942e54-…"
}

Look at what didn't happen. The half the corpus couldn't support, the model refused to answer β€” "the provided sources do not specify…" β€” instead of fabricating it. The half it could support is keyed to a numbered citation you can open. And every answer comes with a why-trace (phases, model, telemetryId) you can replay. That's the whole pitch in one call: no source, no claim β€” and a receipt for every answer.

πŸ†š How it's different

Plain RAG / memory SDKsAgenticMind
Grounded answerssometimescitation-enforced + post-checked
Why-trace per answerβœ—full decision trace
Self-improving corpusβœ—compounding loop (judge-gated)
Relational verificationβœ—graph module
Runs onvariesPostgres + pgvector (flagship)

βœ… Use it when / 🚫 reach for something else when

Use AgenticMind when:

  • Your agent must answer from trusted sources, and every claim needs a citation.
  • You need a replayable why-trace and a single status (supported / partial / unsupported / conflicted / needs_review) you can gate an agent on.
  • Disagreeing or stale sources must be surfaced, not silently resolved.
  • You want governed self-improvement β€” not silent autonomous memory mutation.
  • You need self-hosting (Postgres-only) and MCP-native access (Claude Code, Cursor, LangGraph, OpenAI/Claude Agent SDK, custom agents).

Reach for something else when:

  • You only need simple personalised chat memory (use a memory SDK).
  • You want a hosted API / no-code UI today β€” AgenticMind is self-hosted infra.
  • You need SSO / SOC2 out of the box (see the security model for what exists).
  • You're optimising for the fastest prototype, not accountable production.

πŸ›  Agent surface (MCP)

A headless service (apps/server) exposes the engine as MCP tools over streamable HTTP, with fail-closed per-token bearer auth (scoped, least-privilege):

ToolScopePurpose
kl_searchknowledge:readsemantic / keyword passage search
kl_ask_globalknowledge:readsynthesised answer + citations + a gate-able status (optional intent/facts)
kl_get_materialknowledge:readfetch a material by id
kl_graph_neighborsknowledge:readrelated materials via the knowledge graph
kl_ingestknowledge:writeadd text (chunked, embedded, distilled into cards, graph-extracted)
kl_forgetknowledge:admindelete a material + all derived chunks/cards/graph (inverse of ingest)
kl_signalknowledge:signalemit a programmatic compounding signal on a prior answer
mem_recallmemory:readrecall beliefs (private βˆͺ shared); semantic or asOf time-travel
mem_writememory:writerecord a belief into private memory (bitemporal, revision-aware)
mem_forgetmemory:writeretract one of your own beliefs (soft, bitemporal)

See What counts as knowledge for the Knowledge Unit contract (what may become stored knowledge), Evals & limits for what we measure and what we don't claim, docs/knobs.md for the optional answer-quality knobs (Tier-B faithfulness, contested-sources, answer policy, source trust), and the security model (fail-closed auth, tenant RLS, lethal-trifecta analysis, supply chain).

There is no frontend β€” the only consumers are agents over MCP. The tool logic is framework-agnostic in packages/shared/src/lib/knowledge/mcp-tools.ts; the host is a ~60-line Web-standard fetch handler served by Node or Bun.

🧱 Layout

Copy & paste β€” that's it
packages/shared/src/lib/knowledge/        ← the tiered engine (the product)
packages/shared/src/lib/ai/               ← chat + embeddings (provider-agnostic; local embeddings by default)
packages/shared/src/database/             ← Drizzle schema + queries (Postgres + pgvector)
apps/server/src/{index,mcp}.ts            ← headless MCP host, Node or Bun (agent surface)
apps/worker/src/jobs/knowledge-feedback/  ← Postgres-scheduled compounding sweep

Architecture notes. Agent-first and Postgres-only: the graph lives behind a GraphStore interface (recursive-CTE traversal on Postgres, no extra service), compounding is driven by programmatic signals, MCP tokens are scoped least-privilege, the agent principal is slim, and the host is a headless Node/Bun HTTP server. Retrieval is multilingual by default β€” local bge-m3 embeddings cover many languages with zero keys; full-text search uses the language-agnostic simple config (configurable per deployment).

🌐 Ecosystem

AgenticMind is the flagship reference implementation of the Agentic Product Standard β€” the open standard (plus Claude Code skills) for building production-grade agentic products.

RepoUse it when
πŸ“agentic-product-standardYou're designing or building an agent / agentic product β€” the standard + skills tell you how.
βš™οΈAgenticOpsYou need to run a fleet of long-lived agents as deployed infrastructure β€” manifests, scheduling, a durable backlog, bounded runs, fleet health.
🧠AgenticMind (this repo)You need a knowledge & memory layer for your agent β€” a working implementation you can run.
πŸ“ˆAgenticPerformanceYou need to measure and improve your agents β€” traces, golden-set evals with a CI gate, failure clusters, a governed improvement loop.
🩹AgenticSelfHealingCodeYou need agents to heal what breaks β€” production monitoring, incident RCA, and test-suite repair.

See the standard's AgenticMind case study for a layer-by-layer map of how this repo implements the canon.

🀝 Contributing & license

Contributions welcome β€” see CONTRIBUTING.md. Licensed under Apache-2.0.