Skip to content

Commit 3bbc7e9

Browse files
miyannisharNishar
authored andcommitted
feat(autogen): add native GovernanceInterventionHandler via AutoGen v0.4+ hooks (microsoft#1591)
Replace fragile monkey-patching with AutoGen's native intervention handler system (DefaultInterventionHandler with on_send, on_publish, on_response) introduced in AutoGen v0.4+. Changes: - Add GovernanceInterventionHandler class with three hooks: - on_send: tool call governance, content filtering, PII detection - on_publish: broadcast message governance - on_response: output content filtering, drift detection - Add AutoGenKernel.as_handler() factory method as the recommended integration path - Deprecate govern() and wrap() with DeprecationWarning pointing to as_handler() - Export AutoGenGovernanceHandler from integrations package - Add 51 new tests covering all three hook types, Cedar/OPA integration, deprecation warnings, PII detection, and backward compatibility - All 18 existing AutoGen regression tests pass unchanged Co-authored-by: Nishar <you@example.com>
1 parent 7dab9c1 commit 3bbc7e9

3 files changed

Lines changed: 1118 additions & 18 deletions

File tree

agent-governance-python/agent-os/src/agent_os/integrations/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
)
6161
from agent_os.integrations.a2a_adapter import A2AEvaluation, A2AGovernanceAdapter, A2APolicy
6262
from agent_os.integrations.anthropic_adapter import AnthropicKernel, GovernedAnthropicClient
63-
from agent_os.integrations.autogen_adapter import AutoGenKernel
63+
from agent_os.integrations.autogen_adapter import (
64+
AutoGenKernel,
65+
GovernanceInterventionHandler as AutoGenGovernanceHandler,
66+
)
6467
from agent_os.integrations.crewai_adapter import CrewAIKernel
6568
try:
6669
from agent_os.integrations.crewai_adapter import GovernanceHooks as CrewAIGovernanceHooks
@@ -173,6 +176,7 @@
173176
"CrewAIKernel",
174177
# AutoGen
175178
"AutoGenKernel",
179+
"AutoGenGovernanceHandler",
176180
# OpenAI Assistants
177181
"OpenAIKernel",
178182
"GovernedAssistant",

0 commit comments

Comments
 (0)