# hardness1020/awesome-agent-architecture architecture

> Architecture diagram of the GitHub repository hardness1020/awesome-agent-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hardness1020/awesome-agent-architecture
- Repository: https://github.com/hardness1020/awesome-agent-architecture

## Overview

#### Purpose and Structure
This is an educational, incremental reconstruction of modern LLM-agent harness architecture, primarily studying Claude Code and Hermes Agent patterns. It is not one deployable agent: 22 self-contained sections progressively evolve a runnable Python harness. Each later section copies and extends the prior section, making adjacent diffs the intended implementation narrative. Core documentation begins at `README.md` and `sections/00-harness-thesis/README.md`.

#### Entry Points and Runtime
For each runnable stage, `src/demo.py` is the live Anthropic API entry point and `src/test.py` is the offline validation entry point; the central execution implementation is always `src/loop.py`, e.g. `sections/01-agent-loop/src/demo.py`, `sections/01-agent-loop/src/loop.py`, and `sections/21-loop-engineering/src/demo.py`. The runtime is Python with dependencies from `requirements.txt`, configured through `.env` / `.env.example`. External model access is Anthropic-compatible, using `ANTHROPIC_API_KEY`, optional model selection, and optional base URL.

#### Core Agent Loop and Tool Boundary
The baseline loop maintains conversation `messages[]`, calls the LLM, interprets terminal versus tool-use stop reasons, appends tool results, and repeats until it can answer. It originates in `sections/01-agent-loop/src/loop.py`. Tool registration, schemas, routing, and execution are added at `sections/02-tool-runtime/src/tools.py` and integrated through `sections/02-tool-runtime/src/loop.py`. This is the primary model/harness boundary: the model requests actions; deterministic Python owns execution and feeds observations back.

#### Safety, Extensibility, and Deliberate Work
Permission policy and sandboxing gate side-effecting tools before dispatch, separating authorization from tool implementation: `sections/03-permission-sandbox/src/permissions.py`, `sections/03-permission-sandbox/src/tools.py`. Lifecycle and tool interception hooks provide extension points in `sections/04-hooks/src/hooks.py`. Complex work is decomposed into plans/todos and isolated child loops/subagents in `sections/05-planning-todos/src/planning.py` and `sections/06-subagents/src/subagents.py`.

#### Context, Knowledge, and Reliability
Capabilities are loaded progressively from skill definitions such as `sections/07-skills/src/skills.py` and `sections/07-skills/src/skills/pdf-fill/SKILL.md`. Context management controls prompt-window pressure through budgeting and compaction (`sections/08-context-management/src/context.py`); persistent cross-run knowledge is managed separately (`sections/09-memory/src/memory.py`). Prompt construction composes system instructions and live harness state in `sections/10-system-prompt/src/prompt.py`, while retry, overflow, and fallback behavior form an explicit resilience boundary in `sections/11-error-recovery/src/recovery.py`.

#### Durable and Concurrent Execution
The harness grows from turn-local work to persistent task records and dependencies (`sections/12-task-system/src/tasks.py`), background handles/notifications (`sections/13-background-execution/src/background.py`), and scheduling (`sections/14-scheduling/src/scheduler.py`). Parallel code work can be isolated with Git worktrees in `sections/15-worktree-isolation/src/worktree.py`. These stages introduce durable/asynchronous control flow around the foreground model loop.

#### Multi-Agent, Integration, and Final Composition
Agents coordinate through mailbox-based messaging and higher-level protocols in `sections/16-coordination/src/mailbox.py` and `sections/17-protocols/src/protocols.py`; autonomy adds idle-cycle task claiming in `sections/18-autonomy/src/autonomy.py`. External integrations assemble MCP, plugins, and channels in `sections/19-mcp-plugins-channels/src/mcp.py`. Observability adds telemetry (`sections/20-observability/src/telemetry.py`), and the final composition introduces verification-loop engineering in `sections/21-loop-engineering/src/verify.py` alongside the accumulated orchestrator at `sections/21-loop-engineering/src/loop.py`.

Main entry points: [`sections/01-agent-loop/src/loop.py`](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/01-agent-loop/src/loop.py) (Baseline agent loop), [`sections/02-tool-runtime/src/tools.py`](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/02-tool-runtime/src/tools.py) (Tool runtime), [`sections/10-system-prompt/src/prompt.py`](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/10-system-prompt/src/prompt.py) (System prompt builder), [`sections/21-loop-engineering/src/loop.py`](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/21-loop-engineering/src/loop.py) (Engineered orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_learning["Progressive stages"]
  node_docs["Architecture thesis<br/>documentation<br/>[README.md]"]
end

subgraph group_core["Core harness"]
  node_baseline{{"Baseline agent loop<br/>Python loop<br/>[loop.py]"}}
  node_demo["Runnable API demo<br/>Python entry point<br/>[demo.py]"]
  node_model(("Anthropic-compatible API<br/>external model API"))
  node_tool_runtime["Tool runtime<br/>tool registry<br/>[tools.py]"]
  node_permission["Permission sandbox<br/>authorization policy<br/>[permissions.py]"]
end

subgraph group_capabilities["Agent capabilities"]
  node_hooks["Lifecycle hooks<br/>extension hooks<br/>[hooks.py]"]
  node_planning["Plans and todos<br/>work planner<br/>[planning.py]"]
  node_subagents{{"Child loops<br/>subagent runtime<br/>[subagents.py]"}}
  node_skills["Skill loader<br/>capability loader<br/>[skills.py]"]
  node_context["Context manager<br/>context budgeter<br/>[context.py]"]
  node_memory[("Persistent memory<br/>cross-run knowledge<br/>[memory.py]")]
  node_prompt["System prompt builder<br/>prompt composer<br/>[prompt.py]"]
  node_recovery["Recovery boundary<br/>resilience policy<br/>[recovery.py]"]
end

subgraph group_durable["Durable execution"]
  node_tasks[("Task system<br/>durable task store<br/>[tasks.py]")]
  node_background["Background execution<br/>async handles<br/>[background.py]"]
  node_scheduler["Task scheduler<br/>[scheduler.py]"]
  node_worktree["Git worktree isolation<br/>workspace isolation<br/>[worktree.py]"]
  node_coordination["Agent coordination<br/>mailbox protocols<br/>[protocols.py]"]
end

subgraph group_composition["Final composition"]
  node_integrations["External integrations<br/>MCP and plugins<br/>[mcp.py]"]
  node_telemetry["Telemetry<br/>observability<br/>[telemetry.py]"]
  node_final_loop{{"Engineered orchestrator<br/>final agent loop<br/>[loop.py]"}}
  node_verification["Verification loop<br/>verification engine<br/>[verify.py]"]
end

node_docs -->|"introduces"| node_baseline
node_demo -->|"runs"| node_baseline
node_baseline -->|"requests completion"| node_model
node_model -->|"answer or tool use"| node_baseline
node_baseline -->|"dispatches tool use"| node_tool_runtime
node_tool_runtime -->|"returns observation"| node_baseline
node_permission -->|"authorizes execution"| node_tool_runtime
node_hooks -.->|"intercepts"| node_tool_runtime
node_planning -->|"delegates planned work"| node_subagents
node_skills -->|"contributes instructions"| node_prompt
node_memory -->|"supplies knowledge"| node_prompt
node_context -->|"bounds live context"| node_prompt
node_prompt -->|"builds model input"| node_baseline
node_recovery -.->|"wraps failures"| node_baseline
node_tasks -->|"provides dependencies"| node_scheduler
node_scheduler -->|"launches work"| node_background
node_background -->|"updates task state"| node_tasks
node_worktree -->|"isolates parallel work"| node_subagents
node_coordination -->|"coordinates agents"| node_subagents
node_integrations -->|"extends tool boundary"| node_tool_runtime
node_telemetry -.->|"observes"| node_final_loop
node_final_loop -->|"verifies outcomes"| node_verification
node_verification -->|"feeds corrections"| node_final_loop

click node_docs "https://github.com/hardness1020/awesome-agent-architecture/blob/main/README.md"
click node_baseline "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/01-agent-loop/src/loop.py"
click node_demo "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/01-agent-loop/src/demo.py"
click node_tool_runtime "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/02-tool-runtime/src/tools.py"
click node_permission "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/03-permission-sandbox/src/permissions.py"
click node_hooks "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/04-hooks/src/hooks.py"
click node_planning "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/05-planning-todos/src/planning.py"
click node_subagents "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/06-subagents/src/subagents.py"
click node_skills "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/07-skills/src/skills.py"
click node_context "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/08-context-management/src/context.py"
click node_memory "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/09-memory/src/memory.py"
click node_prompt "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/10-system-prompt/src/prompt.py"
click node_recovery "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/11-error-recovery/src/recovery.py"
click node_tasks "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/12-task-system/src/tasks.py"
click node_background "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/13-background-execution/src/background.py"
click node_scheduler "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/14-scheduling/src/scheduler.py"
click node_worktree "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/15-worktree-isolation/src/worktree.py"
click node_coordination "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/17-protocols/src/protocols.py"
click node_integrations "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/19-mcp-plugins-channels/src/mcp.py"
click node_telemetry "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/20-observability/src/telemetry.py"
click node_final_loop "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/21-loop-engineering/src/loop.py"
click node_verification "https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/21-loop-engineering/src/verify.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_docs toneBlue
class node_baseline,node_demo,node_model,node_tool_runtime,node_permission toneAmber
class node_hooks,node_planning,node_subagents,node_skills,node_context,node_memory,node_prompt,node_recovery toneMint
class node_tasks,node_background,node_scheduler,node_worktree,node_coordination toneRose
class node_integrations,node_telemetry,node_final_loop,node_verification toneIndigo
```

## Components

### Progressive stages

Each section copies and extends the prior runnable harness.

- [Architecture thesis](https://github.com/hardness1020/awesome-agent-architecture/blob/main/README.md): documentation · The README introduces the incremental reconstruction. · `README.md`

### Core harness

- [Baseline agent loop](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/01-agent-loop/src/loop.py): Python loop · Maintains messages, calls the model, and repeats after tool results. · `sections/01-agent-loop/src/loop.py`
- [Runnable API demo](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/01-agent-loop/src/demo.py): Python entry point · Live Anthropic-compatible runtime entry point. · `sections/01-agent-loop/src/demo.py`
- **Anthropic-compatible API**: external model API
- [Tool runtime](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/02-tool-runtime/src/tools.py): tool registry · Registers schemas, routes model requests, and executes deterministic tools. · `sections/02-tool-runtime/src/tools.py`
- [Permission sandbox](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/03-permission-sandbox/src/permissions.py): authorization policy · Gates side-effecting tools before dispatch. · `sections/03-permission-sandbox/src/permissions.py`

### Agent capabilities

- [Lifecycle hooks](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/04-hooks/src/hooks.py): extension hooks · Intercepts lifecycle and tool activity. · `sections/04-hooks/src/hooks.py`
- [Plans and todos](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/05-planning-todos/src/planning.py): work planner · Decomposes complex work into tracked steps. · `sections/05-planning-todos/src/planning.py`
- [Child loops](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/06-subagents/src/subagents.py): subagent runtime · Runs isolated child agents for delegated work. · `sections/06-subagents/src/subagents.py`
- [Skill loader](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/07-skills/src/skills.py): capability loader · Loads skill definitions into agent capabilities. · `sections/07-skills/src/skills.py`
- [Context manager](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/08-context-management/src/context.py): context budgeter · Budgets and compacts prompt-window state. · `sections/08-context-management/src/context.py`
- [Persistent memory](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/09-memory/src/memory.py): cross-run knowledge · `sections/09-memory/src/memory.py`
- [System prompt builder](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/10-system-prompt/src/prompt.py): prompt composer · Combines system instructions with live harness state. · `sections/10-system-prompt/src/prompt.py`
- [Recovery boundary](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/11-error-recovery/src/recovery.py): resilience policy · Handles retries, overflow, and fallback behavior. · `sections/11-error-recovery/src/recovery.py`

### Durable execution

- [Task system](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/12-task-system/src/tasks.py): durable task store · Tracks persistent tasks and dependencies. · `sections/12-task-system/src/tasks.py`
- [Background execution](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/13-background-execution/src/background.py): async handles · Manages background handles and notifications. · `sections/13-background-execution/src/background.py`
- [Task scheduler](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/14-scheduling/src/scheduler.py): scheduler · `sections/14-scheduling/src/scheduler.py`
- [Git worktree isolation](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/15-worktree-isolation/src/worktree.py): workspace isolation · Separates parallel code work into worktrees. · `sections/15-worktree-isolation/src/worktree.py`
- [Agent coordination](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/17-protocols/src/protocols.py): mailbox protocols · Coordinates agents through messaging and higher-level protocols. · `sections/17-protocols/src/protocols.py`

### Final composition

- [External integrations](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/19-mcp-plugins-channels/src/mcp.py): MCP and plugins · Assembles MCP, plugins, and channels. · `sections/19-mcp-plugins-channels/src/mcp.py`
- [Telemetry](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/20-observability/src/telemetry.py): observability · `sections/20-observability/src/telemetry.py`
- [Engineered orchestrator](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/21-loop-engineering/src/loop.py): final agent loop · Accumulated final harness composition. · `sections/21-loop-engineering/src/loop.py`
- [Verification loop](https://github.com/hardness1020/awesome-agent-architecture/blob/main/sections/21-loop-engineering/src/verify.py): verification engine · Validates work as part of final loop engineering. · `sections/21-loop-engineering/src/verify.py`

## Connections

- Architecture thesis → Baseline agent loop: introduces
- Runnable API demo → Baseline agent loop: runs
- Baseline agent loop → Anthropic-compatible API: requests completion
- Anthropic-compatible API → Baseline agent loop: answer or tool use
- Baseline agent loop → Tool runtime: dispatches tool use
- Tool runtime → Baseline agent loop: returns observation
- Permission sandbox → Tool runtime: authorizes execution
- Lifecycle hooks → Tool runtime: intercepts
- Plans and todos → Child loops: delegates planned work
- Skill loader → System prompt builder: contributes instructions
- Persistent memory → System prompt builder: supplies knowledge
- Context manager → System prompt builder: bounds live context
- System prompt builder → Baseline agent loop: builds model input
- Recovery boundary → Baseline agent loop: wraps failures
- Task system → Task scheduler: provides dependencies
- Task scheduler → Background execution: launches work
- Background execution → Task system: updates task state
- Git worktree isolation → Child loops: isolates parallel work
- Agent coordination → Child loops: coordinates agents
- External integrations → Tool runtime: extends tool boundary
- Telemetry → Engineered orchestrator: observes
- Engineered orchestrator → Verification loop: verifies outcomes
- Verification loop → Engineered orchestrator: feeds corrections
