cookbook(langgraph): use gpt-4.1-mini + sharpen Pattern-1 prompts#41
Open
DK09876 wants to merge 1 commit into
Open
cookbook(langgraph): use gpt-4.1-mini + sharpen Pattern-1 prompts#41DK09876 wants to merge 1 commit into
DK09876 wants to merge 1 commit into
Conversation
Two related changes to make 06-langgraph-react-agent.ipynb's memory demos
work reliably end-to-end:
1. Model: gpt-4o-mini → gpt-4.1-mini in cells 3 (chat helper),
9 (Pattern 2 graph), and 15 (Pattern 3 memory_instructions). Pattern 3
was returning "I don't have that specific information" under
gpt-4o-mini even though memory_instructions had successfully recalled
"Alice prefers dark mode and uses VS Code" into the system prompt —
the model was simply not grounding its answer on the injected
context. Under gpt-4.1-mini, cell 15 now returns:
"You use Python and SQL as your programming languages, and you
prefer to work in the VS Code IDE with dark mode enabled."
2. Pattern-1 prompts (cells 7 and 8): nudge the agent to call
recall_memory explicitly before answering, instead of leaving the
tool-use decision to the model. Same template the Claude SDK
cookbook adopted (d92ccab on main). Under gpt-4o-mini cell 7
returned "I don't have any information stored about your IDE or your
job"; with the bumped model + sharpened prompt it now returns:
"You use the IDE Visual Studio Code (VS Code), and your job is a
data scientist working with Python and SQL."
Cell 8's grounded-recommendations question now also surfaces the
recalled context ("Alice, based on what I know about you as a data
scientist who specializes in Python and SQL...").
Integration code in vectorize-io/hindsight#1673 is unchanged; only the
cookbook is touched here. Pattern 2 (Graph-node retain/recall) was
already working under gpt-4o-mini and is preserved as-is.
Pattern matches the OpenAI Agents cookbook fix in PR #40 — both use the
same model+prompt template since both notebooks show the same
gpt-4o-mini tool-use variance.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related changes to
notebooks/06-langgraph-react-agent.ipynbto make the memory demos work reliably end-to-end. Pairs with vectorize-io/hindsight#1673.Same template as the OpenAI Agents polish PR #40 — both notebooks were showing the same
gpt-4o-minitool-use variance under the V1/V2 audit's cookbook checks.What & why
1. Model upgrade:
gpt-4o-mini→gpt-4.1-mini(cells 3 and 9)Under
gpt-4o-mini, cell 7's cross-session recall returned:Even though cell 5 had been intended to store Alice's facts via
hindsight_retain. Withgpt-4.1-minithe agent reliably calls the tool both ways. Cell 7 now returns:2. Pattern-1 prompt sharpening (cells 7 and 8)
Same template the Claude SDK cookbook adopted (commit
d92ccab373on main): nudge the agent to callrecall_memoryexplicitly before answering, instead of leaving the tool-use decision to the model."What IDE do I use? And what's my job?"→"Recall what you know about me first, then answer: what IDE do I use and what's my job?""Use the recall tool to refresh what you know about me first, then recommend...").Cell 8 now returns memory-grounded recommendations:
Relationship to other PRs
gpt-4o-minivariance issue.dk/langgraph-basestore-cookbook) adds a Pattern 3 /memory_instructionscell that also benefits from the gpt-4.1-mini bump. Once LangGraph notebook: replace BaseStore with memory_instructions #36 lands, that cell can be polished in a follow-up.Test plan
🤖 Generated with Claude Code