Skip to main content

Agents vs Simple Prompts: When to Use Each

4/28
Chapter 1 Introduction to AI Agents

Agents vs Simple Prompts: When to Use Each

14 min read Lesson 4 / 28

Agents vs Simple Prompts: When to Use Each

Agents are powerful, but they introduce latency, cost, and failure modes that simple prompts do not. Knowing when to use each approach is a core engineering judgment.

When a Simple Prompt Is Enough

Use a single API call when:

  • The task has a well-defined input and output
  • No external data or tools are needed
  • The answer fits in one response
  • Latency requirements are under 2–3 seconds
# Good use of a simple prompt
response = client.messages.create(
    model="claude-haiku-4-5",
    max_tokens=512,
    messages=[{
        "role": "user",
        "content": "Summarize this 200-word paragraph in one sentence: ..."
    }],
)

When an Agent Is Worth It

Use an agent when:

  • You need to retrieve live or dynamic data (search, databases, APIs)
  • The problem requires multi-step decomposition
  • The answer depends on intermediate results
  • You need to take actions in external systems
# Requires agent: needs live search + multi-step reasoning
response = run_agent(
    "Compare the pricing of AWS Lambda and Google Cloud Functions for 1M requests/month",
    tools=[web_search_tool, calculator_tool],
)

The Complexity-Cost Matrix

                Low Reasoning    High Reasoning
No Tools        Simple prompt    Chain-of-thought prompt
With Tools      Single tool call Full agent loop

Common Anti-Patterns

Over-engineering: Using a 5-step agent for a task that a single well-crafted prompt handles perfectly.

Under-engineering: Cramming a multi-step research task into one prompt and wondering why the results are inconsistent.

Wrong model tier: Running a simple classification loop on Opus when Haiku would be 10x cheaper and equally accurate.

# Anti-pattern: agent where a prompt suffices
def translate_text(text: str, target_lang: str) -> str:
    # No tools needed — a single prompt is correct here
    # Do NOT wrap this in an agent loop
    response = client.messages.create(
        model="claude-haiku-4-5",
        max_tokens=1024,
        messages=[{
            "role": "user",
            "content": f"Translate to {target_lang}: {text}"
        }],
    )
    return response.content[0].text

Start with the simplest approach. Add agentic complexity only when you hit a wall that simpler solutions cannot solve.