Skip to content

cookbook(langgraph): use gpt-4.1-mini + sharpen Pattern-1 prompts#41

Open
DK09876 wants to merge 1 commit into
mainfrom
cookbook/langgraph-model-prompt-polish
Open

cookbook(langgraph): use gpt-4.1-mini + sharpen Pattern-1 prompts#41
DK09876 wants to merge 1 commit into
mainfrom
cookbook/langgraph-model-prompt-polish

Conversation

@DK09876

@DK09876 DK09876 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related changes to notebooks/06-langgraph-react-agent.ipynb to 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-mini tool-use variance under the V1/V2 audit's cookbook checks.

What & why

1. Model upgrade: gpt-4o-minigpt-4.1-mini (cells 3 and 9)

Under gpt-4o-mini, cell 7's cross-session recall returned:

"It looks like I don't have any information stored about your IDE or your job. Could you let me know what you use and what your job is?"

Even though cell 5 had been intended to store Alice's facts via hindsight_retain. With gpt-4.1-mini the agent reliably calls the tool both ways. Cell 7 now returns:

"You use the IDE Visual Studio Code (VS Code), and your job is a data scientist working with Python and SQL."

2. Pattern-1 prompt sharpening (cells 7 and 8)

Same template the Claude SDK cookbook adopted (commit d92ccab373 on main): nudge the agent to call recall_memory explicitly before answering, instead of leaving the tool-use decision to the model.

  • Cell 7: "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?"
  • Cell 8: same template ("Use the recall tool to refresh what you know about me first, then recommend...").

Cell 8 now returns memory-grounded recommendations:

"Alice, based on what I know about you as a data scientist who specializes in Python and SQL and prefers dark mode in VS Code, here is a recommended setup..."

Relationship to other PRs

Test plan

  • Cookbook 16/16 cells execute against canonical PR #1673 build, 0 errors.
  • Cell 7 (Pattern 1 cross-session) reliably surfaces Alice's facts (VS Code / data scientist / Python+SQL).
  • Cell 8 (recommendations) grounds recommendations in recalled context.
  • Pattern 2 (Graph nodes, cells 11+13) unchanged behavior.
  • Reviewer to verify end-to-end against the merged hindsight-langgraph.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant