Skip to content

Commit 9a8b9bc

Browse files
committed
Workshop-ready: pinned env, offline stubs, eval section, cleanup
- Pin deepagents==0.5.2 + langgraph==1.1.6 + langchain-core==1.2.28 to avoid the ToolRuntime 'tools' breakage in langgraph>=1.1.10 - Cap requires-python to >=3.11,<3.14 (3.14 breaks jsonschema-rs/pyo3 build) - Replace Tavily search_travel with deterministic offline stub (city KB, AA-first flight ordering) - Add Part 10 LangSmith evaluations (4 metrics, two-model comparison) - Trim notebook from 89 to 77 cells (collapsed 3 memory variants to 1, removed FilesystemBackend demos, trimmed Part 4 verbose demo) - agents/travel_planner/agent.py: async log_tool_calls middleware, user_id-or-anonymous fallback for namespace, docstring refresh - langgraph.json: register only Travel Planner (removed langgraph-101 forks) - README.md: rewrite for 11-part outline, pip + uv install paths, langgraph dev + Studio path - Add pip-tested requirements.txt - Gitignore runtime agent outputs
1 parent 9b1eebe commit 9a8b9bc

12 files changed

Lines changed: 1875 additions & 2262 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,8 @@ cython_debug/
174174
vertexCred.json
175175

176176
.idea
177+
178+
# Agent runtime outputs written to disk by FilesystemBackend during `langgraph dev`.
179+
# Source agent files (AGENTS.md, SKILL.md in subfolders) are not matched.
180+
/agents/travel_planner/*.md
181+
!/agents/travel_planner/AGENTS.md

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 79 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Deep Agents Travel Planner Workshop
22

3-
A hands-on, single-notebook walkthrough that builds a production-style travel planner agent from scratch using [Deep Agents](https://docs.langchain.com/oss/python/deepagents/overview) on top of LangChain and LangGraph.
3+
A hands-on, single-notebook walkthrough that builds a production-style travel planner agent from scratch using [Deep Agents](https://docs.langchain.com/oss/python/deepagents/overview) on top of LangChain and LangGraph, then evaluates it with LangSmith.
44

55
The notebook lives at `notebooks/deepagents-travel-planner.ipynb` and is designed to be worked through top-to-bottom in a guided session with a LangChain engineer.
66

@@ -10,28 +10,32 @@ By the end of the notebook you'll have a travel planning agent that can:
1010

1111
- Plan a multi-day trip from a single user request
1212
- Delegate research to specialized subagents (`hotel-search`, `flight-search`, `activity-search`) running in parallel
13-
- Read and write files on a virtual filesystem (or on real disk) via `read_file` / `write_file` / `edit_file`
13+
- Read and write files on a virtual filesystem via `read_file` / `write_file` / `edit_file`
1414
- Pause for human approval before "booking" anything
1515
- Remember a traveler's preferences across conversations (per-user, with a shared global namespace)
1616
- Follow a team-authored `AGENTS.md` and load on-demand `SKILL.md` files for each deliverable (itinerary, budget, packing list, travel brief)
1717
- Emit a final itinerary and budget in your team's exact format
1818

19+
You'll also build a small LangSmith evaluation suite that runs the same dataset against two OpenAI models (`gpt-5.4` and `gpt-4.1-mini`), with four metrics — trajectory match, constraint check, efficiency, and LLM-as-judge response quality — so you can compare cost / latency / quality side-by-side in the LangSmith experiment comparison view.
20+
1921
## Notebook Outline
2022

21-
The notebook is split into ten parts. Each part introduces one Deep Agents concept and adds one capability to the agent:
23+
The notebook is split into eleven parts. Each part introduces one concept and adds one capability:
2224

2325
| Part | Topic | What's introduced |
2426
| --- | --- | --- |
25-
| 0 | Setup & Installation | `uv sync`, `.env`, model config |
27+
| 0 | Setup & Installation | `uv sync` or `pip install -r requirements.txt`, `.env`, model config |
2628
| 1 | Your First Deep Agent | `create_deep_agent`, the harness, planner + virtual filesystem out of the box |
27-
| 2 | Adding Custom Tools | Domain tools for discovery, pricing, and availability |
28-
| 3 | Understanding Backends | `StateBackend`, `FilesystemBackend`, `CompositeBackend`, `StoreBackend` |
29+
| 2 | Adding Custom Tools | Deterministic offline stubs for discovery (`search_travel`) and pricing/availability |
30+
| 3 | Understanding Backends | `StateBackend` (per-thread default), preview of `StoreBackend` for cross-thread persistence |
2931
| 4 | Adding Subagents | `hotel-search`, `flight-search`, `activity-search` + an orchestrator that fans out via `task()` |
30-
| 5 | Middleware Deep Dive | Inspecting `write_todos`, writing a `@wrap_tool_call` logger |
32+
| 5 | Middleware Deep Dive | Built-in `TodoListMiddleware`, writing a custom `@wrap_tool_call` logger |
3133
| 6 | Human-in-the-Loop | `HumanInTheLoopMiddleware`, interrupts, `Command(resume=...)` |
32-
| 7 | Long-Term Memory | `StoreBackend` routed via `CompositeBackend`, per-user vs shared namespaces |
34+
| 7 | Long-Term Memory | `CompositeBackend` routing `/memories/user/` and `/memories/shared/` to a `StoreBackend` with per-user namespaces |
3335
| 8 | `AGENTS.md` & Skills | Identity file + on-demand `SKILL.md` files for each deliverable |
3436
| 9 | The Complete Travel Planner | All layers composed end-to-end |
37+
| 10 | Evaluations | LangSmith dataset, four evaluators (trajectory, constraint, efficiency, LLM-judge), two-model comparison |
38+
| 11 | Next Steps | Where to take the agent next (real APIs, calendar, multi-leg trips, group travel) |
3539

3640
Each part is independently runnable — you can stop at any layer and have a working agent for that scope.
3741

@@ -40,37 +44,70 @@ Each part is independently runnable — you can stop at any layer and have a wor
4044
### Clone the repo
4145
```bash
4246
git clone <repo-url>
43-
cd deepagents-workshop
47+
cd travel-planner-deepagents-workshop
4448
```
4549

4650
### Configure environment variables
4751
```bash
4852
cp .env.example .env
49-
# Fill in your model + Tavily keys
53+
# Fill in: OPENAI_API_KEY (or your provider's keys) + LANGSMITH_API_KEY for Part 10 evals
5054
```
5155

56+
No Tavily key needed — discovery is handled by a deterministic offline stub so the workshop runs without external APIs.
57+
5258
If corporate policy blocks API keys, contact your LangChain representative and we'll find a workaround.
5359

5460
### Install dependencies
55-
This project uses [`uv`](https://github.com/astral-sh/uv):
61+
62+
Two options — both install the exact same pinned versions (`requirements.txt` is generated from `uv.lock` and is pip-tested on Python 3.11).
63+
64+
**Option A: `uv`** (recommended if you have it)
5665
```bash
57-
# Install uv if you haven't already
5866
pip install uv
59-
60-
# Install the project
6167
uv sync
68+
source .venv/bin/activate
69+
```
6270

63-
# Activate the virtual environment
71+
**Option B: `pip`**
72+
```bash
73+
python3.11 -m venv .venv
6474
source .venv/bin/activate
75+
pip install --upgrade pip
76+
pip install -r requirements.txt
6577
```
6678

67-
## Running the Notebook
79+
Versions are pinned to a known-good combo (`deepagents==0.5.2`, `langgraph==1.1.6`, `langchain-core==1.2.28`) to avoid the `ToolRuntime.__init__() missing 'tools'` skew that newer `langgraph` releases trigger with `deepagents` 0.5.x.
80+
81+
## Running
82+
83+
### As a notebook
84+
85+
Open `notebooks/deepagents-travel-planner.ipynb` in JupyterLab, VS Code, or Cursor and select the workshop's `.venv` as the kernel.
6886

69-
Open `notebooks/deepagents-travel-planner.ipynb` in Jupyter, PyCharm, or VS Code, select the workshop's `.venv` as the kernel, and run cells in order.
87+
If your editor doesn't auto-detect the venv, register it as a named Jupyter kernel:
88+
89+
```bash
90+
.venv/bin/python -m ipykernel install --user --name=travel-planner --display-name="Travel Planner"
91+
```
92+
93+
Then pick **Travel Planner** from the kernel selector.
94+
95+
### As a LangGraph Studio agent
96+
97+
The agent in `agents/travel_planner/` is registered in `langgraph.json`. Launch it locally with:
98+
99+
```bash
100+
source .venv/bin/activate
101+
langgraph dev
102+
```
103+
104+
This starts an API server at `http://localhost:2024` and prints a LangGraph Studio URL. Studio gives you a visual graph view, message-level tracing, checkpoint history, and a chat panel.
70105

71106
## Model Configuration
72107

73-
Model selection is centralized in `utils/models.py`. The default is OpenAI; the file contains commented-out blocks for Azure OpenAI, AWS Bedrock, and Google Vertex AI — uncomment the section matching your provider and fill in the relevant env vars in `.env`.
108+
Model selection is centralized in `utils/models.py`. The default is OpenAI (`openai:gpt-5.4`); the file contains commented-out blocks for Azure OpenAI, AWS Bedrock, and Google Vertex AI — uncomment the section matching your provider and fill in the relevant env vars in `.env`.
109+
110+
The notebook's Part 10 evaluations call `init_chat_model()` directly to swap models for the comparison (`openai:gpt-5.4` vs `openai:gpt-4.1-mini`) and use `model` from `utils/models.py` for the LLM-as-judge. If your provider proxies OpenAI through APIM, point `OPENAI_BASE_URL` at the proxy so all three model names resolve through it.
74111

75112
### Azure OpenAI
76113
```
@@ -93,10 +130,33 @@ GOOGLE_APPLICATION_CREDENTIALS=./vertexCred.json
93130
```
94131
Make sure `vertexCred.json` is in `.gitignore`.
95132

133+
## Repo Layout
134+
135+
```
136+
travel-planner-deepagents-workshop/
137+
├── notebooks/
138+
│ └── deepagents-travel-planner.ipynb # the workshop notebook
139+
├── agents/
140+
│ └── travel_planner/ # standalone agent for `langgraph dev`
141+
│ ├── agent.py # mirrors the notebook's final composition
142+
│ ├── AGENTS.md # agent identity & workflow rules
143+
│ └── skills/ # on-demand output formats
144+
│ ├── itinerary-format/SKILL.md
145+
│ ├── budget-summary/SKILL.md
146+
│ ├── packing-list/SKILL.md
147+
│ └── travel-brief/SKILL.md
148+
├── utils/
149+
│ └── models.py # centralized model selection
150+
├── langgraph.json # registers the travel_planner agent
151+
├── pyproject.toml
152+
├── requirements.txt # pinned, pip-tested
153+
└── .env.example
154+
```
155+
96156
## Resources
97157

98158
- **[Deep Agents Documentation](https://docs.langchain.com/oss/python/deepagents/)** — harness reference, backends, middleware
99159
- **[LangChain Documentation](https://docs.langchain.com/oss/python/langchain/overview)**`create_agent`, tools, middleware
100160
- **[LangGraph Documentation](https://docs.langchain.com/oss/python/langgraph/overview)** — state, interrupts, `Store`, checkpointers
101161
- **[LangChain vs LangGraph vs Deep Agents](https://docs.langchain.com/oss/python/concepts/products)** — how the layers relate
102-
- **[LangSmith](https://smith.langchain.com)** — tracing and debugging the agent's tool calls and subagent fan-outs
162+
- **[LangSmith](https://smith.langchain.com)** — tracing, datasets, evaluations, the experiment comparison view used in Part 10

0 commit comments

Comments
 (0)