Building Advanced AI Agents in Python
An intensive workshop in which participants build a working AI agent directly in Python, without high-level agent frameworks. The emphasis is on understanding and implementing the mechanisms behind modern agents: LLM integration, structured outputs, tools, execution loops, state, memory, planning, reliability, and guardrails.
Objectives
- Explain the architecture and execution model of an AI agent.
- Expose Python functions as tools and dispatch tool calls dynamically.
- Handle tool/model failures, retries, loops, permissions, and human approval.
- Integrate an LLM with Python and validate structured model output.
- Build a multi-step agent loop with state, memory, planning, and stop conditions.
- Refactor the prototype into a clean, testable Python architecture and understand what agent frameworks automate.
Target Audience
Advanced Python developers, backend engineers, software architects, and AI developers.
Prerequisites & Experience
Participants should be comfortable with classes, type hints, data classes, JSON, exceptions, APIs, packages, virtual environments, and basic Asencio concepts.
Recommended Technology Stack
- Core – Python 3.12+, OpenAI-compatible LLM API, Pydantic, httpx, python-dotenv, SQLite, logging.
- Development – PyCharm / VS Code, venv, Git, pytest; optional: FastAPI, asyncio, PostgreSQL, FAISS/ChromaDB, Docker.
Minimum Implementation Requirements
- LLM API integration and system instructions
- At least one protected action requiring user approval
- Agent state and short-term context
- Planning / task decomposition
- Logging and repeated-action detection
- Pydantic models for structured decisions
- Dynamic tool execution and an agent loop
- Basic persistent memory (SQLite)
- Error handling, retries, and maximum execution steps
- At least three Python tools and a tool registry
Agenda
Agent Architecture & LLM Integration
From chatbot to agent; agent components; system/user/tool messages; minimal LLM client.
Structured Output & Tool Calling
Pydantic schemas; tool metadata; native function calling; tool registry; dynamic dispatch.
Building the Agent Execution Loop
Multi-step execution; AgentState; observations; tool results; completion and maximum-step conditions.
Memory & Context
Short-term history; state vs. memory; persistent SQLite memory; brief introduction to embeddings/RAG.
Planning & Multi-Step Tasks
Task decomposition; structured plans; planner–executor pattern; progress tracking; re-planning after failure.
Reliability & Guardrails
Invalid output; tool exceptions; retry strategy; repeated-action detection; budgets; tool permissions; human-in-the-loop.
Clean Python Architecture
Separation of concerns; Tool interface; dependency injection; configuration; logging; mocking LLMs; testing.
Capstone Challenge
Combine the components into an autonomous research-and-analysis agent.