0
Phase 4

Core Concepts

~4 min read

Concept & How It Works

    Why Does It Exist?

    LLMs alone can only produce text. Real work requires calling APIs, querying databases, browsing the web, writing files, and coordinating multi-step workflows. Agents wrap LLMs in an execution loop with tools and memory, turning a chatbot into a system that actually gets things done.

    Real-World Analogy

    A chatbot is a consultant who gives advice from a chair. An agent is a consultant who gets up, logs into your systems, pulls the data, drafts the report, sends it for review, and follows up — reporting back at each step.
    Loading diagram...

    Visual Workflows

    What is Core Concepts?

    Loading diagram...

    Example

    Scenario

    User: 'Analyze our Q3 sales data and email the summary to the leadership team.' Agent: queries SQL database → aggregates results → generates chart → drafts email → requests human approval → sends via email API → confirms completion.

    Solution

    In Agent Foundations, apply Core Concepts to this scenario: User: 'Analyze our Q3 sales data and email the summary to the leadership team. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

    Practice Task

    Do this before moving to the next module — reading alone is not enough.

    Open the Code Walkthrough below and run it locally. Change one parameter related to Core Concepts (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

    Code Walkthrough

    Highlighted lines show where Core Concepts happens in the code.

    Core Concepts
    1from openai import OpenAI  # import dependencies2
    3client = OpenAI()  # create API client4
    5tools = [6    {"type": "function", "function": {7        "name": "query_database",8        "description": "Run a SQL query on the sales database",9        "parameters": {"type": "object", "properties": {10            "sql": {"type": "string"}11        }, "required": ["sql"]}12    }},13    {"type": "function", "function": {14        "name": "send_email",15        "description": "Send an email to recipients",16        "parameters": {"type": "object", "properties": {17            "to": {"type": "string"}, "subject": {"type": "string"}, "body": {"type": "string"}18        }, "required": ["to", "subject", "body"]}19    }},20]21
    22messages = [{"role": "user", "content": "Analyze Q3 sales and email leadership"}]23# Agent loop: call LLM → if tool_calls → execute → append result → repeat

    Commands to Remember

    Commands to Remember

    • pip install openai # minimal agent = LLM API + Python loop
    • python agent.py # run your agent script
    • pip install python-dotenv # load API keys from .env

    Common Mistakes

    • No iteration limit — agent runs forever on impossible tasks
    • Giving agents unrestricted tool access without sandboxing
    • No observability — impossible to debug agent failures
    • Treating agents as chatbots with one extra API call
    • No human approval for destructive actions (delete, send, pay)

    Cheat Sheet

    Quick recap — the most important points from this module.

    Cheat Sheet

    quick ref
    • Agent = LLM + Tools + Memory + Loop
    • Max iterations prevent runaway
    • Sandbox tool execution
    • Human approval for writes/deletes
    • Trace every step
    • Cost budget per run