feat(adapters): add native hooks for Anthropic, SK, smolagents, PydanticAI#1605
Merged
imran-siddique merged 1 commit intomainfrom Apr 30, 2026
Merged
feat(adapters): add native hooks for Anthropic, SK, smolagents, PydanticAI#1605imran-siddique merged 1 commit intomainfrom
imran-siddique merged 1 commit intomainfrom
Conversation
…ticAI
Complete the native-hooks migration for all four remaining adapters:
Anthropic:
- Add GovernanceMessageHook + as_message_hook() factory
- Pre-execution: content scanning, tool allowlist, token limits
- Post-execution: tool_use validation, token tracking, audit
- Deprecate wrap() and wrap_client() with migration guidance
Semantic Kernel:
- Add GovernanceFunctionFilter + as_filter() factory
- Uses SK's native add_filter('auto_function_invocation', ...) system
- Validates function names, blocked patterns, call counts
- Deprecate wrap() and wrap_kernel() with migration guidance
Smolagents:
- Add GovernanceStepCallback + as_step_callback() factory
- Implements step_callbacks protocol: __call__(step, agent)
- Validates tool names, blocked patterns, observations
- Deprecate wrap() with migration guidance
PydanticAI:
- Add GovernanceCapability + as_capability() factory
- Lifecycle hooks: before/after_run, before/after_tool_execute
- Pre-execution policy gating, post-execution drift detection
- Deprecate wrap() with migration guidance
Package exports:
- Export AnthropicGovernanceHook, SKGovernanceFilter,
SmolagentsGovernanceCallback, PydanticAIGovernanceCapability
from integrations __init__.py
Tests:
- test_anthropic_hooks.py: 12 tests
- test_semantic_kernel_hooks.py: 10 tests
- test_smolagents_hooks.py: 14 tests
- test_pydantic_ai_hooks.py: 16 tests
Part of: #1571
🤖 AI Agent: security-scanner — View detailsNo security issues found. |
🤖 AI Agent: docs-sync-checker — Docs SyncDocs Sync
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
🤖 AI Agent: code-reviewer — Action Items:TL;DR: 0 blockers, 2 warnings. Solid implementation with minor follow-ups.
Action Items:
Warnings:
|
🤖 AI Agent: breaking-change-detector — API CompatibilityAPI Compatibility
|
🤖 AI Agent: test-generator — `anthropic_adapter.py`
|
PR Review Summary
Verdict: ❌ Changes needed |
imran-siddique
added a commit
to imran-siddique/agent-governance-toolkit
that referenced
this pull request
May 4, 2026
…ticAI (microsoft#1605) Complete the native-hooks migration for all four remaining adapters: Anthropic: - Add GovernanceMessageHook + as_message_hook() factory - Pre-execution: content scanning, tool allowlist, token limits - Post-execution: tool_use validation, token tracking, audit - Deprecate wrap() and wrap_client() with migration guidance Semantic Kernel: - Add GovernanceFunctionFilter + as_filter() factory - Uses SK's native add_filter('auto_function_invocation', ...) system - Validates function names, blocked patterns, call counts - Deprecate wrap() and wrap_kernel() with migration guidance Smolagents: - Add GovernanceStepCallback + as_step_callback() factory - Implements step_callbacks protocol: __call__(step, agent) - Validates tool names, blocked patterns, observations - Deprecate wrap() with migration guidance PydanticAI: - Add GovernanceCapability + as_capability() factory - Lifecycle hooks: before/after_run, before/after_tool_execute - Pre-execution policy gating, post-execution drift detection - Deprecate wrap() with migration guidance Package exports: - Export AnthropicGovernanceHook, SKGovernanceFilter, SmolagentsGovernanceCallback, PydanticAIGovernanceCapability from integrations __init__.py Tests: - test_anthropic_hooks.py: 12 tests - test_semantic_kernel_hooks.py: 10 tests - test_smolagents_hooks.py: 14 tests - test_pydantic_ai_hooks.py: 16 tests Part of: microsoft#1571 Co-authored-by: Nishar <you@example.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased version of #1593 (by @miyannishar) with merge conflicts resolved against recently merged native-hooks PRs (#1582, #1585, #1588, #1591).
Adds native hook implementations for the remaining four adapters:
Includes 52 new tests across 4 test files.
Part of: #1571
Original PR: #1593 (closed due to merge conflicts)