1. Environment Setup
Set up your local development environment to build your own AI agent from scratch. This workshop is designed for you to follow along and build a practical laboratory project.
Prerequisites Checklist
Before you begin, ensure you have:
- Python 3.10+: The core language for our agent logic.
- uv: An extremely fast Python package and environment manager.
- VS Code (Recommended): Our preferred code editor with excellent Python support.
- Terminal Access: macOS/Linux terminal or Windows PowerShell.
- GitHub Account: Required for accessing GitHub Models.
- Git: To version control your workspace (optional but recommended).
Steps
1. Create Your Practical Lab Directory
Start by creating a dedicated folder for your workshop project. We are going to build “OpsAgent”, an intelligent cross-team operations agent that leverages the Microsoft Agent Framework to bridge tools and user interfaces.
[!NOTE] This directory will serve as the root for all your project files and configurations.
# Initialize a new project
uv init lab --python 3.12
# or without a Python version (defaults to latest)
uv init lab
# Change into the project directory
cd lab
2. Create and Activate Virtual Environment
Use uv to manage your dependencies in an isolated environment.
# Create a virtual environment
uv venv
# Activate it (macOS / Linux)
source .venv/bin/activate
# Activate it (Windows)
.venv\Scripts\activate
3. Install Core Dependencies
We need specific libraries to build OpsAgent.
What are we installing? and why we need them?
- agent-framework: The Microsoft Agent Framework core for defining agent logic and workflows.
- python-dotenv: To securely load configuration (like API tokens) from a
.envfile. - httpx: A modern HTTP client for making asynchronous requests.
- openai: The standard client for interacting with LLM providers (including GitHub Models).
- chainlit: A beautiful framework to create a chat-based web interface instantly.
- streamlit: Another popular framework for building interactive web apps with Python.
[!IMPORTANT]
- Make sure your virtual environment is activated before installing dependencies.
- The installer will fail without the
--prerelease=allowflag becauseagent-frameworkdepends on a very specific beta version ofazure-search-documentsthat is currently unavailable, so dependency resolution becomes impossible.
Install them using uv:
uv pip install agent-framework python-dotenv httpx openai chainlit streamlit --prerelease=allow
# or
uv add agent-framework python-dotenv httpx openai chainlit streamlit --prerelease=allow
[!TIP] Alternatively, if you have a
requirements.txtfile, you can runuv pip install -r requirements.txt.Below is an example
requirements.txtcontent for reference:agent-framework python-dotenv httpx openai chainlit streamlit
4. Create Environment File
Create a .env file in the root of your lab directory:
touch .env
Add these lines to your .env file, replacing the placeholders with your actual GitHub token and desired model:
GITHUB_TOKEN=your_github_token
GITHUB_MODEL=gpt-4o-mini
Validation
Run the following to verify your environment is ready:
uv --version
python --version
uv run main.py
pip list | grep agent-framework
# or
uv pip list | grep agent-framework
Next
Continue to 2. GitHub Models Connection.