Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions architectures/agentic-architecture/data-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, data-flow, orchestration, multi-agent-systems]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# 🌊 Agentic Architecture Data Flow

## Request Lifecycle

```mermaid
sequenceDiagram
participant User
participant Orchestrator
participant Planner
participant Coder
participant Reviewer
participant DB

User->>Orchestrator: Send Request
activate Orchestrator

Orchestrator->>Planner: Request Task Breakdown
Planner-->>Orchestrator: Execution Plan

Orchestrator->>Coder: Execute Coding Step
Coder-->>Reviewer: Code Output

Reviewer-->>Orchestrator: Code Verification

Orchestrator->>DB: Persist Approved State
Orchestrator-->>User: Final Result
deactivate Orchestrator
```

## Core Principles
1. **Delegation:** Orchestrator decomposes tasks and delegates.
2. **Handoff Validation:** Structured data must be validated between agent handoffs.
43 changes: 43 additions & 0 deletions architectures/agentic-architecture/folder-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, folder-structure, orchestration]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# 📁 Agentic Architecture Folder Structure

```mermaid
graph TD
User[User Request] --> Orchestrator[Orchestrator Agent]
Orchestrator --> |Decomposes task| Planner[Planner Agent]
Planner -.-> |Plan| Orchestrator
Orchestrator --> |Delegates| Coder[Coder Agent]
Orchestrator --> |Delegates| Reviewer[Reviewer Agent]
Coder -.-> |Code output| Reviewer
Reviewer -.-> |Verification| Orchestrator
Orchestrator --> DB[(Shared Context / Memory)]

%% Added Design Token Styles for Mermaid Diagrams
classDef default fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
classDef component fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;
classDef layout fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px,color:#000;

class User component;
class Orchestrator layout;
class Planner component;
class Coder component;
class Reviewer component;
class DB default;
```

## Directory Blueprint
```text
src/
├── 📁 orchestrator/ # Main coordinator agent
├── 📁 workers/ # Specialized worker agents (Planner, Coder, Reviewer)
└── 📁 memory/ # Shared context and validation schemas
```
72 changes: 72 additions & 0 deletions architectures/agentic-architecture/implementation-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, implementation-guide, orchestration]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# 🛠️ Agentic Architecture Implementation Guide

## 1. Monolithic Agent State Management

### ❌ Bad Practice
```typescript
class MonolithicAIAgent {
constructor(private readonly llm: LLMClient) {}

async handleRequest(userPrompt: string) {
// Agent attempts to plan, code, and review all at once with unbounded context
const fullContext = await this.gatherAllSystemContext();
const prompt = `Plan this out, write the code, and review it.
Here is the entire database context: ${fullContext}
Task: ${userPrompt}`;

const response = await this.llm.generate(prompt);
// Unsafe execution of non-deterministic output
eval(response.code);
return response;
}
}
```

### ⚠️ Problem
Loading a monolithic agent with unbounded context leads to "Context Explosion", resulting in non-deterministic hallucinations, excessive token costs, and security risks (like arbitrary code execution). A single LLM call attempting multiple distinct personas (Planner, Coder, Reviewer) fundamentally degrades reasoning quality.

### ✅ Best Practice
```typescript
interface AgentTask {
goal: string;
context: unknown;
}

class OrchestratorAgent {
constructor(
private readonly planner: PlannerAgent,
private readonly coder: CoderAgent,
private readonly reviewer: ReviewerAgent
) {}

async processTask(userPrompt: string) {
// 1. Specialized Planner Agent isolates the task roadmap
const executionPlan = await this.planner.plan({ goal: userPrompt, context: {} });

// 2. Specialized Coder Agent executes ONLY the specific sub-tasks
const codePayload = await this.coder.execute({ goal: executionPlan.codingSteps, context: executionPlan.schema });

// 3. Specialized Reviewer Agent deterministically validates the output
const isApproved = await this.reviewer.validate({ goal: 'Verify code matches schema', context: codePayload });

if (!isApproved) {
throw new Error("Validation failed in Review phase");
}

return codePayload;
}
}
```

### 🚀 Solution
Implementing an **Orchestrator-Worker pattern** strictly isolates responsibilities. Each specialized agent receives only the exact context required for its task (O(1) relevant context per agent), lowering token overhead and drastically increasing deterministic reliability. Validating structured data at every handoff ensures resilient, secure, and predictable Multi-Agent execution.
95 changes: 4 additions & 91 deletions architectures/agentic-architecture/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,101 +26,14 @@ last_updated: 2026-04-17

This architecture defines the operational boundaries for multi-agent workflows, specifically optimizing for context windows, token efficiency, and deterministic output.

- 🌊 **Data Flow:** Orchestrator-to-Worker execution paths.
- 📁 **Folder Structure:** Modular isolation of Prompts, Skills, and Contexts.
- ⚖️ **Trade-offs:** Latency vs. Reasoning depth.
- 🛠️ **Implementation Guide:** Rules for defining strict agent personas and constraints.

```mermaid
graph TD
User[User Request] --> Orchestrator[Orchestrator Agent]
Orchestrator --> |Decomposes task| Planner[Planner Agent]
Planner -.-> |Plan| Orchestrator
Orchestrator --> |Delegates| Coder[Coder Agent]
Orchestrator --> |Delegates| Reviewer[Reviewer Agent]
Coder -.-> |Code output| Reviewer
Reviewer -.-> |Verification| Orchestrator
Orchestrator --> DB[(Shared Context / Memory)]

%% Added Design Token Styles for Mermaid Diagrams
classDef default fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
classDef component fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;
classDef layout fill:#f3e5f5,stroke:#9c27b0,stroke-width:2px,color:#000;

class User component;
class Orchestrator layout;
class Planner component;
class Coder component;
class Reviewer component;
class DB default;
```
- 🌊 [**Data Flow:** Orchestrator-to-Worker execution paths](./data-flow.md)
- 📁 [**Folder Structure:** Modular isolation of Prompts, Skills, and Contexts](./folder-structure.md)
- ⚖️ [**Trade-offs:** Latency vs. Reasoning depth](./trade-offs.md)
- 🛠️ [**Implementation Guide:** Rules for defining strict agent personas and constraints](./implementation-guide.md)

## 🚀 The Core Philosophy

Agentic Architecture emphasizes the decomposition of monolithic tasks into granular, specialized agent workloads managed by a central Orchestrator. This resolves massive context window pollution and isolates functional logic.

> [!IMPORTANT]
> **AI Constraint:** Agents MUST NOT mutate shared global state directly. They must return deterministic structured data (e.g., JSON schema) to the Orchestrator, which strictly validates the payload before persisting it.

---

## 1. Monolithic Agent State Management

### ❌ Bad Practice
```typescript
class MonolithicAIAgent {
constructor(private readonly llm: LLMClient) {}

async handleRequest(userPrompt: string) {
// Agent attempts to plan, code, and review all at once with unbounded context
const fullContext = await this.gatherAllSystemContext();
const prompt = `Plan this out, write the code, and review it.
Here is the entire database context: ${fullContext}
Task: ${userPrompt}`;

const response = await this.llm.generate(prompt);
// Unsafe execution of non-deterministic output
eval(response.code);
return response;
}
}
```

### ⚠️ Problem
Loading a monolithic agent with unbounded context leads to "Context Explosion", resulting in non-deterministic hallucinations, excessive token costs, and security risks (like arbitrary code execution). A single LLM call attempting multiple distinct personas (Planner, Coder, Reviewer) fundamentally degrades reasoning quality.

### ✅ Best Practice
```typescript
interface AgentTask {
goal: string;
context: unknown;
}

class OrchestratorAgent {
constructor(
private readonly planner: PlannerAgent,
private readonly coder: CoderAgent,
private readonly reviewer: ReviewerAgent
) {}

async processTask(userPrompt: string) {
// 1. Specialized Planner Agent isolates the task roadmap
const executionPlan = await this.planner.plan({ goal: userPrompt, context: {} });

// 2. Specialized Coder Agent executes ONLY the specific sub-tasks
const codePayload = await this.coder.execute({ goal: executionPlan.codingSteps, context: executionPlan.schema });

// 3. Specialized Reviewer Agent deterministically validates the output
const isApproved = await this.reviewer.validate({ goal: 'Verify code matches schema', context: codePayload });

if (!isApproved) {
throw new Error("Validation failed in Review phase");
}

return codePayload;
}
}
```

### 🚀 Solution
Implementing an **Orchestrator-Worker pattern** strictly isolates responsibilities. Each specialized agent receives only the exact context required for its task (O(1) relevant context per agent), lowering token overhead and drastically increasing deterministic reliability. Validating structured data at every handoff ensures resilient, secure, and predictable Multi-Agent execution.
20 changes: 20 additions & 0 deletions architectures/agentic-architecture/trade-offs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
technology: Agentic Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [ai-agents, trade-offs, orchestration]
ai_role: Senior Software Architect
last_updated: 2026-04-17
---

# ⚖️ Agentic Architecture Trade-offs

## Pros and Cons

| Category | Factor | Description |
| :--- | :--- | :--- |
| ✅ **Advantage** | Determinism | Smaller, bounded context per agent leads to more reliable outputs. |
| ✅ **Advantage** | Token Efficiency | Passing only necessary context reduces API costs. |
| ❌ **Disadvantage** | Latency | Multiple agent hops take longer than a single monolithic request. |
| ❌ **Disadvantage** | Complexity | Managing handoffs, retries, and state between multiple agents is difficult. |
39 changes: 39 additions & 0 deletions architectures/microkernel-architecture/data-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
technology: Microkernel Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [plugin-architecture, data-flow, core-system]
ai_role: Senior Software Architect
last_updated: 2026-04-18
---

# 🌊 Microkernel Architecture Data Flow

## Request Lifecycle

```mermaid
sequenceDiagram
participant User
participant Core
participant Registry
participant Plugin

User->>Core: Trigger Action
activate Core

Core->>Registry: Lookup applicable Plugin
Registry-->>Core: Return Plugin Reference

Core->>Plugin: Execute Plugin Method (passing data)
activate Plugin
Plugin-->>Core: Return Result
deactivate Plugin

Core-->>User: Final Response
deactivate Core
```

## Core Principles
1. **Contract Enforcement:** All plugins must strictly adhere to the interfaces defined by the Core.
2. **Registry Lookup:** Execution relies on a dynamic registry mapping at runtime.
37 changes: 37 additions & 0 deletions architectures/microkernel-architecture/folder-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
technology: Microkernel Architecture
domain: Architecture
level: Senior/Architect
version: Agnostic
tags: [plugin-architecture, folder-structure, core-system]
ai_role: Senior Software Architect
last_updated: 2026-04-18
---

# 📁 Microkernel Architecture Folder Structure

```mermaid
graph TD
Core[Core System / Microkernel] --> Registry[Plugin Registry]
Registry --> PluginA[Payment Plugin]
Registry --> PluginB[Notification Plugin]
Registry --> PluginC[Analytics Plugin]

%% Added Design Token Styles for Mermaid Diagrams
classDef default fill:#e1f5fe,stroke:#03a9f4,stroke-width:2px,color:#000;
classDef component fill:#e8f5e9,stroke:#4caf50,stroke-width:2px,color:#000;

class Core default;
class Registry default;
class PluginA component;
class PluginB component;
class PluginC component;
```

## Directory Blueprint
```text
src/
├── 📁 core/ # Core system orchestrator and registry interfaces
├── 📁 plugins/ # Independent modules implementing core interfaces
└── 📁 shared/ # Data types and common utilities
```
Loading
Loading