How hardness1020/awesome-agent-architecture works
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: src/loop.py Baseline agent loop · tools.py Tool runtime · prompt.py System prompt builder · src/loop.py Engineered orchestrator
Components 23
Progressive stages
Each section copies and extends the prior runnable harness.
- Architecture thesis · The README introduces the incremental reconstruction.
README.md
Core harness
- Baseline agent loop · Maintains messages, calls the model, and repeats after tool results.
sections/01-agent-loop/src/loop.py - Runnable API demo · Live Anthropic-compatible runtime entry point.
sections/01-agent-loop/src/demo.py - Anthropic-compatible API
- Tool runtime · Registers schemas, routes model requests, and executes deterministic tools.
sections/02-tool-runtime/src/tools.py - Permission sandbox · Gates side-effecting tools before dispatch.
sections/03-permission-sandbox/src/permissions.py
Agent capabilities
- Lifecycle hooks · Intercepts lifecycle and tool activity.
sections/04-hooks/src/hooks.py - Plans and todos · Decomposes complex work into tracked steps.
sections/05-planning-todos/src/planning.py - Child loops · Runs isolated child agents for delegated work.
sections/06-subagents/src/subagents.py - Skill loader · Loads skill definitions into agent capabilities.
sections/07-skills/src/skills.py - Context manager · Budgets and compacts prompt-window state.
sections/08-context-management/src/context.py - Persistent memory
sections/09-memory/src/memory.py - System prompt builder · Combines system instructions with live harness state.
sections/10-system-prompt/src/prompt.py - Recovery boundary · Handles retries, overflow, and fallback behavior.
sections/11-error-recovery/src/recovery.py
Durable execution
- Task system · Tracks persistent tasks and dependencies.
sections/12-task-system/src/tasks.py - Background execution · Manages background handles and notifications.
sections/13-background-execution/src/background.py - Task scheduler
sections/14-scheduling/src/scheduler.py - Git worktree isolation · Separates parallel code work into worktrees.
sections/15-worktree-isolation/src/worktree.py - Agent coordination · Coordinates agents through messaging and higher-level protocols.
sections/17-protocols/src/protocols.py
Final composition
- External integrations · Assembles MCP, plugins, and channels.
sections/19-mcp-plugins-channels/src/mcp.py - Telemetry
sections/20-observability/src/telemetry.py - Engineered orchestrator · Accumulated final harness composition.
sections/21-loop-engineering/src/loop.py - Verification loop · Validates work as part of final loop engineering.
sections/21-loop-engineering/src/verify.py
Connections 23
- 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