Skip to content

Commit 7dab9c1

Browse files
miyannisharNishar
authored andcommitted
feat(crewai): add native GovernanceHooks using CrewAI execution hooks (microsoft#1588)
Replace fragile proxy-based monkey-patching with CrewAI's native execution hooks (@before_tool_call, @after_tool_call, @before_llm_call, @after_llm_call) introduced in CrewAI 0.80+. Changes: - Add GovernanceHooks class that registers four global governance hooks for tool allowlist, blocked-pattern scanning, Cedar/OPA pre_execute gates, and output content filtering - Add CrewAIKernel.as_hooks() factory method as the recommended integration path - Deprecate CrewAIKernel.wrap() with DeprecationWarning pointing to as_hooks() - Export CrewAIGovernanceHooks from integrations package - Add 43 new tests covering all four hook types, deprecation warnings, Cedar evaluator integration, and backward compatibility - All 12 existing CrewAI regression tests pass unchanged Resolves microsoft#1576 Co-authored-by: Nishar <you@example.com>
1 parent f4d7b68 commit 7dab9c1

3 files changed

Lines changed: 1153 additions & 28 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
from agent_os.integrations.anthropic_adapter import AnthropicKernel, GovernedAnthropicClient
6363
from agent_os.integrations.autogen_adapter import AutoGenKernel
6464
from agent_os.integrations.crewai_adapter import CrewAIKernel
65+
try:
66+
from agent_os.integrations.crewai_adapter import GovernanceHooks as CrewAIGovernanceHooks
67+
except ImportError:
68+
pass
6569
from agent_os.integrations.gemini_adapter import GeminiKernel, GovernedGeminiModel
6670
from agent_os.integrations.google_adk_adapter import (
6771
ADKExecutionContext,

0 commit comments

Comments
 (0)