|
1 | | -# Agent Kernel |
| 1 | +# Agent Kernel (Archived) |
2 | 2 |
|
3 | | -**A framework-agnostic foundation for building reliable, auditable AI agent systems.** |
| 3 | +> **This project has been superseded by [Experience Graph](https://github.com/ronsse/experience-graph).** |
4 | 4 |
|
5 | | -[](https://github.com/ORG/REPO/actions/workflows/ci.yml) |
6 | | -[](https://pypi.org/project/agentkernel/) |
7 | | -[](https://pypi.org/project/agentkernel/) |
8 | | -[](LICENSE) |
| 5 | +Agent Kernel was a framework-agnostic foundation for building reliable, auditable AI agent systems. The core ideas — schemas as contracts, governed execution, immutable traces, pluggable stores — have evolved into **Experience Graph**, an org-scale context graph and experience store for AI agents and teams. |
9 | 6 |
|
10 | | ---- |
| 7 | +## What changed? |
11 | 8 |
|
12 | | -## Overview |
| 9 | +Agent Kernel focused on agent *runtime* (planning, execution, tool brokering). Experience Graph focuses on the *knowledge layer* that agents read from and write to: |
13 | 10 |
|
14 | | -Agent Kernel separates **reasoning** (LLM-driven planning) from **execution** (deterministic tool running), giving you strict schema contracts, comprehensive trace logging, and pluggable components at every layer. |
| 11 | +- **Traces** — structured records of agent/human actions with outcomes |
| 12 | +- **Entities** — nodes in a shared knowledge graph |
| 13 | +- **Evidence** — provenance-tracked artifacts |
| 14 | +- **Precedents** — curated institutional knowledge extracted from traces |
| 15 | +- **Policies** — governance rules for the write pipeline |
| 16 | +- **Packs** — retrieval bundles assembled for specific tasks |
15 | 17 |
|
16 | | -### Core Principles |
| 18 | +## Migration |
17 | 19 |
|
18 | | -1. **Schemas are the contract.** Everything meaningful is a typed envelope. |
19 | | -2. **Separation of reasoning vs. execution.** LLM produces structured plan; deterministic executor runs tools. |
20 | | -3. **Kernel owns memory + traces.** Agent frameworks must *not* be the source of truth. |
21 | | -4. **Adapters everywhere.** Swap agent framework, vector store, graph store, LLM provider, or tool transport. |
22 | | -5. **Try fast, escalate on evidence.** Don't pre-classify complexity; use quality gates. |
| 20 | +The following components were ported to Experience Graph: |
23 | 21 |
|
24 | | ---- |
25 | | - |
26 | | -## Why Agent Kernel? |
27 | | - |
28 | | -| | Agent Kernel | LangChain/LangGraph | CrewAI | Pydantic AI | |
29 | | -|---|---|---|---|---| |
30 | | -| **Framework lock-in** | Zero -- swap engines freely | Moderate -- LangChain ecosystem | High -- CrewAI patterns | Low -- but limited scope | |
31 | | -| **Trace/audit** | Built-in immutable traces | Via LangSmith (external) | Limited | None built-in | |
32 | | -| **Tool governance** | Approval gates, rate limits, circuit breakers | Basic | Basic | None | |
33 | | -| **Reasoning control** | 4-tier adaptive escalation | Manual | Manual | None | |
34 | | -| **Memory ownership** | You own all data (local SQLite) | Framework-managed | Framework-managed | None | |
35 | | -| **Schema contracts** | Strict Pydantic throughout | Loose | Loose | Strict | |
36 | | - |
37 | | -**Key differentiators:** |
38 | | - |
39 | | -- **Framework-agnostic** -- use LangGraph, custom engines, or any LLM provider as a pluggable adapter |
40 | | -- **Immutable audit trails** -- every decision produces a `DecisionTrace` with full provenance |
41 | | -- **Tool governance** -- approval gates, rate limits, and circuit breakers (not just tool calling) |
42 | | -- **Adaptive reasoning** -- try fast, validate with quality gates, escalate on evidence |
43 | | -- **Local-first** -- own your data in local SQLite stores, no external services required |
44 | | - |
45 | | ---- |
46 | | - |
47 | | -## Features |
48 | | - |
49 | | -### Core |
50 | | - |
51 | | -- **Schema contracts** -- strict Pydantic models for all data flows (`ContextPacket`, `Plan`, `DecisionTrace`) |
52 | | -- **Separation of reasoning and execution** -- LLM proposes plans; deterministic executor validates and runs them |
53 | | -- **Immutable traces** -- complete audit trail of every decision, tool call, and outcome |
54 | | - |
55 | | -### Engines |
56 | | - |
57 | | -- **Pluggable agent engines** -- swap LangGraph, Semantic Kernel, or custom implementations |
58 | | -- **Adaptive reasoning** -- 4-tier thinking policy with automatic escalation (routing -> standard -> deep -> deep+critic) |
59 | | -- **Quality gates** -- deterministic plan validation before execution |
60 | | -- **Critic engine** -- optional second-opinion pass for high-reliability tasks |
61 | | - |
62 | | -### Tools |
63 | | - |
64 | | -- **Tool Broker** -- single point of tool execution with input validation and logging |
65 | | -- **Approval gates** -- human-in-the-loop for sensitive operations |
66 | | -- **Retry + circuit breaker** -- exponential backoff and cascading failure prevention |
67 | | -- **Rate limiting** -- per-capability rate control |
68 | | - |
69 | | -### Memory |
70 | | - |
71 | | -- **Document store** -- full-text storage with content hashing |
72 | | -- **Vector index** -- semantic search via LanceDB |
73 | | -- **Knowledge graph** -- typed nodes and edges with 30+ node types |
74 | | -- **Event log** -- append-only system event stream |
75 | | - |
76 | | -### Operations |
77 | | - |
78 | | -- **Workflow runner** -- state machine for multi-step agent workflows |
79 | | -- **Scheduler** -- cron, file watch, event, and workflow triggers |
80 | | -- **CLI** -- comprehensive Typer-based command-line interface |
81 | | -- **REST API** -- FastAPI server with full kernel access |
82 | | - |
83 | | ---- |
84 | | - |
85 | | -## Quick Start |
86 | | - |
87 | | -### Installation |
88 | | - |
89 | | -```bash |
90 | | -pip install agentkernel |
91 | | - |
92 | | -# Or with optional extras |
93 | | -pip install agentkernel[vectors,api] |
94 | | -``` |
95 | | - |
96 | | -### Minimal Example |
97 | | - |
98 | | -```python |
99 | | -import asyncio |
100 | | -from agent_kernel import ( |
101 | | - AgentProfile, CapabilityRegistry, ContextPacket, |
102 | | - DeterministicExecutor, Plan, ToolBroker, |
103 | | -) |
104 | | -from agent_kernel.core.schemas import ( |
105 | | - ApprovalPolicy, ContextPolicy, ModelConfig, RiskAssessment, |
106 | | -) |
107 | | -from agent_kernel.tracing.sinks.sqlite_sink import SQLiteTraceSink |
108 | | - |
109 | | -# In-memory stores (no API keys needed) |
110 | | -trace_store = SQLiteTraceSink(":memory:") |
111 | | -broker = ToolBroker(registry=CapabilityRegistry(), enable_circuit_breaker=False) |
112 | | -executor = DeterministicExecutor(tool_broker=broker, trace_store=trace_store) |
113 | | - |
114 | | -profile = AgentProfile( |
115 | | - agent_profile_id="demo", name="Demo Agent", |
116 | | - llm_config=ModelConfig(provider="stub", model="stub"), |
117 | | - context_policy=ContextPolicy(must_cite=False), |
118 | | - approval_policy=ApprovalPolicy(), |
119 | | -) |
120 | | - |
121 | | -async def main(): |
122 | | - context = ContextPacket(intent="What should I work on today?") |
123 | | - plan = Plan( |
124 | | - intent=context.intent, |
125 | | - summary="Focus on the top 3 priority tasks", |
126 | | - risk=RiskAssessment(level="low", reasons=["No actions"]), |
127 | | - ) |
128 | | - trace = await executor.execute( |
129 | | - plan=plan, context_packet=context, |
130 | | - agent_profile=profile, engine_id="stub", |
131 | | - ) |
132 | | - print(f"Trace: {trace.trace_id} | Outcome: {trace.outcome.status.value}") |
133 | | - |
134 | | -asyncio.run(main()) |
135 | | -``` |
136 | | - |
137 | | -See the [examples directory](examples/) and [documentation](https://ORG.github.io/REPO/) for more. |
138 | | - |
139 | | ---- |
140 | | - |
141 | | -## Architecture |
142 | | - |
143 | | -``` |
144 | | - AGENT KERNEL |
145 | | -
|
146 | | - +--------------+ +--------------+ +----------------+ |
147 | | - | Context |--->| Agent |--->| Deterministic | |
148 | | - | Assembler | | Engine | | Executor | |
149 | | - +--------------+ +--------------+ +----------------+ |
150 | | - | | | |
151 | | - | +------+------+ | |
152 | | - | v v | |
153 | | - | +----------+ +-----------+ | |
154 | | - | | Thinking | | Quality | | |
155 | | - | | Policy | | Gates | | |
156 | | - | +----------+ +-----------+ | |
157 | | - | | | | |
158 | | - | +------+------+ | |
159 | | - | v | |
160 | | - | +--------------+ | |
161 | | - | | Escalation | | |
162 | | - | | Manager | | |
163 | | - | +--------------+ | |
164 | | - v v |
165 | | - +--------------+ +--------------+ +--------------+ |
166 | | - | Memory | | Plan | | Tool | |
167 | | - | Subsystem | | Schema | | Broker | |
168 | | - +--------------+ +--------------+ +--------------+ |
169 | | - | | |
170 | | - +------------------+-------------------+ |
171 | | - v |
172 | | - +--------------+ |
173 | | - | Trace | |
174 | | - | Store | |
175 | | - +--------------+ |
176 | | -``` |
177 | | - |
178 | | -### Key Components |
179 | | - |
180 | | -| Component | Description | |
181 | | -|-----------|-------------| |
182 | | -| **Context Assembler** | Deterministic retrieval from memory stores into `ContextPacket` | |
183 | | -| **Agent Engine** | Pluggable: LLM produces `Plan` from `ContextPacket` | |
184 | | -| **Thinking Policy** | Controls reasoning budget per task (tiers 0-3) | |
185 | | -| **Quality Gates** | Deterministic plan validation | |
186 | | -| **Escalation Manager** | Attempt, gate, escalate flow | |
187 | | -| **Deterministic Executor** | Validates plan, gates approvals, executes via Tool Broker | |
188 | | -| **Tool Broker** | Single point of tool execution with validation + logging | |
189 | | -| **Memory Subsystem** | Document store, vector index (LanceDB), graph store, event log | |
190 | | -| **Trace Store** | Immutable audit trail of all decisions and executions | |
191 | | -| **Workflow Runner** | State machine for multi-step agent workflows | |
192 | | -| **Context Graph** | Trace decomposition, knowledge graph, event clock | |
193 | | -| **LLM Cache** | Tier-aware semantic response caching | |
194 | | -| **Feedback Loops** | Success rate routing, cost anomaly detection, adaptive timeouts | |
195 | | - |
196 | | ---- |
197 | | - |
198 | | -## Project Structure |
199 | | - |
200 | | -``` |
201 | | -agent-kernel/ |
202 | | -+-- src/agent_kernel/ # Main kernel source code |
203 | | -| +-- core/ |
204 | | -| | +-- schemas/ # Pydantic models (THE contract) |
205 | | -| | +-- config.py # Pydantic Settings |
206 | | -| | +-- ids.py # ULID generation |
207 | | -| | +-- errors.py # Custom exceptions |
208 | | -| +-- memory/ # Document, vector, graph, event stores |
209 | | -| +-- tools/ # Tool broker, registry, adapters |
210 | | -| +-- context/ # Context assembler |
211 | | -| +-- context_graph/ # Trace decomposition, knowledge graph |
212 | | -| +-- engine/ # Agent engines, thinking policy, escalation |
213 | | -| +-- executor/ # Deterministic executor, approval gates |
214 | | -| +-- workflows/ # Workflow runner, specs |
215 | | -| +-- scheduler/ # Cron scheduling, file watchers |
216 | | -| +-- services/ # LLM, embedding, vault indexer, enrichment |
217 | | -| +-- integrations/ # Calendar, task sync adapters |
218 | | -| +-- tracing/ # Trace store and sinks |
219 | | -| +-- api/ # FastAPI REST server |
220 | | -| +-- cli/ # Typer CLI |
221 | | -+-- configs/ |
222 | | -| +-- capabilities/ # Capability definition YAMLs |
223 | | -+-- tests/ # Unit and integration tests |
224 | | -+-- examples/ # Example applications |
225 | | -+-- docs/ # Documentation source |
226 | | -+-- pyproject.toml # Project config |
227 | | -``` |
228 | | - |
229 | | ---- |
230 | | - |
231 | | -## Testing |
232 | | - |
233 | | -```bash |
234 | | -# Run all tests |
235 | | -make test |
236 | | - |
237 | | -# Run unit tests only |
238 | | -make test-unit |
239 | | - |
240 | | -# Run with coverage |
241 | | -make test-cov |
242 | | - |
243 | | -# Run specific test file |
244 | | -pytest tests/unit/engine/test_escalation.py -v |
245 | | -``` |
246 | | - |
247 | | ---- |
248 | | - |
249 | | -## Development |
250 | | - |
251 | | -```bash |
252 | | -# Setup |
253 | | -uv venv && source .venv/bin/activate |
254 | | -uv pip install -e ".[dev]" |
255 | | -cp .env.example .env |
256 | | - |
257 | | -# Quality checks |
258 | | -make lint # Lint with ruff |
259 | | -make format # Format code |
260 | | -make typecheck # Type checking with mypy |
261 | | -make test # Run all tests |
262 | | - |
263 | | -# Pre-commit hooks run automatically on commit |
264 | | -``` |
265 | | - |
266 | | -See [CONTRIBUTING.md](CONTRIBUTING.md) for full development guidelines. |
267 | | - |
268 | | ---- |
269 | | - |
270 | | -## Documentation |
271 | | - |
272 | | -Full documentation is available at [https://ORG.github.io/REPO/](https://ORG.github.io/REPO/), including: |
273 | | - |
274 | | -- Architecture and design guides |
275 | | -- API reference |
276 | | -- Example walkthroughs |
277 | | -- Integration patterns |
278 | | - |
279 | | ---- |
| 22 | +| Agent Kernel | Experience Graph | |
| 23 | +|---|---| |
| 24 | +| Store backends (SQLite doc/graph/vector/event) | `xpgraph/stores/` | |
| 25 | +| ULID generation, content hashing | `xpgraph/core/` | |
| 26 | +| Pydantic base models + versioning | `xpgraph/schemas/` | |
| 27 | +| Importance scoring + hybrid search | `xpgraph/retrieve/` | |
| 28 | +| DeterministicExecutor | `xpgraph/mutate/` (governed write pipeline) | |
| 29 | +| Enrichment service | `xpgraph_workers/enrichment/` | |
| 30 | +| Experience miner | `xpgraph_workers/learning/` | |
| 31 | +| Thinking policy | `xpgraph_workers/engine/` | |
| 32 | +| Vault indexer | `integrations/obsidian/` | |
280 | 33 |
|
281 | 34 | ## License |
282 | 35 |
|
|
0 commit comments