Alfred
Agentic orchestration for LLMs that read and write real systems
Alfred is an orchestration engine that sits between an LLM and any database-backed system. You define what your data looks like, how intent maps to subdomains, and what persona the LLM should adopt in each context. Alfred handles routing, planning, tool execution, memory, and safety. It's published on PyPI and domain-agnostic by design.
pip install alfredagainv2.4.2Depth of Customization
Tools, subdomains, and personas combine endlessly
A domain defines its entities — what lives in the database. It groups those entities into subdomains — logical clusters that map to how users actually think and talk. Each subdomain gets its own persona: a set of instructions that shape how the LLM reasons, what it prioritizes, and how it speaks.
On top of that, a domain supplies middleware — hooks that run before and after every read or write — and custom tools that extend what the LLM can do beyond standard CRUD. Semantic search, ingredient lookups, email composition, chart generation — whatever the domain needs.
These layers multiply each other. A domain with six subdomains, each with its own persona, middleware that converts currencies and strips sensitive fields, and a custom tool for sending emails — that's not configuration. That's composition. The surface area for domain-specific behavior is intentionally deep.
Three Domains, One Engine
Same engine. Different minds.
Chef
Recipe management, meal planning, grocery coordination. The chef thinks in ingredients, portions, and timing. Semantic search, 4-tier ingredient lookup, cook mode with frozen recipe context.
10 entities, 7 subdomains
BI Analyst
Fantasy Premier League analytics on live data. The analyst thinks in statistics, trends, and visualizations. Sandboxed Python executor generates matplotlib charts inline.
117 tests, 14 DB tables
Sales Coach / Estimator / PM
Multi-tenant customer management across deals, estimates, design, construction, and billing. Three personas switch by subdomain — a sales coach thinks in pipeline velocity, an estimator thinks in margins, a PM thinks in schedule and budget.
Chef
Recipe management, meal planning, grocery coordination. The chef thinks in ingredients, portions, and timing. Semantic search, 4-tier ingredient lookup, cook mode with frozen recipe context.
10 entities, 7 subdomains
BI Analyst
Fantasy Premier League analytics on live data. The analyst thinks in statistics, trends, and visualizations. Sandboxed Python executor generates matplotlib charts inline.
117 tests, 14 DB tables
Sales Coach / Estimator / PM
Multi-tenant customer management across deals, estimates, design, construction, and billing. Three personas switch by subdomain — a sales coach thinks in pipeline velocity, an estimator thinks in margins, a PM thinks in schedule and budget.
You don't trust an abstraction until you've tested its limits.
The Graph
How work actually flows
Requests route, they don't chain. Simple reads skip planning entirely — Understand detects quick-mode and sends them straight to execution. Complex tasks expand into a plan with parallelizable step groups. Every path converges at a response and persisted state.
Five agents, each with a single responsibility. Understand resolves references and curates what stays in memory. Think decomposes intent into typed steps and decides whether to execute immediately, propose first, or ask for clarification. Act loops tools — CRUD operations plus any domain-specific tools — with retry limits and parallel execution within groups. Reply formats outcomes for humans. Summarize compresses the turn and persists the entity registry for next time.
Act Quick
Fast Path
Simple reads bypass Think and Act entirely
Understand
Memory Manager
Routes to: Act Quick, Think, or Reply
Think
Planner
Routes to: Act, or Reply directly
Act
Executor
Multi-tool loop
Reply
Formatter
All paths converge here
Summarize
Historian
How It Keeps LLMs Honest
Entity identity, approval, and layered context
LLMs hallucinate identifiers, write without permission, and lose track of what they've done. Alfred addresses each with a specific mechanism: deterministic entity refs, an approval model for generated content, and three independent context layers that give each agent only what it needs.
Entity Identity & Approval
Deterministic entity refs — Every database record gets a human-readable ref like recipe_1 or deal_3. Counters are monotonic and never reset within a session. LLMs never see UUIDs.
Strict CRUD boundary — Agents operate in ref space. The database operates in UUID space. Translation happens at the boundary through a single registry, not inside agents.
Approval-aware persistence — Generated content lives in memory with a gen_* prefix. Nothing writes to the database without explicit user promotion. The lifecycle is: generate, hold in memory, present for review, persist only on approval.
Ref Namespace
Agents, user messages, LLM decisions
SessionId
Registry
deterministic,
persists across turns
UUID Namespace
Database tables, CRUD operations
Ref Namespace
SessionIdRegistry
deterministic
UUID Namespace
Content Lifecycle
Generate
In memory
gen_recipe_1
User reviews
Persisted
real UUID
Removed
Generate
In memory
gen_recipe_1
User reviews
Persisted
Removed
Layered Context
Alfred maintains three independent layers of context, each serving a different purpose in the pipeline. This separation ensures agents receive only the context they need, reducing token waste and preventing cross-contamination between concerns.
Entity Context is deterministic — refs, labels, lifecycle state. Updated by CRUD operations, not LLM decisions. Conversation Context is compressed — last three turns in full, older turns summarized. Reasoning Context is auditable — what was planned, executed, and changed.
Entity Context
deterministic — CRUD-driven
Conversation Context
3 turns full → older compressed
Reasoning Context
2 summaries → older compressed
Entity Context
deterministic — CRUD-driven
Understand (reads) · Think (reads) · Act (reads, deep) · Reply (reads) · Summarize (writes)
Conversation Context
3 turns full → older compressed
Understand (reads) · Think (reads) · Reply (reads) · Summarize (writes)
Reasoning Context
2 summaries → older compressed
Think (reads) · Reply (reads) · Summarize (writes)
tap an agent to isolate its connections