crewai - 💡(How to fix) Fix Proposal: Governance Guardrails Plugin for CrewAI [10 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4502Fetched 2026-04-08 00:41:44
View on GitHub
Comments
10
Participants
4
Timeline
24
Reactions
0
Timeline (top)
commented ×10mentioned ×5subscribed ×5cross-referenced ×2
RAW_BUFFERClick to expand / collapse

Proposal: Governance Guardrails Plugin for CrewAI

Problem

CrewAI excels at multi-agent orchestration with roles and tasks, but currently lacks a built-in governance/guardrails layer for enforcing safety policies on agent actions. As agent autonomy grows, organizations need:

  • Policy enforcement — Cap token usage, limit tool calls, block dangerous patterns (regex/glob-aware)
  • Event hookson(POLICY_VIOLATION, callback) for logging, alerting, circuit-breaking
  • Trust-gated delegation — Verify agent trust scores before allowing inter-agent handoffs
  • Audit trails — Tamper-evident logging with Merkle chain hashing

What we've built (Apache-2.0)

We've been developing AgentMesh and Agent-OS with production-grade governance features:

  1. GovernancePolicy — Declarative policy with YAML import/export, validation, diff/comparison
  2. PatternType enum — Blocked patterns with substring, regex, and glob matching (pre-compiled)
  3. GovernanceEventType hooksPOLICY_CHECK, POLICY_VIOLATION, TOOL_CALL_BLOCKED, CHECKPOINT_CREATED
  4. Semantic intent classifier — Classifies actions into 9 threat categories (destructive, exfiltration, privilege escalation, etc.)
  5. Trust scoring engine — 5-dimension trust scores with decay modeling
  6. Merkle audit chains — Tamper-evident, offline-verifiable execution logs

Proposed integration

We'd contribute a crewai-guardrails plugin (or PR to core) that wraps CrewAI's task execution with governance hooks:

`python from crewai import Crew, Agent, Task from crewai_guardrails import GovernancePolicy, GuardedCrew

policy = GovernancePolicy.load("policy.yaml") crew = GuardedCrew( agents=[researcher, writer], tasks=[research_task, write_task], policy=policy, # Enforced on every agent action ) crew.on("policy_violation", lambda e: alert(e)) result = crew.kickoff() `

Why this matters for CrewAI

  • Enterprises adopting CrewAI need governance before production deployment
  • No existing CrewAI extension provides this
  • Our code is Apache-2.0, battle-tested (700+ tests), and framework-agnostic
  • Aligns with CSA's Agentic Trust Framework direction

Ask

Is there interest in this kind of contribution? Happy to:

  1. Start with a minimal before_task_execute / after_task_execute hook PR
  2. Or build a standalone crewai-guardrails package that integrates via CrewAI's existing callback system

Would love feedback from maintainers on the preferred approach.

extent analysis

Fix Plan

To integrate the governance guardrails plugin into CrewAI, we can follow these steps:

  • Create a crewai-guardrails package with the necessary dependencies and import the GovernancePolicy and GuardedCrew classes.
  • Implement the before_task_execute and after_task_execute hooks to enforce the governance policy on every agent action.
  • Use the GovernanceEventType hooks to trigger callbacks for policy violations, tool call blocks, and checkpoint creations.

Example code:

from crewai import Crew, Agent, Task
from crewai_guardrails import GovernancePolicy, GuardedCrew

# Load the governance policy from a YAML file
policy = GovernancePolicy.load("policy.yaml")

# Create a GuardedCrew instance with the policy and agents
crew = GuardedCrew(
    agents=[researcher, writer],
    tasks=[research_task, write_task],
    policy=policy,
)

# Define a callback function for policy violations
def on_policy_violation(event):
    alert(event)

# Register the callback function with the crew
crew.on("policy_violation", on_policy_violation)

# Kick off the task execution
result = crew.kickoff()

Verification

To verify that the fix worked, we can:

  • Test the before_task_execute and after_task_execute hooks to ensure they are triggered correctly.
  • Validate that the governance policy is enforced on every agent action.
  • Check that the callback functions are triggered for policy violations, tool call blocks, and checkpoint creations.

Extra Tips

  • Ensure that the crewai-guardrails package is properly installed and imported in the CrewAI project.
  • Configure the governance policy to suit the specific needs of the organization.
  • Monitor the audit trails and logs to detect any potential security issues.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING