WhoBuilt

12-Factor Agents: Patterns of reliable LLM applications

Jul 3, 2025· 17 min· 294K views·Watch on YouTube

Speaker

Dex Horthy of HumanLayer presents “12-Factor Agents” at AI Engineer, explaining software engineering patterns for building more reliable LLM applications.

Why agent projects stall

Horthy describes getting an agent to 70 or 80 percent, then struggling to understand how a framework builds prompts and passes tools. His DevOps agent example showed that some tasks are better handled by a simple Bash script than an agent.

Treat model output as data

Horthy says a core strength of LLMs is turning natural language into structured JSON. Deterministic code can act on that output, so tool use does not need to be treated as a special kind of magic.

Own control flow and state

A basic agent loop can let a model choose steps, but long workflows accumulate context and become less reliable. Horthy recommends owning the loop and state so applications can pause, resume, summarize, retry, and manage approvals.

Engineer prompts and context

Horthy argues that better outputs depend on the tokens supplied to the model, so teams should own their prompts and context construction. For example, after an API error, they can clear resolved errors and summarize useful information instead of repeatedly adding full stack traces.

Use small agents in deterministic workflows

Horthy recommends small agent loops of roughly three to ten steps within mostly deterministic workflows. At HumanLayer, a deployment bot proposes backend and frontend deployments for human approval, then deterministic code runs production tests.

Takeaways

  • Use a script when a task has a clear, fixed sequence of steps.
  • Treat model responses as structured data and let ordinary code handle actions.
  • Keep control of the agent loop and application state to support pause, resume, and recovery.
  • Review prompts and context carefully, including how errors are summarized or removed.
  • Place short, focused agent loops inside deterministic workflows, with human approval where useful.

Mentioned in this talk

Search inside this talk

What was claimed 7

Related talks