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
- Create one ValGuard agent slug per CrewAI role.
- Attach packs; start in shadow mode.
- Pass
base_url, API key, andX-VG-Agenton eachLLM(...). - Re-verify CrewAI
LLMkwargs 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.guardrailruns 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
LLMaimed at ValGuard. - Tool calls that never hit an LLM are not covered. See MCP security for tool gates.