Starter Templates, Runbooks and Checklists
Start from a small project that already says no to the right things, then add what your task needs.
This is the site's template and download center. Copy a starter agent in Python, TypeScript or Java that already has a tool registry, argument checks, approval and a step limit. Then take the design document, runbook, incident record, readiness checklist and cost sheet. Everything is plain text you can paste into your own files.
What you will learn: what a good starter includes, how the three versions compare, how to add a real model safely, and which documents a team needs before and after launch.
Prerequisites: Set Up Your Agent Development Lab and basic programming in one of the three languages.
Run in November 2026 with Python 3.13, Node.js 22.23.5 and OpenJDK 21. The TypeScript file also passed a strict type check with TypeScript 6.0.3. The cost formulas were calculated with LibreOffice. None of the starters calls a model: a scripted stand-in returns the decisions, so they run offline and free.
What every starter includes
| Safety habit | Why it is there from day one |
|---|---|
| Fixed tool registry | A model cannot invent a capability |
| Argument checking | Bad input stops before it reaches your systems |
| Approval defaults to no | Forgetting to wire approval fails safely |
| Step limit | A confused loop ends and costs stay bounded |
| Scripted model | Tests are repeatable and need no key |
Suggested layout
my-agent/
agent/ loop, prompts, model client
tools/ one file per tool, with its schema and checks
tests/ cases and expected behavior
config/ settings and limits; .env.example without secrets
notes/ design, decisions, runbook
Python starter
Save as agent.py and run python agent.py. It uses the standard library only.
"""Starter agent: replace ScriptedModel with a call to your model provider."""
import json
from dataclasses import dataclass
from typing import Callable
MAX_STEPS = 6
@dataclass
class Tool:
run: Callable[..., object]
params: dict # name -> required Python type
needs_approval: bool = False
TOOLS = {
"lookup_order": Tool(lambda order_id: {"id": order_id, "status": "shipped"},
{"order_id": str}),
"cancel_order": Tool(lambda order_id: {"id": order_id, "status": "canceled"},
{"order_id": str}, needs_approval=True),
}
class ScriptedModel:
"""Returns prepared decisions, so tests need no network and no key."""
def __init__(self, decisions):
self.decisions = iter(decisions)
def decide(self, history):
return next(self.decisions, {"answer": "I have no further step."})
def call_tool(name, args, approve):
tool = TOOLS.get(name)
if tool is None:
return {"error": f"unknown tool {name}"}
if set(args) != set(tool.params) or any(
not isinstance(args[k], t) for k, t in tool.params.items()):
return {"error": "arguments do not match the schema"}
if tool.needs_approval and not approve(name, args):
return {"error": "not approved"}
try:
return {"result": tool.run(**args)}
except Exception as error: # report, do not crash the loop
return {"error": type(error).__name__}
def run(task, model, approve=lambda name, args: False, log=print):
history = [{"role": "user", "content": task}]
for step in range(1, MAX_STEPS + 1):
decision = model.decide(history)
if "answer" in decision:
return decision["answer"]
outcome = call_tool(decision["tool"], decision.get("args", {}), approve)
log(json.dumps({"step": step, "tool": decision["tool"], **outcome}))
history.append({"role": "tool", "content": outcome})
return "Stopped: step limit reached."
if __name__ == "__main__":
model = ScriptedModel([
{"tool": "lookup_order", "args": {"order_id": "A-1"}},
{"tool": "cancel_order", "args": {"order_id": "A-1"}},
{"tool": "delete_everything"},
{"answer": "Order A-1 has shipped. I did not cancel it."}])
print(run("Where is order A-1?", model))
looping = ScriptedModel([{"tool": "lookup_order", "args": {"order_id": 7}}] * 99)
print(run("loop", looping, log=lambda line: None))
Output:
{"step": 1, "tool": "lookup_order", "result": {"id": "A-1", "status": "shipped"}}
{"step": 2, "tool": "cancel_order", "error": "not approved"}
{"step": 3, "tool": "delete_everything", "error": "unknown tool delete_everything"}
Order A-1 has shipped. I did not cancel it.
Stopped: step limit reached.
Three things to notice: the cancel request is refused because nobody approved it; the invented tool is refused; and a model that repeats a bad call is stopped by the step limit.
TypeScript starter
Save as starter.ts. Recent Node.js 22 releases run it directly with node starter.ts by removing type annotations; that does not check types, so also run the TypeScript compiler with --noEmit in your build.
// Starter agent. Replace scripted() with a call to your model provider.
type Decision = { answer: string } | { tool: string; args: Record<string, unknown> };
type Tool = {
check: (args: Record<string, unknown>) => boolean;
run: (args: Record<string, unknown>) => Promise<unknown>;
needsApproval?: boolean;
};
const MAX_STEPS = 6;
const hasOrderId = (a: Record<string, unknown>) =>
Object.keys(a).length === 1 && typeof a.order_id === "string";
const tools = new Map<string, Tool>([
["lookup_order", { check: hasOrderId,
run: async (a) => ({ id: a.order_id, status: "shipped" }) }],
["cancel_order", { check: hasOrderId, needsApproval: true,
run: async (a) => ({ id: a.order_id, status: "canceled" }) }],
]);
function scripted(decisions: Decision[]) {
let next = 0;
return async (): Promise<Decision> =>
decisions[next++] ?? { answer: "I have no further step." };
}
async function callTool(name: string, args: Record<string, unknown>,
approve: (name: string) => Promise<boolean>) {
const tool = tools.get(name);
if (!tool) return { error: `unknown tool ${name}` };
if (!tool.check(args)) return { error: "arguments do not match the schema" };
if (tool.needsApproval && !(await approve(name))) return { error: "not approved" };
try {
return { result: await tool.run(args) };
} catch {
return { error: "tool failed" };
}
}
async function run(model: () => Promise<Decision>,
approve = async (_name: string) => false): Promise<string> {
for (let step = 1; step <= MAX_STEPS; step++) {
const decision = await model();
if ("answer" in decision) return decision.answer;
const outcome = await callTool(decision.tool, decision.args, approve);
console.log(JSON.stringify({ step, tool: decision.tool, ...outcome }));
}
return "Stopped: step limit reached.";
}
console.log(await run(scripted([
{ tool: "lookup_order", args: { order_id: "A-1" } },
{ tool: "cancel_order", args: { order_id: "A-1" } },
{ tool: "delete_everything", args: {} },
{ answer: "Order A-1 has shipped. I did not cancel it." },
])));
export {};
Output:
{"step":1,"tool":"lookup_order","result":{"id":"A-1","status":"shipped"}}
{"step":2,"tool":"cancel_order","error":"not approved"}
{"step":3,"tool":"delete_everything","error":"unknown tool delete_everything"}
Order A-1 has shipped. I did not cancel it.
Types describe what your code expects; they do not validate data arriving from a model at run time. The check function does that. For real tools, use a schema validation library and generate the tool description from the same schema.
Java starter
Save as Starter.java and run java Starter.java. It needs no build tool or dependency and uses sealed interfaces, records and pattern matching from Java 21.
// Starter agent with no dependencies. Run with: java Starter.java (Java 21)
import java.util.*;
import java.util.function.*;
public class Starter {
sealed interface Decision permits Answer, Call {}
record Answer(String text) implements Decision {}
record Call(String tool, Map<String, Object> args) implements Decision {}
record Tool(Function<Map<String, Object>, String> run, boolean needsApproval) {}
static final int MAX_STEPS = 6;
static final Map<String, Tool> TOOLS = Map.of(
"lookup_order", new Tool(a -> a.get("order_id") + " shipped", false),
"cancel_order", new Tool(a -> a.get("order_id") + " canceled", true));
static String callTool(Call call, Predicate<Call> approve) {
Tool tool = TOOLS.get(call.tool());
if (tool == null) return "error: unknown tool " + call.tool();
if (!call.args().keySet().equals(Set.of("order_id"))
|| !(call.args().get("order_id") instanceof String))
return "error: arguments do not match the schema";
if (tool.needsApproval() && !approve.test(call)) return "error: not approved";
try {
return tool.run().apply(call.args());
} catch (RuntimeException e) {
return "error: tool failed";
}
}
static String run(Iterator<Decision> model, Predicate<Call> approve) {
for (int step = 1; step <= MAX_STEPS; step++) {
Decision d = model.hasNext() ? model.next() : new Answer("No further step.");
switch (d) {
case Answer a -> { return a.text(); }
case Call c -> System.out.println(
"step " + step + " " + c.tool() + " -> " + callTool(c, approve));
}
}
return "Stopped: step limit reached.";
}
public static void main(String[] args) {
Map<String, Object> id = Map.of("order_id", "A-1");
List<Decision> script = List.of(
new Call("lookup_order", id), new Call("cancel_order", id),
new Call("delete_everything", Map.of()),
new Answer("Order A-1 has shipped. I did not cancel it."));
System.out.println(run(script.iterator(), call -> false));
}
}
Output:
step 1 lookup_order -> A-1 shipped
step 2 cancel_order -> error: not approved
step 3 delete_everything -> error: unknown tool delete_everything
Order A-1 has shipped. I did not cancel it.
For a Java service, move this loop behind your web framework and consider the libraries covered in Java: Spring AI and LangChain4j.
Connect a real model
- Keep the interface: history goes in, one decision comes out.
- Use your provider's official library and its tool-calling feature. Describe each tool from the same schema your code validates.
- Read the key from an environment variable or secret store. Never commit it.
- Set a time limit, retry only errors that are safe to retry and add a spending limit (Set Up Your Agent Development Lab has one).
- Treat the returned decision as untrusted input. All checks stay.
- Keep the scripted model for tests, and add a small separate evaluation that uses the real one.
The starters lack authentication, persistent state, tracing, input size limits, timeouts around tools and protection against duplicate actions. Use the checklist below before real users or data.
Design document template
# Agent design: <name>
Owner: Reviewers: Date:
Problem and users:
Success measure (number, how checked, baseline today):
Out of scope:
Why an agent rather than a script or workflow:
Inputs and data (owner, sensitivity, retention):
Tools (name | reads or changes | limit | approval):
Flow and stop rules:
Failure handling and human handover:
Threats considered and controls:
Evaluation set and release bar:
Cost estimate and cap:
Rollout stages and rollback:
Open questions:
Two pages is usually enough. If the tool table is hard to fill in, the scope is not ready. See Architecture Decision Records and Reviews.
Diagram template
For each arrow, write what data crosses it and whose permission is used. More shapes are in Agent Pattern Catalog and Diagram Gallery.
Runbook template
# Runbook: <agent name>
On call: Business owner:
What it does / never does:
Dashboards and trace search:
Normal ranges (success, latency, cost per task, escalations):
STOP how to disable all actions (one step, tested on <date>)
DEGRADE how to switch to read-only or human handling
ROLLBACK how to restore previous model, prompt, tools and code
Alerts:
<alert> | meaning | first check | action | escalate to
Common failures:
model or tool outage | slow responses | loop or cost spike |
wrong answers after a change | suspected injection or data leak
Dependencies and their contacts:
Credential rotation steps:
Last drill and findings:
Incident record template
# Incident <id>: <short title>
Severity: Commander: Status:
Start / detected / contained / resolved (with time zone):
Impact: who and what was affected, how many, can it be reversed?
Actions the agent took (from systems of record, not its summary):
Versions: code, model, prompt, tools, policy
Timeline:
Contributing causes:
Which control should have prevented or limited this?
Fixes (owner, due date) and the new test case:
Notifications required and sent:
Write it without blame and keep personal data to the minimum. See Incident Runbook and Failure Mode Catalog.
Production readiness checklist
Purpose and quality
- Owner, users and success measure are written down
- Evaluation set covers normal, edge and hostile cases
- Release bar met on the exact versions being shipped
Safety and security
- Each tool has least privilege and a limit; changes need approval where required
- Users are authenticated and record-level access is checked
- Untrusted content cannot trigger actions without checks
- Secrets are managed and rotated; logs redact sensitive values
Reliability and operations
- Time limits, retries and idempotency are in place
- Traces connect request, model calls, tools and approvals
- Alerts have owners; stop and rollback were rehearsed
- Capacity and provider limits were tested
Cost and obligations
- Budget, cap and cost per task are monitored
- Privacy notice, retention, deletion and required disclosures are done
- Users know how to reach a person and report problems
Cost estimation spreadsheet
Save the text below as cost.csv and open it in a spreadsheet, making sure formulas are evaluated on import. Row numbers matter. Prices are placeholders.
Item,Value,Note
Tasks per month,20000,expected volume
Model calls per task,4,measure from traces
Input tokens per call,3000,includes history and tool results
Output tokens per call,400,
Input price per million tokens,1.00,example only: use your price
Output price per million tokens,5.00,example only: use your price
Tool and search cost per task,0.002,
Share of tasks sent to a person,0.08,
Cost of one human review,0.90,
Fixed monthly platform cost,300,hosting storage and logging
Model cost per task,"=B3*(B4*B6+B5*B7)/1000000",
Variable cost per task,=B12+B8+B9*B10,
Monthly total,=B2*B13+B11,
Cost per task including fixed,=B14/B2,
Share spent on human review,=B2*B9*B10/B14,
| Calculated result with the example values | Value |
|---|---|
| Model cost per task | 0.020 |
| Variable cost per task | 0.094 |
| Monthly total | 2,180 |
| Cost per task including fixed | 0.109 |
| Share spent on human review | about 66% |
In this example, people's review time costs far more than the model, so lowering the review share safely would matter more than a cheaper model. Add retries, failed tasks, evaluation runs, embeddings and storage when they apply. See Agent Cost Model and Token Economics.
More templates on this site
| Need | Where |
|---|---|
| System prompt patterns | Agent System Prompts and Instruction Hierarchy and Prompt Templates and Tool-Use Prompting |
| Tool schemas | Designing Tool Schemas and Contracts |
| MCP and A2A starters | Lab: MCP Server and A2A Agent |
| Retrieval project | Build a RAG Knowledge Assistant |
| Supervisor and workers | Supervisor and Orchestrator-Worker Patterns |
| Human approval workflow | Human-in-the-Loop and Approval Gates |
| Checkpointing and long runs | Durable Execution, Checkpoints and Approvals |
| Evaluation harness and tracing | Lab: Evaluation Harness and Tracing |
| Security checklist and threat model | Lab: Least Privilege, Authentication and RBAC |
| Portfolio ideas | Agentic AI Projects and Portfolio Ideas |
Adapt a template without breaking it
- Run it unchanged and record the output.
- Write one test for the behavior you want, and one for what must never happen.
- Add one read-only tool. Only later add a tool that changes something, with approval.
- Connect the real model behind the same interface.
- Commit after each step so you can return to a working state.
Common mistakes
| Mistake | Better practice |
|---|---|
| Deleting checks to get a demo working | Fix the arguments or the schema |
| Auto-approving everything "for now" | Keep default no; approve in tests explicitly |
| Copying a template without reading it | Break each check once to see what it protects |
| A runbook nobody has rehearsed | Practice stop and rollback |
| Estimating cost from one happy path | Use measured calls, retries and review rates |
Checklist for your copy
- Starter runs and its tests are in version control
- No secrets in the repository
- Design page filled in and reviewed
- Runbook has a tested stop step
- Cost sheet uses your measured numbers
Frequently asked questions
Should I start with a framework instead?
Either is fine. Building the small loop once helps you see what a framework does for you. Then read Choosing Frameworks: Lock-In, Upgrades and Benchmarks.
May I reuse these templates at work?
Check the site's terms and your organization's rules, and review the code as you would any dependency.
Why no model library in the starters?
Provider libraries change often and need keys. A small interface keeps the starter runnable and lets you choose.
Which language should I pick?
Usually the one your team already operates well. Tool access, tests and monitoring matter more than the language.
References and further reading
- Python venv documentation
- Node.js: TypeScript support
- Java SE 21 documentation
- Google: Site Reliability Engineering book
- OWASP GenAI Security Project
Next steps
Lab: Browser Agent and Coding Agent
Build your first guided agents.
Lab: Evaluation Harness and Tracing
Test what you built.
Deploying Agents to Production
Plan for real traffic.