The Cognitive Stack
Five layers: Interface, Orchestration, Reasoning, Knowledge, Action. A reference architecture.
The Cognitive Stack
What it is
A modular reference architecture for adaptive AI systems. How perception, reasoning, and memory fit together. Shared vocabulary, so engineers, designers, and researchers can talk about the same thing.
The five layers
| Layer | Function | Example Components | | ----------------------- | ------------------------------------------------- | ---------------------------------------------------- | | Interface Layer | Captures input, displays output | UI, chat, voice I/O, API endpoints | | Orchestration Layer | Routes tasks between models and tools | Agent frameworks, execution graphs, workflow engines | | Reasoning Layer | Interprets, plans, generates | LLMs, planners, logic engines | | Knowledge Layer | Context, grounding, long-term memory | RAG pipelines, vector stores, structured databases | | Action Layer | Executes tasks | APIs, automation scripts, external systems |
Intelligence emerges when context moves between these layers without loss.
How layers interact
Interface ↔ Orchestration
The interface captures intent. The orchestrator breaks it into sub-tasks.
- User: "Generate a motion graphic from this layout."
- Interface parses text and image.
- Orchestration picks the reasoning and tool path.
Orchestration ↔ Reasoning
The orchestrator decides whether to invoke a model, a retriever, a planner, or a function.
Reasoning ↔ Knowledge
When context runs out, the reasoning layer queries the knowledge base. That's RAG.
Reasoning ↔ Action
After a plan, the reasoning layer triggers actions. Results loop back through perception.
The loop
[1] Input captured (Interface)
[2] Intent parsed (Orchestration)
[3] Reasoning & planning (Reasoning)
[4] Retrieve background (Knowledge)
[5] Execute via tools (Action)
[6] Log + update memory (Knowledge)
[7] Generate response (Interface)
Each pass refines state. The metric isn't fluency. It's loop efficiency — how quickly the system settles into coherent action.
Design principles
1. Context first
Intelligence quality is proportional to context quality, not model size. Architect for retrieval, embeddings, schema, summarisation.
2. Decouple perception from cognition
Input processing is its own module. It normalises mess into structure before reasoning starts.
3. Tools as cognitive extension
Tools aren't side features. They're extensions of reasoning. Build them callable, composable, typed.
4. Transparent reasoning
Every chain is inspectable. Log intermediate prompts, tool calls, retrieved context. Non-negotiable.
5. Memory as a graph
Stop modelling memory as linear history. Use a graph of events, contexts, outcomes. Traversable.
6. Feedback over rules
Replace static control logic with reinforcing feedback loops. Systems evaluate their own output and adjust.
7. Humans in the reflective loop
Operators set learning boundaries, validate outcomes, define what "good reasoning" means.
A working stack
| Layer | Tools I'd reach for | | ----------------- | -------------------------------------------------------------------- | | Interface | Next.js, Vercel AI SDK, REST | | Orchestration | OpenAI Agent Builder, LangChain, custom graph controller | | Reasoning | GPT-4.1, Claude, local LLMs | | Knowledge | Supabase (pgvector), Redis, JSON document store | | Action | Internal APIs, third-party (Notion, Figma, Slack) |
Scales horizontally by adding agents. Scales vertically by adding domain modules.
Measuring intelligence
| Dimension | Description | Metric | | ----------------------- | ----------------------------------------- | ---------------------------- | | Context Depth | Breadth and precision of retrieved data | Retrieval precision / recall | | Reasoning Coherence | Consistency of multi-step plans | Agent task success rate | | Adaptability | Adjustment to feedback or new data | Error correction rate | | Transparency | Clarity of reasoning traces | % of explainable decisions |
Not chasing AGI. Chasing scalable contextual intelligence — systems that adapt reliably inside a defined domain.
Why this matters
Intelligence as infrastructure, not as a monolith. Separate perception, cognition, memory into interoperable layers and the system can grow without collapsing into complexity.