Module 3: Keep Your Factory in Control and on Budget
Your basic factory already runs in the cloud and launches from triggers. This module gives humans control of the running factory, and keeps it cheap and portable as models change.
Give humans control of the running factory
Your orchestrator should give you a global view of every agent, active and historical, and the stage of every issue. Treat it as your factory control room, where you see how the factory runs, where the bottlenecks are and what needs attention.
Build three ways for humans to step in
Agents sometimes get stuck, some complex tasks still go better interactively, and sometimes you want to test an agent's output yourself. Build three primitives into the factory:
| Primitive | What it lets you do |
|---|---|
| Steering | Join a live session and iterate with the agent. |
| Handoff | Move an agent session and its context from the cloud to your local machine, and back. |
| Notifications | Let an agent tell a human that it needs help. |
These primitives are hard to build, but developers need them to adopt a factory. Without them, work gets stuck or gets done incorrectly.
Let people change the factory from where they work
Your integrations should let people add work, check its status and change how the factory operates. Say a code review agent gives advice that breaks the repo's conventions. A developer should be able to correct it right in the code review tool.
The Code: Your daily unfair advantage in software engineering.
Join 350,000+ software engineers, tech leads, and CTOs who start their morning with The Code.
Keep the factory cheap and portable
The best agent today is not the best agent tomorrow, and the landscape changes weekly. Build the factory so it can always use the agent and model with the best mix of cost, quality and speed.
Route each task to the right model
Route each task to the least expensive, fastest model that meets your quality bar. You can mix open-weight and frontier models, and route between models even within one task:
Keep the harness layer flexible too, so you can switch harnesses or mix them across tasks. A single model or harness locks you in on price, and providers struggle to reach even two nines of reliability.
Move deterministic steps out of the model and into code. Guild's engineering team expects routing and this move to keep cutting its cost per unit of work.
Keep the prompt cache warm
Each turn resends the whole conversation, so prompt caching keeps your agents fast and cheap. With cache hits, sampling cost grows linearly rather than quadratically, but a hit needs an exact prefix match:
- Put static content, such as instructions and examples, at the start of the prompt, and variable content at the end.
- Keep the tool list, its order, the model and the sandbox settings the same for the whole run.
- When the configuration must change mid-run, append a new message, and leave earlier messages untouched.
Once a run passes a token threshold, have the agent compact the conversation. It replaces the input with a smaller list of items that represents it, and keeps going.
Keep your team's knowledge separate, and own it
Split what any factory does from what only your team knows. Planning, implementation, review, retries and escalation are reusable, and your standards and conventions become Skills the factory loads:
Give agents memory too. Support explicit memory, such as "remember that we always use terraform for infra changes," and implicit memory that the agent extracts from past interactions. Store this memory in your own company's systems, or it becomes a big lock-in risk.
By this point you should have:
- A control room, three ways for humans to step in, and a way to correct agents from your existing tools.
- A factory that routes each task to the cheapest model that clears the bar and keeps its prompt cache warm.
- Skills and memory that your company owns.
Module 4: Measure and Improve the Factory
The next module shows you how to measure the factory and improve it.