Skip to content

cookbook: sharpen Pattern-1 prompts in 08-llamaindex + 10-openai-agents#38

Closed
DK09876 wants to merge 2 commits into
mainfrom
cookbook/pattern1-prompt-polish-oa-llamaindex
Closed

cookbook: sharpen Pattern-1 prompts in 08-llamaindex + 10-openai-agents#38
DK09876 wants to merge 2 commits into
mainfrom
cookbook/pattern1-prompt-polish-oa-llamaindex

Conversation

@DK09876

@DK09876 DK09876 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Sharpens the Pattern-1 recall cells in notebooks 08-llamaindex-react-agent.ipynb and 10-openai-agents-memory.ipynb so gpt-4o-mini reliably invokes recall before answering. Same pattern the Claude SDK cookbook (d92ccab) and cookbook PRs #36 (LangGraph) + #31 (Haystack) just adopted.

Why

2026-06-02 V2 audit found cells 7 and 8/9 in both notebooks producing "I don't have any information…" responses even though the prior cell stored exactly the asked-about content. Pure LLM tool-choice variance, not an integration bug — the same notebooks' Pattern-2 cells (memory_instructions / HindsightMemory) work perfectly.

What changed

  • notebooks/08-llamaindex-react-agent.ipynb cells 7 + 9 prepend an explicit recall directive
  • notebooks/10-openai-agents-memory.ipynb cells 7 + 8 prepend an explicit recall directive

Integration code is unchanged.

Test plan

  • Re-execute both notebooks end-to-end and confirm the sharpened cells now correctly recall and reference stored memories

🤖 Generated with Claude Code

DK09876 and others added 2 commits May 27, 2026 13:43
…gent-safety)

Pairs with the hindsight-superagent integration (hindsight-core PR #1128).
22 cells demonstrating:
- SafeHindsight drop-in wrapper for the Hindsight client
- PII redact-on-write (default on)
- Guard blocking a blatant prompt injection
- retain_batch with safety pipeline per-item
- on_guard observability callback for verdict logging
- async-with lifecycle / aclose connection cleanup

Verified end-to-end against live Hindsight + Superagent + OpenAI on
Python 3.12.  All cells run cleanly with no errors; Guard correctly
identifies "IGNORE ALL PREVIOUS INSTRUCTIONS" as a prompt_injection /
system_prompt_extraction with the matched CWE code, and Redact strips
the seeded email address before storage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
V2 audit found gpt-4o-mini repeatedly answering 'I don't have any
information' on cells 7 and 8/9 of notebooks 08 and 10 — despite the
prior cell having stored exactly the asked-about info. Pure LLM
tool-choice variance, not an integration bug; the same notebooks'
Pattern-2 cells (memory_instructions auto-injection / HindsightMemory
adapter) work perfectly.

Same fix template the Claude SDK cookbook (commit d92ccab) and the
LangGraph + Haystack cookbook PRs (#36, #31) just adopted: prepend an
explicit recall directive so the model has to ground its answer in
memory. Two cells per notebook.

Integration code in #1866 (openai-agents) and #1867 (llamaindex) is
unchanged. This is a cookbook-prose polish PR; opening separately so
the integration PRs land independently.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@DK09876

DK09876 commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing per vectorize-io/hindsight#866 (comment) (review-log 2026-06-02). Empirical retest of the four cookbook polish commits showed the Claude-SDK prompt-sharpening template does not transfer to gpt-4o-mini-driven notebooks. LangGraph regressed (empty-query recall error); Haystack, LlamaIndex, and OpenAI Agents notebooks produced the same "I don't have any information" responses as before. Reverting the polish commits.

The Pattern-1 cells remain a known LLM tool-call variance with gpt-4o-mini, not an integration bug. Pattern-2 cells (memory_instructions / HindsightMemory adapter / hooks) in the same notebooks work perfectly. Real fix is choosing Pattern-2 by default in cookbook prose, which is a separate scope.

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