Module 3: Advanced Customization
Run the agent loop locally via a notebook
Module Summary
- Goal: Customize agent loops, add Python tools, and run the agent locally
- Prerequisites: Python 3.12, Node.js v22
What you’ll do in This module
In this module, you’ll gain full control over your agent’s behavior.
You’ll learn how to:
- Run your agent locally via a Jupyter notebook.
- Customize the agent loop, allowing advanced logic or prompt shaping
- Add your own Python tools to expand what the agent can do
Environment Setup
Tool | Required Version |
---|---|
Python | 3.12.7 |
Node.js | v22 |
Use pyenv
and nvm
to manage these versions if needed:
Clone the template repository
CLI Login & Agent Initialization
Install the CLI and initialize your agent:
To get the Agent ID of your SWE agent for the initialization part:
- Go back to the AI Workbench
- Click the “SDK” trigger node, at the top part of the canvas
- Copy the Agent ID from there, and paste it in the CLI prompt
This creates the following files:
xpander_config.json
agent_instructions.json
requirements.txt
Install agent dependencies
Fill in the required values in .env
:
If you’re running the workshop in an event, get the OpenAI key from the event’s Notes file, or use your own key.
Run the agent via a Jupyter notebook.
Here, we’ll step through the agent lifecycle.
Open my_agent.ipynb
in VSCode, Cursor, Jupyter Lab, or any notebook viewer.
Run through the notebook, and then come back to this guide to add local tools in the next step.
Add a Local Tool to Star a GitHub Repository (Optional)
In this step, you’ll enable your agent to run a custom tool that stars a GitHub repository.
1. Generate a GitHub Token
First, create a GitHub personal access token:
👉 Generate Token
⏳ Note: Make sure to select full repo access scope in order to star a repo.
2. Add the Token to Your .env
File
Update your .env
file with the following:
🧩 3. Define the Custom Tool
Replace the contents of tools/local_tools.py
with:
🔄 4. Reload the Agent
Add a new cell to reinitialize the agent with the updated tools:
🤖 5. Ask the Agent to Star a Repository
Add a new cell to send a prompt to the agent: