Skip to content

feat: add Claude Agent SDK + Hindsight memory notebook#35

Open
DK09876 wants to merge 2 commits into
mainfrom
cookbook/claude-agent-sdk
Open

feat: add Claude Agent SDK + Hindsight memory notebook#35
DK09876 wants to merge 2 commits into
mainfrom
cookbook/claude-agent-sdk

Conversation

@DK09876

@DK09876 DK09876 commented May 11, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds notebooks/claude-agent-sdk.ipynb demonstrating Claude Agent SDK with Hindsight persistent memory
  • Covers explicit memory tools (retain, recall, reflect) and automatic hooks (auto-recall, auto-retain)
  • Shows knowledge compounding across sessions
  • Companion to the hindsight-claude-agent-sdk package in vectorize-io/hindsight

Test plan

  • Full notebook run verified end-to-end with live API
  • No hardcoded secrets — uses getpass for API key
  • All cell outputs cleared

🤖 Generated with Claude Code

DK09876 and others added 2 commits May 11, 2026 14:24
Interactive notebook demonstrating:
- Explicit memory tools (retain, recall, reflect) via MCP server
- Automatic memory hooks (auto-recall, auto-retain)
- Knowledge compounding across sessions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ace all stored facts

Audit finding (2026-06-02): cell 7 (Reflect) surfaced only Python/async out
of 4 stored facts (Python+async, pytest, FastAPI, conventional-commits),
and cell 9 (auto-recall hook) failed to surface conventional-commits
despite the cell's markdown explicitly claiming it would. Not a Pattern-1
LLM-tool-choice issue (Claude doesn't typically have that quirk on
explicit recall instructions) — both come down to recall/reflect query
specificity:

- Cell 7's "synthesize everything you know about my development stack
  and preferences" is broad enough that the server's reflect synthesis
  ranked Python/async highest and dropped the others. Sharpening the
  prompt to name the four categories explicitly forces reflect to cover
  each one (or say so when a category has none) — much more reliable.

- Cell 9's "What commit message format should I use for this test file
  I just created?" is dominated semantically by "test file"; the
  auto-recall hook uses the raw user prompt as its query, so the
  test-related memories outrank the conventional-commits one. Prepending
  "Recall what you know about my commit conventions, then answer:"
  steers the recall query toward the right memory while still asking
  the same underlying question.

Both edits live entirely in the notebook prompts — the integration code
(create_memory_hooks, hindsight_reflect) is correct and unchanged. The
recall_max_results=5 default is plenty; the issue is query semantics.

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