home / skills / coowoolf / insighthunt-skills / three-layer-agent-stack
This skill helps you design and implement three-layer agent stacks by coordinating model, API, and harness to deliver robust AI-powered workflows.
npx playbooks add skill coowoolf/insighthunt-skills --skill three-layer-agent-stackReview the files below or copy the command above to add this skill to your agents.
---
name: three-layer-agent-stack
description: Use when building AI-powered products or agents, when raw model intelligence isn't enough to solve user problems, or when designing the architecture for agentic workflows
---
# The Three-Layer Agent Stack
## Overview
A framework for building effective AI agents by synchronizing innovation across **three distinct layers**: Model, API, and Harness. Success requires tight integration—not treating the model as a black box.
**Core principle:** Features like "compaction" (long-running tasks) require simultaneous changes across all three layers.
## The Stack
```
┌─────────────────────────────────────────────────────────────────┐
│ LAYER 3: HARNESS / PRODUCT LAYER │
│ ───────────────────────────────────────────────────────────── │
│ The environment that executes actions and provides context │
│ • VS Code / IDE integration │
│ • Terminal / Shell access │
│ • Sandbox / Secure execution environment │
├─────────────────────────────────────────────────────────────────┤
│ LAYER 2: API LAYER │
│ ───────────────────────────────────────────────────────────── │
│ Interface handling state, context windows, and orchestration │
│ • Context management / Compaction │
│ • State handoff between sessions │
│ • Tool routing and formatting │
├─────────────────────────────────────────────────────────────────┤
│ LAYER 1: MODEL LAYER │
│ ───────────────────────────────────────────────────────────── │
│ Foundation model providing reasoning and intelligence │
│ • Code generation / Reasoning │
│ • Summarization for compaction │
│ • Environment-specific training │
└─────────────────────────────────────────────────────────────────┘
```
## Key Principles
| Principle | Description |
|-----------|-------------|
| **Full-Stack Iteration** | Changes often need Model + API + Harness together |
| **Harness Specificity** | Models perform best when trained for specific environments |
| **Feedback Loops** | Product usage (Harness) must inform model training |
| **Safety Sandboxing** | Harness provides secure environment for code execution |
## Common Mistakes
- **Model-only optimization**: Changing model without adapting harness
- **Generic API assumptions**: Assuming generic API supports agentic behaviors
- **No feedback loop**: Harness doesn't feed back to model training
## Real-World Example
Implementing "Compaction" to allow Codex to run 24 hours:
- **Model**: Must understand summarization
- **API**: Must handle the context handoff
- **Harness**: Must prepare and format the payload
---
*Source: Alexander Embiricos (OpenAI Codex) via Lenny's Podcast*
This skill presents the Three-Layer Agent Stack framework for designing AI-powered products and agents. It shows how to align Model, API, and Harness layers so features and long-running behaviors work reliably. It emphasizes that improving agent capabilities requires coordinated changes across all layers, not model-only tweaks.
The skill inspects and organizes responsibilities into three layers: the Model layer (reasoning, generation, and environment-specific behavior), the API layer (context, state handoff, and tool orchestration), and the Harness layer (execution environment, UI, and security). It guides teams to map a feature across those layers, identify gaps, and plan joint iterations. It highlights feedback loops so runtime signals from the Harness inform model tuning and API changes.
Do I have to retrain the model for every product change?
No. Many product changes require API and Harness updates first. Retrain or fine-tune the model only when behaviors or environment-specific reasoning must improve.
How do I start applying this stack to an existing agent?
Inventory current responsibilities by layer, identify mismatches (e.g., the API lacks state handoff), and create a small pilot that implements a feature across all three layers to validate the approach.