Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ async def call_agent_with_tools(query: str, trace_id: str) -> str:
### Essential Commands

```bash
make setup # Install deps - ALWAYS run first
make env # Validate OPENAI_API_KEY - run before exercises 1,3,4
make temporal-up # Start Temporal server - REQUIRED for exercises 2,3,4
make exercise-{1-4} # Run specific exercise
Expand Down
14 changes: 13 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ All tool calls have to be real, no mocking. Use the [weather API](https://docs.t
### Setup & Environment

```bash
make setup # Install dependencies and set up environment
# Installation is done via temporal_installation.ipynb
# Packages are installed per-exercise in each notebook
make env # Validate environment variables (OPENAI_API_KEY)
```

Expand Down Expand Up @@ -126,6 +127,7 @@ if __name__ == "__main__":
Exercise 3 follows the production-ready structure from [temporal-weather-openai-agents](https://github.com/nadvolod/temporal-weather-openai-agents):

#### **Component 1: activities.py**

```py
import httpx
from temporalio import activity
Expand Down Expand Up @@ -156,6 +158,7 @@ async def get_weather(state: str) -> dict:
```

#### **Component 2: workflow.py**

```py
from datetime import timedelta
from temporalio import workflow
Expand Down Expand Up @@ -184,6 +187,7 @@ class WeatherAgentWorkflow:
```

#### **Component 3: worker.py**

```py
from temporalio.client import Client
from temporalio.worker import Worker
Expand Down Expand Up @@ -215,6 +219,7 @@ async def main():
```

#### **Component 4: starter.py**

```py
from temporalio.client import Client
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
Expand All @@ -236,6 +241,7 @@ async def main():
```

**Key Benefits:**

- ✅ Clean separation of concerns - each component has one responsibility
- ✅ Agent tool calls are durable and automatically retried by Temporal
- ✅ Full execution history visible in Temporal UI
Expand All @@ -244,6 +250,7 @@ async def main():
- ✅ Proper sandbox configuration with `with_passthrough_modules()`

**Important Notes:**

- Activity returns `dict` not string - LLM interprets structured data
- Single parameter: `user_query` (no trace_id)
- `Runner()` is instantiated (not just `Runner`)
Expand Down Expand Up @@ -296,6 +303,7 @@ class RoutingWorkflow:
```

**Key Differences from Other Exercises:**

- ❌ **NOT a Jupyter notebook** - uses separate Python files like production apps
- ✅ **3-file pattern:** workflow.py (logic) + worker.py (execution) + starter.py (invocation)
- ✅ **Multiple specialized agents** with handoff coordination
Expand Down Expand Up @@ -338,6 +346,7 @@ All workflows in this repository follow a consistent naming pattern for workflow
**Example:** `durable-agent-wed-oct-16-094832est`

**Implementation:**

```python
from datetime import datetime
import pytz
Expand All @@ -349,17 +358,20 @@ workflow_id = f"durable-agent-{now.strftime('%a-%b-%d-%I%M%S').lower()}est"
```

**Benefits:**

- Human-readable workflow IDs
- Chronologically sortable in Temporal UI
- Timezone-aware (EST) for workshop coordination
- Consistent pattern across all exercises

**Examples by Exercise:**

- Exercise 2: `hello-workflow-thu-oct-16-095919est`
- Exercise 3: `durable-agent-wed-oct-16-094832est`
- Exercise 4: `routing-fri-oct-17-103045est`

**Required Dependencies:**

- Add `pytz` to pip install commands: `%pip install --quiet temporalio openai-agents httpx rich nest-asyncio pytz`
- Import: `from datetime import datetime` and `import pytz`

Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ This is a **90-minute workshop**: 30 minutes instruction + 4×15 minute exercise
**Goal:** Create a simple AI agent with tool calling using real weather data

**What you'll learn:**

- 🤖 Build your first OpenAI agent with a weather tool
- 🔧 Understand the agent → tool → response flow
- 💡 See how LLMs decide when to use tools
Expand All @@ -91,6 +92,7 @@ This is a **90-minute workshop**: 30 minutes instruction + 4×15 minute exercise
**Goal:** Understand Temporal workflows and activities

**What you'll learn:**

- 🏗️ Create your first Temporal workflow
- ⚙️ Learn about activities as units of work
- 🔍 Observe execution in the Temporal UI
Expand All @@ -105,6 +107,7 @@ This is a **90-minute workshop**: 30 minutes instruction + 4×15 minute exercise
**Goal:** Combine agents + Temporal for production durability ⭐

**What you'll learn:**

- 🔄 Wrap LLM calls in Temporal activities
- ✨ Get automatic retries on failures (magic! ✨)
- 💾 Persist agent state across crashes
Expand All @@ -122,6 +125,7 @@ This is a **90-minute workshop**: 30 minutes instruction + 4×15 minute exercise
**Goal:** Build a routing workflow with language-specific agents using production-ready file structure

**What you'll learn:**

- 🎯 Implement agent routing/triage patterns with OpenAI Agents SDK
- 🌍 Create specialized language agents (French, Spanish, English)
- 🔀 Use handoff patterns for agent-to-agent transitions
Expand All @@ -134,7 +138,6 @@ This is a **90-minute workshop**: 30 minutes instruction + 4×15 minute exercise

```bash
# 🔧 Setup and validation
make setup # Install all dependencies
make env # Check environment variables (OPENAI_API_KEY)

# 🧹 Code quality
Expand Down Expand Up @@ -228,6 +231,7 @@ pgrep -f temporal
```

**Fix:** Use the `temporal_installation.ipynb` notebook to install and start Temporal:

1. Open `temporal_installation.ipynb` in VS Code
2. Run each cell to install Temporal CLI and start the dev server
3. Verify at http://localhost:8233
Expand All @@ -241,9 +245,8 @@ The Temporal dev server must be running for exercises 2, 3, and 4! ⚡
**Problem:** Import errors when running exercises ❌

```bash
# Reinstall dependencies
make setup
# Or: pip install -e ".[dev]"
# Packages are installed per-exercise/solution in each notebook
# Run the first cell of the notebook to install required dependencies
```

---
Expand Down Expand Up @@ -304,20 +307,16 @@ pip install -e ".[dev]"
1. **Students skip checking `.env`** 🔑
- Do environment check before starting (`make env`)
- Emphasize that exercises 1, 3, 4 need API key

2. **Temporal not running** ⚡
- Remind students to use `temporal_installation.ipynb` notebook to install and start Temporal
- Walk through opening the notebook and running each cell
- Show them how to verify at http://localhost:8233

3. **Confusion between exercise and solution** 📓
- Clearly explain: work in `exercises/`, compare with `solutions/`
- Solution notebooks are complete standalone implementations

4. **Activity timeouts** ⏳
- Explain `start_to_close_timeout` defaults
- Show how to adjust for longer-running operations

5. **Notebook vs Python files** 📝
- Exercises 1-3 are Jupyter notebooks (`.ipynb`)
- Exercise 4 uses separate Python files (workflow.py, worker.py, starter.py)
Expand All @@ -328,16 +327,13 @@ pip install -e ".[dev]"
- **Exercise 1:** Emphasize tool calling as the foundation of agentic behavior 🤖
- Show how the agent decides to use tools
- Highlight the real API integration (National Weather Service)

- **Exercise 2:** Show the Temporal UI extensively - it's powerful for debugging! 🔍
- Walk through execution history
- Demonstrate the retry mechanism

- **Exercise 3:** THIS IS THE KEY 🌟
- Show how activities make LLM calls durable
- The agent code doesn't change - Temporal wraps it!
- Emphasize: production-ready with zero agent modifications

- **Exercise 4:** Advanced routing workflow with production file structure 🔀
- Language-based routing pattern (French/Spanish/English agents)
- Handoff pattern enables agent-to-agent transitions
Expand Down
9 changes: 7 additions & 2 deletions example-notebook/02-Adding-Durability-Solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1143,13 +1143,18 @@
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.11.14",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.11.13"
"version": "3.11.14"
},
"vscode": {
"interpreter": {
"hash": "default"
}
}
},
"nbformat": 4,
Expand Down
9 changes: 7 additions & 2 deletions example-notebook/03-Human-in-the-Loop-Solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@
"version": ""
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.11.14",
"language": "python",
"name": "python3"
},
Expand All @@ -1043,7 +1043,12 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.13"
"version": "3.11.14"
},
"vscode": {
"interpreter": {
"hash": "default"
}
}
},
"nbformat": 4,
Expand Down
27 changes: 23 additions & 4 deletions exercises/01_agent_hello_world/exercise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
" OPENAI_API_KEY=sk-your-key-here\n",
" ```\n",
"\n",
"2. **Dependencies:** Already installed if you ran `make setup`\n",
"2. **Dependencies:** Installed in the first cell of this notebook:\n",
Copy link

Copilot AI Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation states dependencies are 'Installed in the first cell of this notebook', but this conflicts with the project's established pattern where make setup is the primary installation method. While per-notebook installation provides self-containment, the documentation should clarify the relationship between these two approaches.

Copilot uses AI. Check for mistakes.
" - `openai-agents` - OpenAI Agents SDK\n",
" - `httpx` - Async HTTP client\n",
" - `python-dotenv` - Environment variable management\n",
Expand Down Expand Up @@ -319,18 +319,37 @@
{
"cell_type": "markdown",
"metadata": {},
"source": "## Next Steps\n\nOnce you've completed this exercise, you'll understand:\n\n- ✅ How to create agents with the OpenAI Agents SDK\n- ✅ How to define custom tools that call real APIs\n- ✅ How the agent decides when to use tools\n- ✅ How to run agents with async/await\n\n**Ready for more?** Proceed to:\n\n- **[Exercise 2: Temporal Hello World](../02_temporal_hello_world/exercise.ipynb)** - Learn Temporal workflows and activities\n- **[Exercise 3: Durable Agent](../03_durable_agent/exercise.ipynb)** - Combine agents + Temporal for production durability!"
"source": [
"## Next Steps\n",
"\n",
"Once you've completed this exercise, you'll understand:\n",
"\n",
"- ✅ How to create agents with the OpenAI Agents SDK\n",
"- ✅ How to define custom tools that call real APIs\n",
"- ✅ How the agent decides when to use tools\n",
"- ✅ How to run agents with async/await\n",
"\n",
"**Ready for more?** Proceed to:\n",
"\n",
"- **[Exercise 2: Temporal Hello World](../02_temporal_hello_world/exercise.ipynb)** - Learn Temporal workflows and activities\n",
"- **[Exercise 3: Durable Agent](../03_durable_agent/exercise.ipynb)** - Combine agents + Temporal for production durability!"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.11.14",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.11.0"
"version": "3.11.14"
},
"vscode": {
"interpreter": {
"hash": "default"
}
}
},
"nbformat": 4,
Expand Down
9 changes: 7 additions & 2 deletions exercises/02_temporal_hello_world/exercise.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,18 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3.11.14",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.11.13"
"version": "3.11.14"
},
"vscode": {
"interpreter": {
"hash": "default"
}
}
},
"nbformat": 4,
Expand Down
Loading
Loading