Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Created October 1, 2025 09:27
Show Gist options
  • Save owainlewis/3097a19b1e5ad2223383da898a88a6de to your computer and use it in GitHub Desktop.
Save owainlewis/3097a19b1e5ad2223383da898a88a6de to your computer and use it in GitHub Desktop.

AI Agents 101

In this short video I'll show you how to write an AI agent from scratch in Python using just a few lines of simple code. We'll learn how AI agents work.


The truth: An AI agent is just an LLM in a loop that can call functions.


The Loop

  1. Ask the LLM a question
  2. If it wants to use a tool, run that tool
  3. Give the result back to the LLM
  4. Repeat until it has a final answer

Setup

pip install openai
export OPENAI_API_KEY='your-key-here'
python agent.py

Code Download agent.py — the entire pattern in ~100 lines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment