Skip to content

Volume II

Production Doctrine

The 12 factors and the outer loop

Frameworks get you to 80%. The last 20% — the part customers will pay for — is software engineering: own the prompt, own the context, own the control flow, and treat the model as a stateless reducer over events you control.

  1. II.1The Twelve FactorsTwelve engineering constraints that make LLM-powered software reliable enough for paying customers. Not a framework — a checklist you can apply to any stack.10 min
  2. II.2Own Your PromptsPrompts are source code. If you cannot diff them, version them, and test them, you do not own the agent's policy.5 min
  3. II.3Own Your Context WindowThe context window is not 'chat history'. It is a carefully laid-out working set. Whoever builds that layout owns the agent's intelligence.8 min
  4. II.4Own Your Control FlowThe model may propose the next edge. Your code decides whether that edge is legal, budgeted, and reversible. Do not outsource the graph.6 min
  5. II.5Small, Focused AgentsA good agent has few tools, a narrow goal, and a short context. Generalists are orchestrators. Specialists do the work.6 min
  6. II.6The Agent as a Stateless ReducerFactor 12: (state, event) → (newState, effects). The model is a pure function over a context you serialize. Everything else is infrastructure.6 min
  7. II.7Unify Execution and Business StateFactor 5: there is one serializable blob. The ticket is the agent state. A second 'agent memory' that drifts from the business object is how you lose the thread and the customer.6 min
  8. II.8Trigger from AnywhereFactor 11: the loop does not live in one text box. Mail, chat, tickets, cron, webhooks, and IDE events are all legal starts. The agent is a reducer over events, not a chatbot with extra steps.5 min