humanlayer /12-factor-agents
What are the principles we can use to build LLM-powered software that is actually good enough to put in the hands of production customers?
★ 27,072⑂ 2,046👁 226⑃ 70● 24▤ 0◈ 14
27,072
stars
+17+118+431
2,046
forks
226
watchers
70
prs
24
issues
0
releases
14
discussions
README
12-Factor Agents - Principles for building reliable LLM applications
In the spirit of 12 Factor Apps. The source for this project is public at https://github.com/humanlayer/12-factor-agents, and I welcome your feedback and contributions. Let's figure this out together!
[!TIP]
Missed the AI Engineer World's Fair? Catch the talk here
Looking for Context Engineering? Jump straight to factor 3
Want to contribute to npx/uvx create-12-factor-agent - check out the discussion thread
Hi, I'm Dex. I've been hacking on AI agents for a while.
I've tried every agent framework out there, from the plug-and-play crew/langchains to the "minimalist" smolagents of the world to the "production grade" langraph, griptape, etc.
I've talked to a lot of really strong founders, in and out of YC, who are all building really impressive things with AI. Most of them are rolling the stack themselves. I don't see a lot of frameworks in production customer-facing agents.
I've been surprised to find that most of the products out there billing themselves as "AI Agents" are not all that agentic. A lot of them are mostly deterministic code, with LLM steps sprinkled in at just the right points to make the experience truly magical.
Agents, at least the good ones, don't follow the "here's your prompt, here's a bag of tools, loop until you hit the goal" pattern. Rather, they are comprised of mostly just software.
So, I set out to answer:
What are the principles we can use to build LLM-powered software that is actually good enough to put in the hands of production customers?
Welcome to 12-factor agents. As every Chicago mayor since Daley has consistently plastered all over the city's major airports, we're glad you're here.
Special thanks to @iantbutler01, @tnm, @hellovai, @stantonk, @balanceiskey, @AdjectiveAllison, @pfbyjy, @a-churchill, and the SF MLOps community for early feedback on this guide.
The Short Version: The 12 Factors
Even if LLMs continue to get exponentially more powerful, there will be core engineering techniques that make LLM-powered software more reliable, more scalable, and easier to maintain.
- How We Got Here: A Brief History of Software
- Factor 1: Natural Language to Tool Calls
- Factor 2: Own your prompts
- Factor 3: Own your context window
- Factor 4: Tools are just structured outputs
- Factor 5: Unify execution state and business state
- Factor 6: Launch/Pause/Resume with simple APIs
- Factor 7: Contact humans with tool calls
- Factor 8: Own your control flow
- Factor 9: Compact Errors into Context Window
- Factor 10: Small, Focused Agents
- Factor 11: Trigger from anywhere, meet users where they are
- Factor 12: Make your agent a stateless reducer
Visual Nav
| | | |
|----|----|-----|
| | | |
| | | |
| | | |
| | | |
How we got here
For a deeper dive on my agent journey and what led us here, check out A Brief History of Software - a quick summary here:
ThTop issues
#64Could you provide some examples of Agent applications built based on these 12 factors?3 comments · 2025-07-25#25Being explicit about MCP3 comments · 2025-04-21#20[Proposal] Encourage the use of a single industry-wide standard to describe all tools in 12‑Factor Agents #12FactorTools3 comments · 2025-04-19#107Factor 13 candidate: tamper-evident audit trail for agent decisions — HELM AI Kernel2 comments · 2026-06-11#78Feedback on “12-Factor Agent”0 comments · 2025-10-12#21[Proposal] Explicitly Recommend Structured Data for Tool Results #12FactorTools1 comments · 2025-04-19#116A challenge on factor 050 comments · 2026-10-21#114Suggestion: a note on model portability — "Own Your Model Layer" via OpenAI-compatible endpoints0 comments · 2026-08-18
Discussions
#110A CLI built as a stateless verification-loop — sanity check on the 12-factor mapping?0 comments · 2026-07-24#108Runtime guardrails as a principle for agent design.0 comments · 2026-06-16#106Authority-before-action as a production agent factor1 comments · 2026-05-25#9512-factor-agents is featured on Shypd — 80K+ AI tools0 comments · 2026-03-30#92Show and Tell: ORCH — a runtime that implements several 12-factor agent principles in practice0 comments · 2026-03-17#86Context as Enterprise Infrastructure1 comments · 2026-01-25#76Great examples of AI Agent products built on deterministic-code-with-minor-magical-ai-sprinkle0 comments · 2025-10-02#71personas?1 comments · 2025-08-24