# Design decisions

All 41 architecture decision records of AgenticMind, summarised. What was decided, and why.

Source: https://glamorous-boar.cloudvent.net/architecture/decisions/

---

AgenticMind records every significant decision as an ADR (Context → Decision → Consequences → Revisit when) in `docs/adr/` of the main repository. This page summarises them, grouped by theme. They are the best answer to *why does it work this way?*

## Foundation

| ADR | Decision | Why it matters |
|---|---|---|
| 0001 | **Own IR and first-party runtime; frameworks as adapters.** | Stable semantics, uniform traces, export independent of any framework's data model. |
| 0002 | **Monorepo**: uv workspace (Python 3.11, Pydantic 2, FastAPI, SQLAlchemy 2) + npm workspace (React 18, strict TypeScript, Vite, React Flow, Tailwind). | Each subsystem is an independently versioned package; the runtime embeds in generated projects. |
| 0003 | **SQLite by default, PostgreSQL via URL; append-only revisions** with content hashes and optimistic concurrency. | Zero-setup local dev; reproducible runs; cheap history. |
| 0004 | **Only core nodes run in-process** until isolation exists; trust assigned from the distribution. | Safe by default. (Partly superseded by 0021.) |
| 0005 | **Runs as asyncio tasks** in the API process, behind a `RunManager` seam. | No Redis needed early. (Superseded by 0039.) |
| 0006 | **Distinct data and control edges**, OR-join, skip propagation, fail-fast, strict typing, deterministic joins. | Deterministic, explainable runs. |
| 0007 | **Project files in a scoped artifact store**, referenced by ID; allow-listed types, size limit, attachment downloads. | IR stays free of file contents; safe uploads. |

## RAG

| ADR | Decision |
|---|---|
| 0008 | Embedding providers (fastembed local default), vector store adapters, **handles** shared by ingestion and query, re-index skipping, dimension/model mismatch errors, **run targets**. |
| 0009 | OpenRouter provider (Gemini default), **Context Builder** (numbered sources, budget) and **Citation Builder** (marker parsing, invalid-citation removal); Chat panel. Old node versions stay registered. |
| 0015 | **BM25 keyword index** next to every collection, **Hybrid Search** (RRF), **Reranker** (local cross-encoder), **Query Rewriter**, **Context Compressor** that cannot introduce text. |
| 0027 | **Chunker 1.1.0**: sentence, layout, semantic, document and parent-child strategies, all exact slices; **Parent Expander**; layout-aware PDF/HTML/DOCX parsing. |
| 0028 | Eight more vector stores (FAISS, LanceDB, Milvus, Weaviate, Elasticsearch, OpenSearch, MongoDB Atlas, Redis); **one score scale**. |

## Agents

| ADR | Decision |
|---|---|
| 0010 | **Tools are handles** wired into the Agent; a **bounded agent loop** (turns, tool calls, tokens, cost); schema-validated arguments; errors returned to the model; starter tools. |
| 0011 | **Paired loop regions** (no back edges), Router with config-defined routes, AND **Join**. |
| 0012 | **Conversation state separate from consented long-term memory**; retention, namespaces, deletion. |
| 0013 | **Durable checkpoints, Human Approval suspension, resume**; waiting runs hold no resources. |
| 0014 | **Subagent handoff**, Planner, Critic; third-party tool discovery. |
| 0029 | Agent architectures (**function calling, ReAct, plan-and-execute**); **Reasoning** node (CoT, self-consistency, decomposition, ToT, GoT, MCTS, backtracking); Tool Router; Tool Chain. |
| 0030 | More reasoning (self-refine, Reflexion, debate, mixture of agents, step-back, program of thought); **Classifier**; **Summarizer**. |
| 0041 | **Faster agent runs**: permanent tool failures shared across sub-agents, `reasoning_effort`, provider retries before streaming, visible token counts. |

## Data and semantic

| ADR | Decision |
|---|---|
| 0018 | **Read-only database access twice** (sqlglot policy + read-only connections), NL-to-SQL with retries and an explicit *not answerable* path, SQL Tool. |
| 0019 | **NVIDIA Auto Ontology adapter**: pinned commit, vendored contract, contract tests, capability checks. |
| 0024 | **Model Router** (keywords/classifier/hybrid); XLSX/PPTX/EPUB/JSONL/TSV/XML/YAML uploads with zip-bomb limits; project deletion confirmed by typing DELETE. |
| 0025 | **Image** port type, Image Input/Loader, vision LLM 1.2.0, Ollama and Hugging Face providers, **RapidOCR**. |
| 0026 | Nine database engines with secret-backed credentials, **S3 Loader** with SSRF guard, **encrypted workspace secrets**. |

## Platform

| ADR | Decision |
|---|---|
| 0016 | **Compiler**: IR → standalone, vendored, tested, reproducible FastAPI project, API-key auth failing closed. |
| 0017 | **Evaluation Lab**: immutable dataset versions, versioned evaluators, judges as labelled estimates, every case a real run, comparability checks. |
| 0020 | **Deployment Center**: derived requirements, cited vendor limits, hash-bound confirmation, local Docker with health-checked switch-over and rollback. |
| 0021 | **Node packages in isolated workers**: never import third-party code into the platform; exact-permission approval; `agenticmind-node` CLI. |
| 0022 | **Wingman**: the model proposes whole graphs, the platform validates (repair loop) and saves a revision with Undo. |
| 0023 | **Sign-in, roles and workspace settings**: scrypt, hashed session cookies, cross-site write guard. |
| 0031 | **Guardrails**: Input Guard, Output Guard (with repair), PII Redactor; pure check functions; explicit branches. |
| 0032 | **Open-source defaults**: sign-in off by default, localhost binding, MIT licence. |

## Production plan (ADR-0032 onwards)

| ADR | Decision |
|---|---|
| 0033 | **MCP client and server**: MCP Server and MCP Call nodes; projects exposed at `/api/mcp`; `agenticmind mcp-serve`. |
| 0034 | **Sandboxed code execution**: locked-down Docker by default; operator chooses the backend; Code node and Code Interpreter tool. |
| 0035 | **Triggers**: webhook, schedule, queue and chat channels with per-platform signature checks and replies. |
| 0036 | **Native model providers**: OpenAI, Anthropic (official SDK), Gemini, Azure, Bedrock, Mistral, Groq, DeepSeek, Together, xAI. |
| 0037 | **Observability export**: runs as OpenTelemetry GenAI traces after the fact; Prometheus metrics. |
| 0038 | **GitHub version control**: atomic fast-forward-only commits of canonical IR; remote-change detection. |
| 0039 | **Durable execution**: database job queue, leases, heartbeats, automatic resume, separate workers, one trigger leader. |
| 0040 | **Streaming**: provider streaming, batched deltas served across processes, one-call streaming endpoint. |

## Recurring themes

Reading the ADRs together, a few habits stand out, and they make good presentation talking points:

- **Verify upstream before integrating.** Every provider, protocol and vendor limit was checked against current documentation and cited.
- **Tested vertical slices, verified live.** Most ADRs end with a live verification against a real model and the bugs that live testing found.
- **Honest limits.** Each records what is *not* supported and when to revisit it.
- **Old versions keep working.** New behaviour ships as a new node version.
