Agentic AI Notebook
Agent Foundations
Phase 4Module 2 of 15

Why LLMs Need Agents

Production needs live data, accurate math, citations, and side effects — not guesses from training data.

An LLM alone is a strategist locked in a room with no phone. An agent gives them tools and permission to act.

Visual Workflows

Start here — scroll inside each diagram frame to explore, then use + / to zoom up to 200% if needed.

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Agent vs Chatbot Decision

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Use this flow when scoping a new AI feature.

Key Takeaways

  • 1.LLMs are stateless predictors with frozen training knowledge.
  • 2.Agents add tools for live data and real-world actions.
  • 3.Loops enable multi-step tasks pure prompting cannot solve.
  • 4.Memory and RAG ground answers in facts.

Real Example

Scenario

Finance asks: 'What were our Q3 APAC sales?' A raw LLM answers '$4.2M' from memory. An agent runs `SELECT SUM(revenue) FROM sales WHERE quarter='Q3' AND region='APAC'` and returns $3.87M with the query cited.

What you would do

The chatbot hallucinates a plausible number because it has no live data access. The agent selects the SQL tool, executes against Snowflake, and grounds the answer in query output. You would log whether finance answers include a SQL citation and track hallucination reports from users.

Practice Task

List three requests your team gets that need live data or side effects (send email, update CRM, run code). For each, explain why a plain LLM chat fails and name the one tool that closes the biggest gap.

Code Walkthrough

Highlighted lines show where Why LLMs Need Agents happens in the code.

Why LLMs Need Agents
1from openai import OpenAI  # import dependencies2
3client = OpenAI()  # create API client4question = "What were our Q3 APAC sales in dollars?"5
6# LLM-only — no tools, will guess from training data7guess = client.chat.completions.create(  # call the API8    model="gpt-4o-mini",9    messages=[{"role": "user", "content": question}],10)11print("LLM-only:", guess.choices[0].message.content)  # show output for debugging12
13# Agent path — tool returns real warehouse data14def run_sql(query: str) -> str:  # define a reusable function15    return '{"total_revenue": 3870000, "region": "APAC", "quarter": "Q3"}'  # return the result16
17agent = client.chat.completions.create(  # core API call for Why LLMs Need Agents18    model="gpt-4o-mini",19    messages=[{"role": "user", "content": question}],20    tools=[{"type": "function", "function": {"name": "run_sql", "parameters": {"type": "object", "properties": {"query": {"type": "string"}}}}}],21)22# Execute tool call, append observation, ask again for grounded answer

Cheat Sheet

Quick recap

quick ref
  • LLM alone cannot act on the world
  • Tools = live data and side effects
  • Loops = multi-step reasoning
  • RAG = reduce hallucinations
  • Use chatbot when no tools needed

Common Mistakes

  • Skipping evaluation for Why LLMs Need Agents before production
  • No logging or tracing around why llms need agents steps
  • Ignoring cost and latency implications