12 Factor Agents

Stale
GitHub TypeScript NOASSERTION

Description

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?

Key Features

  • 12 core principles framework — systematic best practices from NL-to-tool-calls to stateless reducer pattern
  • Own your context window (Factor 3) — build and manage LLM context yourself, not via framework black box
  • Tools as structured outputs (Factor 4) — treat tool calls as structured outputs, simplify agent interaction
  • Stateless reducer pattern (Factor 12) — design agents as pure function reducers for testability
  • Human contact via tool calls (Factor 7) — reach humans through tool calls for Human-in-the-loop collaboration
  • Compact errors into context window (Factor 9) — distill errors into context for autonomous recovery

Use Cases

💡 Evaluating and improving existing agent framework architecture
💡 Architecture reference for building production-grade LLM applications from scratch
💡 Understanding why most agent frameworks are unsuitable for production
💡 Designing testable, maintainable, and scalable agent systems
💡 Implementing Human-in-the-loop enterprise agent workflows

Strengths & Limitations

Strengths

  • High community interest (25.7k stars)
  • Responsive to issues, low backlog

⚠️ Limitations

  • No updates in over 11 months
  • No clear open-source license

Quick Start

git clone https://github.com/humanlayer/12-factor-agents.git
cd 12-factor-agents

# Read the core principles
cat content/factor-01-natural-language-to-tool-calls.md
cat content/factor-03-own-your-context-window.md
cat content/factor-12-stateless-reducer.md

# Build your own agent following the principles
# 1. Use natural language to tool calls pattern
# 2. Own your context window
# 3. Design agent as a stateless reducer

Related Projects

Agents Towards Production

21.4k · Jupyter Notebook
Active A+

End-to-end, code-first tutorials for building production-grade GenAI agents. From prototype to enterprise deployment.

agentframeworkevaluation +2
  • · 28 production-grade tutorials — Covering stateful workflows, vector memory, web search APIs and more
  • · End-to-end coverage — From Docker deployment, FastAPI endpoints to security guardrails and GPU scaling
  • · Multi-agent coordination — Teaching multi-Agent collaboration architecture design and implementation

OpenShell

8.5k · Rust
Active A

OpenShell is the safe, private runtime for autonomous AI agents, developed by NVIDIA. Provides controlled execution environments and resource management.

rustagentframework +2
  • · Sandboxed execution environments protecting data, credentials, and infrastructure with declarative YAML policies
  • · Four defense-in-depth layers: filesystem, network, process, and inference policy enforcement
  • · Hot-reloadable network and inference policies via `openshell policy set` without restarting sandboxes

SwanLab

4.2k · Python
Active A+

An open-source, modern-design AI training tracking and visualization tool. Supports PyTorch, Transformers and more. Monitor and evaluate AI agent training processes.

pythonobservabilityevaluation +2
  • · Seamless integration with 50+ mainstream frameworks: native support for PyTorch, Transformers, HuggingFace Accelerate, PaddleNLP, NVIDIA NeMo RL and more, with two lines of code to connect training pipelines
  • · Rich visualization system: supports line charts, scalar plots, PR curves, ROC curves, confusion matrices, 3D point clouds, molecular structures, ECharts custom charts and 20+ chart types
  • · Multi-dimensional hardware monitoring: real-time monitoring of GPU (NVIDIA/AMD ROCm/Hygon DCU/Cambricon MLU/Moore Threads/Muxi/Iluvatar/Kunlun), disk utilization, network traffic and other hardware metrics

AgentBench

3.7k · Python
Stale C

A comprehensive benchmark to evaluate LLMs as agents (ICLR 2024), covering operating systems, databases, knowledge graphs, digital card games and more.

evaluationpythonagent +1
  • · First comprehensive benchmark evaluating LLMs as autonomous agents across 8 diverse environments
  • · Covers OS interaction, database operations, knowledge graphs, digital card games, and lateral thinking puzzles
  • · AgentBench FC integrates function-calling style prompts with AgentRL reinforcement learning framework