| name | ai-agent-architecture |
| description | Decision navigator for designing reliable agent systems. Guides any AI agent through 10 architectural decisions derived from 3 production systems (Claude Code, OpenClaw, Hermes) and 7 real production disasters. Two modes: /design (new system) and /audit (existing system). |
| keywords | ["agent","AI agent","multi-agent","MCP","tool use","architecture","ๆบ่ฝไฝ","ไปฃ็","agent ่ฎพ่ฎก","ๅทฅๅ
ท่ฐ็จ","ๆถๆ"] |
| type | reference-based |
CONSUMES: User agent system requirements or existing agent codebase
PRODUCES: 10 architecture decisions + design document or audit report with P0/P1/P2 findings
AI Agent Architecture
A decision-by-decision navigator for building reliable agent systems. Each decision has a selection matrix derived from production systems. Each skipped decision has a documented production disaster.
Audience: AI agents designing other agent systems.
Two modes:
/design โ Walk through D1โD10 for a new system
/audit โ Check an existing system against all 10 decisions
How to Use This Pack
On activation, detect the user's intent:
- Contains: "design / build / create / new agent / architect" โ enter
/design mode
- Contains: "review / audit / check / existing / evaluate" โ enter
/audit mode
- Ambiguous โ ask: "Are you designing a new agent system or auditing an existing one?"
/design Mode
Phase 0 โ Scoping (Ask BEFORE reading any reference file)
Ask the following 5 questions. Collect all answers before proceeding to Phase 1.
Q1 โ Scale: Single agent or multi-agent system?
- Single agent โ D2 (coordination) is likely skipped
- Multi-agent โ D2 is mandatory
Q2 โ Session model: Stateful (long sessions, multi-turn continuity) or stateless (single-turn, ephemeral)?
- Stateless โ D3 (memory) may be skipped, simplified D6 (compression) sufficient
- Stateful โ D3 and D6 are mandatory
Q3 โ Input trust boundary: Trusted inputs only (internal systems, authenticated users) or untrusted external data (web, email, third-party APIs)?
- Trusted only โ D5 (permissions) is simplified, MCP checklist optional
- Untrusted external โ D5 MCP checklist is mandatory, dual-agent architecture required
Q4 โ Context budget: Small model (<128K context) or large context model (โฅ512K)?
- Small โ D6 (compression) is critical, D3 memory pattern selection is strict
- Large โ D6 triggers are relaxed, but still required
Q5 โ Cost sensitivity: Hobby/prototype or production at scale (>1K sessions/day)?
- Prototype โ D7 (cost) optional, D8 (observability) minimal
- Production โ D7 and D8 are mandatory from day 1
After scoping, output:
Applicable decisions: D[X], D[Y], D[Z]...
Skipped: D[A] because [user is stateless, no cross-session memory needed], D[B] because [trusted inputs only]
Then proceed to Phase 1 with ONLY the applicable decisions.
Phase 1 โ Walk Through Each Applicable Decision
For each applicable decision, in order:
- Read
references/{decision}.md
- Apply the selection matrix against the user's scoping answers
- Recommend one specific pattern with a brief rationale
- Record:
Decision: [pattern name] | Rationale: [X constraint โ Y pattern] | Cost impact: [Z]
- Move to the next applicable decision
After all decisions, output the Architecture Decision Document:
## Architecture Decision Document
Generated: [date]
Agent Complexity: D1 โ [Level chosen]
Coordination Topology: D2 โ [Pattern chosen] (or: SKIPPED โ [reason])
Memory Architecture: D3 โ [Pattern chosen] (or: SKIPPED โ [reason])
Tool Loading: D4 โ [Strategy chosen]
Permission Model: D5 โ [Level chosen], MCP checklist: [applied/optional]
Compression Strategy: D6 โ [Pipeline chosen]
Cost Controls: D7 โ [Routing + budget cap strategy]
Observability: D8 โ [Logging + alerting strategy] (or: SKIPPED โ prototype)
Testing Approach: D9 โ [Invariant strategy]
Disaster Prevention: D10 โ [Top 3 applicable incidents reviewed]
Total estimated token cost per session: [range]
Estimated production monthly cost at 1K sessions/day: [range]
/audit Mode
Read the user's existing agent code or design description.
For each of D1โD10, check:
- Was this decision made explicitly?
- If yes, does it match the recommended pattern for the agent's constraints?
- If no (decision was skipped), flag with the production disaster it enables
Output the Architecture Audit Report:
## Architecture Audit Report
Decision | Status | Finding
-----------|---------------|--------
D1 (agent) | โ
Addressed | Level 3 Orchestrator โ appropriate for task
D2 (coord) | โ ๏ธ Incomplete | Hub-spoke used but no idempotency tokens โ Incident #7 risk
D3 (mem) | โ Missing | No memory strategy declared โ Incident #4 risk (stale state)
...
## Risk Assessment
High: [decisions where the specific disaster is likely given this system's constraints]
Medium: [decisions skipped but low-probability disaster for this topology]
Low: [decisions not applicable or well-implemented]
## Recommended Actions (Priority Order)
1. [Missing D, risk: disaster reference]
2. ...
Decision Reference Index
| Decision | File | Core Question |
|---|
| D1 โ Need an Agent | references/need-an-agent.md | Do you even need an agent? |
| D2 โ Coordination | references/coordination-and-state.md | How should agents coordinate and sync state? |
| D3 โ Memory | references/context-memory.md | How should context and memory be stored? |
| D4 โ Tools | references/tool-management.md | How to load and manage tools efficiently? |
| D5 โ Permissions | references/permissions-safety.md | What is the agent allowed to do? MCP security? |
| D6 โ Compression | references/context-compression.md | What happens when context fills up? |
| D7 โ Cost | references/cost-token-economics.md | How to control token cost and API budget? |
| D8 โ Observability | references/observability.md | How to see what the agent is doing in production? |
| D9 โ Testing | references/testing-evaluation.md | How to prove the agent behaves correctly? |
| D10 โ Disasters | references/production-disasters.md | What production failures do these decisions prevent? |
Anti-Skip Table
| Excuse to Skip a Decision | Why It's Wrong | Legitimate Skip Condition |
|---|
| "This is just a prototype, we'll add observability later" | Retrofitting traces into a live multi-agent system takes 3-6 weeks. Launch with at minimum JSONL logging โ it costs 2 hours now vs weeks later. | Skip full dashboards for prototypes; keep basic JSONL logging always. |
| "Context compression is for long sessions, mine are short" | "Short" sessions become "long" sessions as scope creep happens. A session that was designed for 10 turns often runs 40. Build compression before you need it. | Skip only if hard limit enforces session length (enforced budget cap, not just hope). |
| "We don't need permission design for internal tools" | Internal tools accessed by an agent can still cause PocketOS-style disasters. Scoped tokens and deny-first apply equally to internal APIs. | Skip only if agent is read-only (no writes, no destructive operations). |
| "Multi-agent coordination is premature until we need it" | Adding hub-spoke state management after two agents are live requires touching both agents simultaneously. Design the state ownership model before the second agent is built. | Skip only if permanently single-agent (verify: is there a second agent planned in the next 3 months?). |
| "We'll test it when it's done" | Agent testing requires production traces. You cannot write stochastic invariant tests without observing real behavior. Start collecting traces on day 1 even if you don't analyze them immediately. | Skip full evaluation suite for exploratory prototypes; collect basic traces always. |
Source Attribution
Built from research across 102+ sources including:
- Claude Code (Anthropic) โ architecture analysis, 12-session course
- OpenClaw โ multi-channel gateway source code (14 sources)
- Hermes (NousResearch) โ self-evolution, compression, memory source code (16 sources)
- OWASP LLM Top 10 โ security taxonomy
- Elastic Security Labs โ MCP attack research
- Invariant Labs โ tool shadowing documentation
- Anthropic "Building Effective Agents" โ coordination patterns
Full attribution: see LICENSE-ATTRIBUTION.md