ValGuard + CrewAI: shared rules per agent LLM

Point each CrewAI agent LLM at ValGuard. Task guardrails in CrewAI stay in-process; the proxy shares packs across crews and other languages.

Last verified:

CrewAI agents call an LLM per role. Point each agent LLM at ValGuard so every crew member shares policy, shadow mode, and audit IDs — not only the in-process Task.guardrail callback.

When you need this

A researcher agent summarizes a document with invented revenue figures. The writer agent treats the summary as fact. ValGuard blocks numeric policy violations on the researcher completion before the writer task starts.

Setup

  1. Create one ValGuard agent slug per CrewAI role.
  2. Attach packs; start in shadow mode.
  3. Pass base_url, API key, and X-VG-Agent on each LLM(...).
  4. Re-verify CrewAI LLM kwargs against your installed version.

Code

from crewai import Agent, Task, Crew, LLM

vg_llm = LLM(
    model="openai/gpt-4o-mini",
    base_url="https://api.valguard.ai/v1",
    api_key="vg_live_...",
    default_headers={"X-VG-Agent": "research-crew"},
)

researcher = Agent(
    role="Research analyst",
    goal="Summarize only facts in the source document",
    backstory="No invented numbers.",
    llm=vg_llm,
)

Honest limits

  • Task.guardrail runs in-process and does not share packs with Node, n8n, or other services. Use the proxy when policy must be global.
  • There is no single crew-wide interceptor — each agent that needs validation needs its own LLM aimed at ValGuard.
  • Tool calls that never hit an LLM are not covered. See MCP security for tool gates.

Related

Next step

Quickstart then shadow mode rollout.