three-layer-agent-stack
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
More from coowoolf/insighthunt-skills
gardening-mindset
Use when dealing with ecosystems, network effects, or high-uncertainty environments where the right answer cannot be known in advance, when rigid planning consumes more value than it creates
45gamification-triad
Use when designing retention mechanisms, habit loops, or auditing why users drop off despite engaging with core features, to structure gamification beyond superficial badges
44minimum lovable product (mlp)
In an era where AI lowers the cost of building software, viability is obsolete. The differentiator is joy and emotional connection. Prioritize "Wow" over "Aha"—brand is product interaction.
14curiosity-loops
Use when facing a significant decision (career pivot, product direction, technical choice) and feeling stuck or indecisive, when seeking contextual advice rather than generic recommendations
13pre-mortem-kill-criteria
Use before launching products or signing contracts, when needing to combat sunk cost fallacy, or when standard pre-mortems fail to change behavior
13strategic-narrative
Use when traditional problem/solution pitches fail to differentiate, when teams are misaligned around messaging, or when entering Series B/scaling phases where founder-led sales no longer scale
12