feat(03-integration): alice.io WonderFence guardrails#223
feat(03-integration): alice.io WonderFence guardrails#223manoj-selvakumar5 merged 5 commits intostrands-agents:mainfrom
Conversation
Adds third-party guardrails example integrating Alice WonderFence with Strands agents for real-time AI safety protection. The integration uses Strands hooks to evaluate prompts, responses, tool inputs, and tool outputs. Features: - Hook-based implementation (BeforeModelCall, AfterModelCall, BeforeTool, AfterTool) - Support for BLOCK, MASK, and ALLOW actions - Multimodal and multilingual detection (20+ languages) - Example demonstrations of prompt injection, hate speech, and PII detection - Customizable policies via WonderFence UI Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Latest scan for commit: ✅ Security Scan Report (PR Files Only)Scanned Files
Security Scan Results
Threshold: High No security issues detected in your changes. Great job! This scan only covers files changed in this PR. |
|
Hi @lior-k - Thank you for the PR. the hook architecture is great, especially covering all 4 lifecycle hooks and supporting MASK actions. I tested the sample end-to-end and left a few comments on the PR. The main blocker is the argument order in the SDK calls (context should come before content). The other two are smaller fixes. Please let me know if you have questions! |
- Swap (content, context) to (context, content) for evaluate_prompt_sync and evaluate_response_sync calls to match SDK signature - Move Agent creation inside the test loop to avoid broken alternating user/assistant message pattern after WonderFenceViolationException Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The SDK's evaluate_prompt_sync and evaluate_response_sync take (content, context), not (context, content). The original call order was correct. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
hi @manoj-selvakumar5. thanks for the review 🙏 The parameters order is actually correct, as confirmed on the PyPI library page: https://pypi.org/project/wonderfence-sdk/ however we added keyword arguments to function calls to make it clearer.
|
|
Thanks for the headsup @manoj-selvakumar5 🙌 |
Summary
This PR adds a new third-party guardrails integration example demonstrating how to use Alice WonderFence with Strands agents for real-time AI safety protection.
What's New
on_before_model_call: Evaluates user prompts before reaching the modelon_after_model_call: Evaluates model responses before returning to userson_before_tool_call: Evaluates tool input parameters for safetyon_after_tool_call: Evaluates tool execution resultsFeatures
Example Test Cases
The integration includes demonstrations of:
Files Added
03-integrations/third-party-guardrails/04-alice-wonderfence/README.md- Documentation and setup instructions03-integrations/third-party-guardrails/04-alice-wonderfence/guardrail.py- WonderFence hook implementation03-integrations/third-party-guardrails/04-alice-wonderfence/main.py- Demo application with test cases03-integrations/third-party-guardrails/04-alice-wonderfence/requirements.txt- Python dependencies