Skip to content

Add Superagent safety middleware notebook#37

Open
DK09876 wants to merge 1 commit into
mainfrom
dk/superagent-cookbook
Open

Add Superagent safety middleware notebook#37
DK09876 wants to merge 1 commit into
mainfrom
dk/superagent-cookbook

Conversation

@DK09876

@DK09876 DK09876 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds notebooks/11-superagent-safety.ipynb demonstrating the new hindsight-superagent integration's SafeHindsight wrapper (Guard prompt-injection detection + Redact PII removal around every memory op).
  • Pairs with hindsight-core PR #1128 (hindsight-superagent integration).
  • 22 cells covering: drop-in safe wrapper, PII redaction on retain, Guard blocking a blatant prompt injection, retain_batch, on_guard observability callback, async-context-manager lifecycle / aclose.
  • README updated with an entry under Core Tutorials.

Test plan

  • Notebook executes end-to-end on Python 3.12 with live Hindsight + Superagent + OpenAI: 22/22 cells, 0 errors.
  • on_guard callback captures expected verdicts (retain → pass, recall → pass, retain → blocked for the injection cell).
  • Cleanup cell confirms bank deletion succeeded.
  • (Reviewer) verify notebook against your own HINDSIGHT_API_URL / SUPERAGENT_API_KEY / OPENAI_API_KEY.

🤖 Generated with Claude Code

…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>
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