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?
Migrate from framework-based agents to custom implementations with this 12-factor guide. Extract agent loops, externalize prompts to BAML, and replace tool executors for full control.
How to Debug Agent Loops and Prevent Infinite Spinning in 12-Factor AgentsDebug agent loops and prevent infinite spinning in 12-Factor Agents. Implement step counters, validate LLM responses, and add structured logging to your agent code.
How to Handle Rate Limiting in LLM Agent Frameworks: A 12-Factor ApproachHandle rate limiting in LLM agent frameworks with token buckets and exponential back-off. This 12-factor approach prevents API quota exhaustion and ensures predictable agent behavior.
How to Implement DAG-Style Orchestration in Agent SystemsMaster DAG-style orchestration in agent systems. Learn how to combine static task dependencies with LLM control for dynamic execution and resumable state management. Explore the humanlayer/12-factor-agents repository.
How to Test and Evaluate LLM Agent Behavior Reliably: A 12-Factor Agents GuideLearn to reliably test and evaluate LLM agent behavior using the 12-Factor Agents framework. This guide details a reproducible notebook workflow for isolated prompt execution and tool calls in sandboxed environments.
How to Add Approval Gates in Agent Tool Execution: A 12-Factor Agents GuideLearn how to add approval gates in agent tool execution using a Thread state checker. Pause agent loops, await human confirmation, and resume processing securely. Improve agent control and reliability.
How to Manage LLM Context Window Size for Long-Running Agents: A 12-Factor ApproachMaster LLM context window size for long-running agents. Learn to serialize events, implement token budget guards, and optimize context for enhanced performance.
How to Implement RAG in Agent Context Windows: A 12-Factor Agents GuideLearn to implement RAG in agent context windows by encoding documents as structured events for efficient LLM reasoning over current information. Explore the 12-Factor Agents guide.
How to Build Multi-Step Agent Workflows with Deterministic ControlLearn to build multi step agent workflows with deterministic control by separating LLM reasoning from execution. Output JSON intents for a dispatch layer to route to functions. Enable interruptible loops with persistent state.
How to Design Agent Memory and Context Persistence in 12-Factor AgentsLearn to design agent memory and context persistence by treating threads as the source of truth and persisting events to a ThreadStore. Ensure seamless state retention for your stateless LLMs.
Agent Error Recovery and Retry Logic in 12-Factor Agents: A Complete GuideMaster agent error recovery and retry logic in 12-factor agents. Learn to treat tool failures as events for LLM self-correction and implement robust retry counters. Ensure agent resilience.
How to Implement Schema-Aligned Parsing for Reliable LLM OutputsLearn schema-aligned parsing to ensure LLM outputs are reliable JSON, validating against Zod schemas and preventing errors before they impact your business logic.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →