The problem: agents remember facts, but forget why
When an AI coding agent works inside a codebase, knowing what a file contains is only half the job. The harder half is remembering why a choice was made six weeks ago, which trade-offs were accepted, and what consequences followed.
Plain vector search is good at finding text matches ("what do we know?"). But it struggles with causal reasoning:
- Why was shadcn/ui chosen over gluestack.io?
- What bug caused us to add a forward-version write guard to the memory engine?
- Which past decision forbids mutation testing in CI?
To solve this, we integrated an external open-source tool called Semantica into our setup. By linking Semantica's causal knowledge graph with ai-badger 0.124.0 prompt hooks and ai-raccoon 1.14.1's persistent memory bank (building on the search quality system introduced in 1.7.0), we turned session reasoning into an automated, auditable decision trail that stays alive across restarts.
What Semantica is (and where to find it)
Semantica (the PyPI package is semantica; the installed console script is named semantica-mcp) is an external open-source MCP server built for session-scoped knowledge graph reasoning.
Instead of just indexing raw text chunks, Semantica tracks entities, relationships, confidence scores, and structured decision records (category, scenario, reasoning, outcome, confidence).
Quick overview
- Tool Type: External Python-based MCP server (
semanticav0.6.5+). - Core Function: Tracks causal decision graphs, extracts entity relationships, and checks precedents during agent runs.
- Where to find: Open source on GitHub and PyPI (
pip install semantica). - Installation:
pip install semanticaOr register it in your agent's MCP setup (.mcp.json or config.yaml):
{
"mcpServers": {
"semantica": {
"command": "semantica-mcp"
}
}
}Three tools for three questions
In our multi-agent workflow, we split knowledge management across three distinct tools:
| Tool | Core Question | Main Mechanism |
|---|---|---|
ai-raccoon (memory_search) | "What do we know?" | Persistent hybrid vector + BM25 search over indexed docs and notes. |
Semantica (query_decisions, get_causal_chain) | "How are things connected and why?" | Causal knowledge graph, entity relationships, and decision precedents. |
Code-Review-Graph (query_graph_tool: callers_of, callees_of) | "How is code wired?" | AST symbol graph, caller/callee links, and structural code metrics. |
Solving ephemerality: The ai-raccoon Persistence Bridge ([ADR-0019](https://github.com/Arasz/ai-badger/blob/main/docs/adr/0019-semantica-session-graph-export-and-airaccoon-watch.md))
Semantica's session-scoped design meant valuable decision graphs disappeared when a session ended. Rather than modifying Semantica's internal code, we created the ai-raccoon Persistence Bridge Pattern:
Semantica + ai-raccoon Persistence Bridge Flow
flowchartHow the bridge works
- Atomic Exporter: On hook execution or session exit,
.ai-badger/skills/semantica-knowledge-graph/scripts/export_semantica_graph.pytakes a snapshot of Semantica's nodes, edges, and decisions, writing an atomic JSON file to.ai-raccoon/semantica-graph.json. - ai-raccoon Watcher: ai-raccoon maintains an active file watch (
memory_watch_add) on.ai-raccoon/semantica-graph.json. - Chunking and Ingestion: ai-raccoon automatically parses the graph schema (
nodes,edges,decisions), chunking entities and rationale into its encrypted SQLite store (~/.ai-raccoon/memory.db). - Cross-Session Recall: In future sessions,
memory_searchin ai-raccoon returns both textual rationale and exact structural graph relations across restarts.
Automating auditable memory with ai-badger & ai-raccoon
The main advantage here is automation. Nobody needs to hand-format decision logs or manually run export commands.
Combining ai-badger prompt hooks with ai-raccoon background indexing keeps decision tracking hands-off:
- Automatic Capture: While an agent runs tasks under
ai-badger 0.124.0, pre-tool and post-tool hooks record major decisions and verification outcomes. - Background Indexing: Notes and exported graph snapshots flow straight into
ai-raccoon 1.14.1's project memory bank without manual steps. - Auditable Reasoning Chains: When someone asks "why" a decision was made,
memory_searchretrieves the causal chain (Problem -> Research/Trigger -> Solution -> Verified Outcome).
Real-world example: Auditing skill creation in our session
During a recent session, we asked our agent why three skills (ai-raccoon-state-checklist, ai-text-humanization, and refactoring-fix) were created. Here is the exact reasoning chain retrieved from memory:
| Skill Created | Trigger / Problem | Solution & Outcome | Auditable Evidence |
|---|---|---|---|
ai-raccoon-state-checklist | User requested a structured, repeatable pre-flight check after package updates and ai-raccoon serve restarts. | Built a pre-flight checklist skill that populates a dated audit resource (.ai-raccoon/state-checklist-20260813.json). | Commit c5784c49 |
ai-text-humanization | Research showed unedited AI text carries telltale vocabulary and uniform sentence lengths. | Applied 9 humanization levers that reduce AI output detection by 80–90%. | Commit 98877a34 |
refactoring-fix | PR #265 lessons showed dotnet build can silently skip broken files during large refactors. | Enforced dotnet clean && dotnet build post-patch verification and compensation rules. | refactoring-fix/SKILL.md |
Conclusion
Using Semantica for causal reasoning alongside ai-raccoon's persistent storage and ai-badger's automated hooks addresses two frequent hurdles in AI software development: session memory loss and untraceable decision rationale.
Agents no longer make edits in isolation. Every significant architectural choice leaves a persistent, searchable reasoning trail that maintainers and future agent runs can verify.