Update LangGraph notebook dependencies and env-driven setup#117
Update LangGraph notebook dependencies and env-driven setup#117dex-the-ai wants to merge 1 commit into
Conversation
|
Caution Notebooks or Frontmatter Files Have Been Modified
1 Notebook Files Modified:
0 Frontmatter Files Modified:
|
There was a problem hiding this comment.
Code Review
This pull request updates the Couchbase persistence notebook for LangGraph to support environment-based configuration and adds the langchain-openai dependency. Several critical issues were identified: the langgraph package version was pinned to a non-existent version (1.1.10), and the code was changed to use create_agent from langchain.agents instead of create_react_agent from langgraph.prebuilt. The latter change is problematic because standard LangChain agents do not support the checkpointer parameter required for the persistence features demonstrated in this notebook.
| "source": [ | ||
| "%%capture --no-stderr\n", | ||
| "%pip install -U langgraph==0.3.22 langgraph-checkpointer-couchbase " | ||
| "%pip install -U langgraph==1.1.10 langgraph-checkpointer-couchbase langchain-openai\n" |
There was a problem hiding this comment.
The version langgraph==1.1.10 appears to be incorrect. As of the current release cycle, LangGraph versions are in the 0.x range (e.g., 0.2.x or 0.3.x). Pinning to a non-existent version will cause the %pip install command to fail. Additionally, the PR description mentions keeping the pin, but the diff shows a change from 0.3.22 to 1.1.10.
| "%pip install -U langgraph==1.1.10 langgraph-checkpointer-couchbase langchain-openai\n" | |
| "%pip install -U langgraph langgraph-checkpointer-couchbase langchain-openai\n" |
| "from langchain_core.tools import tool\n", | ||
| "from langchain_openai import ChatOpenAI\n", | ||
| "from langgraph.prebuilt import create_react_agent\n", | ||
| "from langchain.agents import create_agent\n", |
There was a problem hiding this comment.
The import create_agent from langchain.agents is likely incorrect for a LangGraph tutorial. LangGraph uses create_react_agent from langgraph.prebuilt to create compiled graphs that support persistence via checkpointers. langchain.agents does not provide a create_agent function that accepts a checkpointer argument, and using the legacy agent stack would break the persistence logic demonstrated in this notebook.
| "from langchain.agents import create_agent\n", | |
| "from langgraph.prebuilt import create_react_agent\n", |
| " scope_name=CB_SCOPE_NAME,\n", | ||
| ") as checkpointer:\n", | ||
| " graph = create_react_agent(model, tools=tools, checkpointer=checkpointer)\n", | ||
| " graph = create_agent(model, tools=tools, checkpointer=checkpointer)\n", |
There was a problem hiding this comment.
Using create_agent here is likely incorrect. Since this notebook demonstrates LangGraph persistence, you should use create_react_agent to ensure the resulting object is a LangGraph CompiledGraph that correctly utilizes the provided checkpointer. Standard LangChain agent factory functions do not support the checkpointer parameter.
| " graph = create_agent(model, tools=tools, checkpointer=checkpointer)\n", | |
| " graph = create_react_agent(model, tools=tools, checkpointer=checkpointer)\n", |
| " scope_name=CB_SCOPE_NAME,\n", | ||
| ") as checkpointer:\n", | ||
| " graph = create_react_agent(model, tools=tools, checkpointer=checkpointer)\n", | ||
| " graph = create_agent(model, tools=tools, checkpointer=checkpointer)\n", |
There was a problem hiding this comment.
As noted in the synchronous example, create_react_agent should be used instead of create_agent to maintain compatibility with LangGraph's checkpointer logic and ensure the graph is properly compiled for persistence.
| " graph = create_agent(model, tools=tools, checkpointer=checkpointer)\n", | |
| " graph = create_react_agent(model, tools=tools, checkpointer=checkpointer)\n", |
Summary
langgraph/couchbase_persistence_langgraph.ipynbdependencies from currentmainand keep the explicitlanggraph==1.1.10pin.langchain-openai, switch the sample agent construction tocreate_agent, and move the notebook to env-driven local Couchbase/OpenAI configuration.Verification
uv venv -p 3.12 --seed --clear .venv-fresh-pr-20260429uv pip install papermill ipykernel pip-auditpapermill -k vsc-langgraph-fresh-20260429 langgraph/couchbase_persistence_langgraph.ipynb ...✅pip-audit✅ (No known vulnerabilities found)Evidence
mainexecuted the notebook end-to-end with papermill on a clean Python 3.12 environment.CB_*/OPENAI_API_KEYenvironment variables instead of hard-coded local values.Rendered notebook screenshot
Papermill / audit summary
vsc-langgraph-fresh-20260429pip-auditreportedNo known vulnerabilities foundOPENAI_API_KEYwas not exported into the kernel environment; rerunning with exported env fixed ittutorial-maintenance/runs/couchbase-examples__vector-search-cookbook/2026-04-29-langgraph-fresh-from-main/verification.mdtutorial-maintenance/runs/couchbase-examples__vector-search-cookbook/2026-04-29-langgraph-fresh-from-main/papermill.logtutorial-maintenance/runs/couchbase-examples__vector-search-cookbook/2026-04-29-langgraph-fresh-from-main/dependency-freeze.txttutorial-maintenance/runs/couchbase-examples__vector-search-cookbook/2026-04-29-langgraph-fresh-from-main/screenshots/langgraph-executed-notebook.pngNotes
langgraph/couchbase_persistence_langgraph.ipynbrather than bundling broader cookbook changes.