Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
Agents are the wrong tool for a lot of work that the AI hype suggests they're right for. If the task is deterministic, an agent adds latency and unpredictability without improving anything. If user expectations require strict guarantees (legal, financial transactions), the open-loop nature of agents fights you. If cost matters and the task is high-volume, agents 3-5x your bill vs a workflow. The discipline: default to workflow; reach for agent only when the task genuinely needs runtime decisions.
Use workflow when: (1) the steps are deterministic. (2) you need strict latency SLAs. (3) you need predictable cost. (4) the task is high-volume and price-sensitive. (5) compliance requires reproducibility. Use agent when: (1) the tool choice depends on the user's request. (2) the path through tools varies (retry, branch, dead-end). (3) the task is exploratory (research, debugging). Most production AI work is the first list, not the second.
# --- Pick your provider (set the matching API key env var) ---
# Anthropic: from anthropic import Anthropic; client = Anthropic() # ANTHROPIC_API_KEY
# OpenAI: from openai import OpenAI; client = OpenAI() # OPENAI_API_KEY
# Gemini: from google import genai; client = genai.Client() # GEMINI_API_KEY
# When workflow is right
def get_user_summary(user_id):
user = db.get(user_id) # not LLM
recent = db.recent_orders(user_id, limit=10) # not LLM
summary = generate_summary(user, recent) # 1 LLM call
return summary
# Deterministic, fast (~500ms), cheap (~$0.005).
# When agent is right
def help_me_debug_this_error(error_msg, codebase):
# Steps depend on the error — might need to grep code,
# read docs, search SO, look at git blame, run tests.
# No fixed path.
return run_debugging_agent(error_msg, codebase, max_steps=10)
# Variable cost ($0.05-$0.50), variable latency (10-60s), high value if it works.
# Anti-pattern: an agent for a workflow
def classify_ticket_with_agent(ticket):
# gives the model "search_kb" and "ask_human" tools
# but really we just want CLASSIFY -> RETURN
# so we end up paying agent overhead for a 1-call task.
...
# This is a workflow:
def classify_ticket(ticket):
return client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=20,
system="Classify into: billing, technical, sales, other. Reply one word.",
messages=[{"role": "user", "content": ticket}],
).content[0].text.strip()python3 main.py