Build Your First AI Agent in Python (Step by Step)

About this video

David builds a first AI agent in Python step by step using Agentspan, described as a free open-source framework and the video’s sponsor. Prerequisites are Python at least version 3.10, a Java Development Kit (install the latest long-term support JDK, 25 as of filming, though 21 is also supported), and the uv package manager, with setup in VS Code. The project is created with uv init, Agentspan added with uv add agentspan, and checked with uv run agentspan doctor. Provider setup is covered for a local Ollama instance, OpenAI via platform.openai.com API keys, and Anthropic via platform.claude.com, setting the corresponding environment variable such as OPENAI API key, plus a fix for a certificate verification failure especially prevalent on Mac. Building is broken into three steps: write tools, write the agent, write code to run it. A tool is a Python function exposed with the @tool decorator — its function name, type hints, return value, and docstring give the model clues — exemplified by a hardcoded get_weather function. The agent requires a name, a model in provider/model format, and a tool list; the demo uses 5.4-mini for speed. The runtime connects to the Agentspan server, started with uv run agentspan server start (about 30 seconds the first time), and the agent is run with uv run main.py (about 10 seconds), with executions inspected in the Agentspan dashboard, including tool call inputs and outputs. A second agent, testbot, writes unit tests for a price calculator module with four functions calculating discounts, taxes, shipping, and total costs, making all four tool calls in parallel. For resilience, resilient_agent.py uses runtime.start to get an execution ID, then resumes an existing run with that ID after the Python process is killed mid-run (the tool sleeps for two seconds to allow interruption). Because the server owns agent state, work resumes on the same execution, and tools must be idempotent — save_tests does not rewrite tests already in the file — allowing the script to crash, restart, or move machines, and in deployment the server can run on a different machine.

Key takeaways

  • Prerequisites: Python 3.10+, JDK (latest LTS 25 as of filming, 21 also supported), uv, and VS Code; set up with uv init, uv add agentspan, and uv run agentspan doctor
  • Build in three steps — tools, agent, runner code; a tool is a Python function with @tool where name, type hints, return, and docstring guide the model
  • An agent needs a name, a provider/model string, and a tool list; the demo uses 5.4-mini and runs via an Agentspan server started with uv run agentspan server start
  • The Agentspan dashboard records every execution so you can inspect the workflow graph and each tool call’s exact inputs and outputs
  • Resilience comes from server-owned state: capture an execution ID with runtime.start, resume that same run after a crash, and make tools idempotent so retries don’t duplicate work

Episode details: published June 17, 2026 · 12:19 long. Summary written by Self Growth Videos from the episode itself. Business results and any income figures mentioned are Kevin Stratvert’s own claims, shared for education — they are not typical or guaranteed.


← Previous: How to use Claude in Microsoft Word · Next: Claude Connectors Tutorial for Beginners →

All Kevin Stratvert videos · Kevin Stratvert profile · Kevin Stratvert on YouTube

Sister brand · Vacation Club Promo

All-inclusive resort stays from $435

Qualified couples: promotional Mexico and Caribbean packages at real resorts. Short presentation during your stay — enjoy the rest of the trip.

Qualifications apply · presentation during stay · no purchase required

Subscribe YouTube Suggest