Skip to content

LearnCourses

HumanLayer

12-Factor Agents

Build LLM agents that hold up in production with 12 engineering principles, for software engineers.

Taught by Dex Horthy at HumanLayerFreeVerified

From How we got here: a brief history of software to Factor 12: Make your agent a stateless reducer
14 chapters
What it uses
BAML, in the prompt examples
Before you startExperience writing software; no AI background is needed, and the examples are mostly TypeScript, though the ideas carry over to Python or any language.
Intermediate level
12 factors, plus a brief history and a bonus factor
Self-paced

What you’ll learn

  • Turn a user's request into a structured tool call that your own code carries out.
  • Write, test and version your prompts and the model's context yourself instead of leaving them to a framework.
  • Keep an agent's progress in the same thread as your app's data, so a run can pause, resume and be debugged.
  • Let an agent ask a person for input or approval through a tool call, from Slack, email or other channels.
  • Feed errors back to the model, cap the retries and hand off to a person when it keeps failing.
  • Split work into small agents with short contexts inside a mostly ordinary program.

Skills you’ll gain

AgentsLLMsPromptingContext engineeringTool calling

Tools it uses

BAML, in the prompt examples.

Details to know

  • No certificateHumanLayer lists none
  • Free to takeNo fee on github.com
  • Taught in EnglishNo other languages listed
  • VerifiedNov 2026

Lessons

14 chapters · 12 factors, plus a brief history and a bonus factor

12-Factor Agents is a free guide from HumanLayer, published on GitHub, for engineers who build software on top of large language models. It sets out 12 principles, named after the 12 Factor App method, for agents that are reliable enough to put in front of customers.

Its author, Dex, argues that the agents working well in production are mostly ordinary code with LLM steps in a few places, not a model looping over a pile of tools. Each chapter is one short page with code snippets and diagrams, and you can read them in any order.

The code is under the Apache 2.0 license and the text and images under CC BY-SA 4.0.

Across a short history and 13 factors, you will:

  • A brief history of software: Trace software from flow charts and DAG orchestrators to agents, and see where the plain agent loop falls short.
  • Factors 1 to 4: Turn requests into tool calls and take charge of your prompts, your context and what tools return.
  • Factors 5 and 6: Keep agent state with your app's data, and launch, pause and resume runs through plain APIs.
  • Factors 7 to 9: Reach people through tool calls, write your own control loop and feed errors back to the model.
  • Factors 10 to 12: Build small agents, start them from any channel and treat each one as a stateless reducer.
  • Factor 13: Fetch the context a model will surely need before it has to ask for it.

By the end, you can design an agent as mostly ordinary code, with LLM calls where they help and people brought in when it matters.

How we got here: a brief history of softwareChapter 1Chapter details

What you’ll learn

  • Follow software from flow charts and DAG orchestrators to machine learning steps and agents.
  • See why the plain agent loop breaks down on longer tasks.
  • Meet micro agents: small LLM loops inside a mostly fixed workflow.
Factor 1: Natural language to tool callsChapter 2Chapter details

What you’ll learn

  • Turn a sentence such as a payment request into a structured tool call.
  • Hand that structured output to ordinary code to carry out.
Factor 2: Own your promptsChapter 3Chapter details

What you’ll learn

  • Treat prompts as code you write, test and version yourself.
  • See why a framework's hidden prompts are hard to tune.
Factor 3: Own your context windowChapter 4Chapter details

What you’ll learn

  • Decide what goes into the model's input at each step.
  • Pack history, tool results and errors in your own format to save tokens.
  • Keep sensitive data out of what the model sees.
Factor 4: Tools are just structured outputsChapter 5Chapter details

What you’ll learn

  • Treat a tool as JSON the model writes and your code acts on.
  • Keep the model's choice apart from how your code carries it out.
Factor 5: Unify execution state and business stateChapter 6Chapter details

What you’ll learn

  • Tell execution state, such as the current step, from business state, such as past tool calls.
  • Keep both in one thread you can serialize, debug and resume from.
Factor 6: Launch/pause/resume with simple APIsChapter 7Chapter details

What you’ll learn

  • Launch, query, pause and stop agents through simple APIs.
  • Resume a run from a webhook or another outside event.
Factor 7: Contact humans with tool callsChapter 8Chapter details

What you’ll learn

  • Have the model ask a person for input through a structured tool call.
  • Let an agent wait for the answer and carry on where it stopped.
Factor 8: Own your control flowChapter 9Chapter details

What you’ll learn

  • Write your own loop and choose which tool calls stop it to wait.
  • Add approvals, summaries, LLM-as-judge checks, tracing and rate limits.
Factor 9: Compact errors into the context windowChapter 10Chapter details

What you’ll learn

  • Feed error messages back into the context so the model can try again.
  • Cap retries and pass the task to a person after repeated failures.
Factor 10: Small, focused agentsChapter 11Chapter details

What you’ll learn

  • Keep each agent to a narrow job of about 3 to 10 steps.
  • Keep contexts short so the model stays on track.
Factor 11: Trigger from anywhere, meet users where they areChapter 12Chapter details

What you’ll learn

  • Start agents from Slack, email, text messages or events.
  • Let agents reply in the same channel and reach a person when stuck.
Factor 12: Make your agent a stateless reducerChapter 13Chapter details

What you’ll learn

  • Picture an agent as a reducer that turns the state so far and one event into the next state.
Factor 13: Pre-fetch all the context you might needChapter 14 • BonusChapter details

What you’ll learn

  • Fetch data the model will surely need before the first call.
  • Save the model a round trip by calling those tools in your own code.

FAQs

Is 12-Factor Agents free?

Yes. The course is free.

Open the course

Do I get a certificate?

No. HumanLayer does not list a certificate for this course.

What do I need before I start?

Experience writing software; no AI background is needed, and the examples are mostly TypeScript, though the ideas carry over to Python or any language.

How long is it?

12 factors, plus a brief history and a bonus factor; you take it at your own pace.

See the lessons

Which tools does it teach?

BAML, in the prompt examples.

Who makes it?

Taught by Dex Horthy at HumanLayer. Recaply lists 1 course from HumanLayer.

More courses

See all
Freeon github.comOpen the course