articleJanuary 1, 2026
12 Factor Agents
A manifesto for building production-grade LLM agents, arguing that effective agents combine mostly deterministic software with strategic LLM decision-making rather than naive 'loop until solved' patterns.
Core Insight
Agents get lost in extended context windows and spin out repeating failed approaches. The solution: integrate focused micro-agents into larger deterministic workflows rather than giving an LLM a bag of tools and looping until done.
"Even as models support longer and longer context windows, you'll ALWAYS get better results with a small, focused prompt and context."
The 12 Factors
- Natural Language to Tool Calls - Convert user input to structured JSON representing next steps
- Own Your Prompts - Treat prompts as first-class code; don't outsource prompt engineering
- Own Your Context Window - Control how information is structured and presented to LLMs
- Tools Are Just Structured Outputs - Tools are JSON that triggers deterministic code
- Unify Execution State and Business State - Infer execution state from context
- Launch/Pause/Resume with Simple APIs - Enable easy interruption and resumption
- Contact Humans with Tool Calls - Use structured requests for human interaction
- Own Your Control Flow - Build custom control structures for your specific use case
- Compact Errors into Context Window - Let LLMs read and learn from failure messages
- Small, Focused Agents - Keep agents to 3-20 steps; avoid monolithic designs
- Trigger from Anywhere - Enable agents via Slack, email, webhooks, etc.
- Make Your Agent a Stateless Reducer - Treat agents as pure functions on accumulated state
Key Takeaways
- Effective agents are mostly just software with strategic LLM decision points
- Context window management is critical—smaller, focused prompts outperform large contexts
- Design for interruptibility and human-in-the-loop from the start
- Deterministic control flow with LLM decision nodes beats autonomous loops
Related
Companion to context-efficient-backpressure (practical techniques for Factor 3) and writing-a-good-claude-md (applying Factor 2 to Claude Code configuration).
Linked References (29)
- 2025: The Year in LLMs
- A Brief History of Ralph
- Advanced Context Engineering for Coding Agents
- Agentic Design Patterns: A Hands-On Guide to Building Intelligent Systems
- AI Agents Roadmap
- AI codes better than me. Now what?
- Beads
- Build Autonomous Agents Using Prompt Chaining with AI Primitives
- Building an AI Agent with TypeScript
- Building Effective Agents
- Building Evolutionary Architectures
- Claude Agent SDK [Full Workshop]
- Claude Code Best Practices
- Claude Code is a Platform, Not an App
- Claude Code Ralph Loop Tutorial
- Context Engineering for AI Agents with LangChain and Manus
- Context Engineering for AI Systems
- Set Up a Context Engineering Flow in VS Code
- Front-End Engineering is Dead, Long Live Front-End Composability
- Ralph
- Ralph Guide
- Ralph Wiggum (and why Claude Code's implementation isn't it)
- Ralph Wiggum as a Software Engineer
- The Ralph Wiggum Technique: Running Claude Code in a Loop
- The Context Window Problem
- The Importance of Agent Harness in 2026
- Vue 3 Testing Pyramid: A Practical Guide with Vitest Browser Mode
- Writing a Good CLAUDE.md
- Zeroshot