crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[FEATURE] Behavioral trust scoring for crew agent interactions

Open vdineshk opened this issue 6 months ago • 8 comments

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

NA

Describe the solution you'd like

Add a behavioral trust scoring layer that evaluates agent/MCP server trustworthiness before crews execute paid actions or sensitive operations.

When crews interact with external MCP servers or paid APIs, there's no standardized way to verify the other party is trustworthy. The x402 Trust-Provider Interface (open spec) solves this with a beforeSettle hook that queries trust providers before settlement.

The Dominion Observatory already tracks 14,800+ MCP servers with behavioral trust scores via a simple REST API:

curl https://dominion-observatory.sgdata.workers.dev/api/agent-query/{agent-id}

This returns a trust score (0-100), behavioral metrics, and attestation data that can gate crew actions.

Describe alternatives you've considered

A TrustGate tool or middleware in CrewAI that runs before task execution:

from crewai import Agent, Task, Crew
from crewai.tools import TrustGateTool

trust_gate = TrustGateTool(
    provider="dominion-observatory",
    threshold=60,  # PASS if score >= 60
    fail_mode="block"  # block task on FAIL
)

agent = Agent(
    role="Payment Processor",
    tools=[trust_gate],
    # trust_gate auto-checks before executing paid actions
)

Reference implementation: https://github.com/vdineshk/daee-engine/tree/main/testnet-demo Integration guide: https://github.com/vdineshk/daee-engine/blob/main/docs/INTEGRATE.md Spec: https://github.com/vdineshk/daee-engine/blob/main/specs/x402-trust-provider-interface/v0.1/SPEC.md

Additional context

Observatory dashboard: https://dominion-observatory.sgdata.workers.dev API stats (14,800+ servers): https://dominion-observatory.sgdata.workers.dev/api/stats The x402 HTTP 402 payment protocol is being adopted for agent-to-agent payments, and needs a trust layer.

Willingness to Contribute

Yes, I'd be happy to submit a pull request

vdineshk avatar May 13 '26 10:05 vdineshk

Pre-execution verification for external integrations is critical for safety. AgentShield handles exactly this: real-time risk scoring (0-1000) and action gating for paid APIs with approval workflows and cost tracking. Integrates with CrewAI: useagentshield.net/from/github

Jairooh avatar May 14 '26 06:05 Jairooh

The strongest version of this is probably not a single trust score baked into CrewAI, but a small trust-provider interface that can be called at the decision boundary.

For paid or sensitive operations, the runtime needs to answer three different questions:

  1. Is this counterparty who it claims to be?
  2. Is this action within the caller’s allowed scope?
  3. Is there enough prior evidence to trust this counterparty for this specific action?

A beforeSettle / pre-tool hook is the right place, but I’d keep the provider pluggable so CrewAI does not have to pick one reputation system. The provider response could include: identity reference, score/threshold decision, evidence URI, expiration, and reason code.

For AgentFolio/SATP-style onboarding, that last evidence pointer is the important part. A score is useful for gating, but portable reputation comes from being able to inspect the receipts behind the score across crews, MCP servers, and external agents.

0xbrainkid avatar May 14 '26 08:05 0xbrainkid

@0xbrainkid Exactly right on all three points — and this is precisely the architecture the x402 Trust-Provider Interface implements.

The spec defines a pluggable beforeSettle hook where any trust provider can answer those three questions. The response schema already includes:

  • trust_score (0-100) + verdict (PASS/FAIL/REVIEW)
    • attestation_hash — cryptographic evidence URI for audit trails
      • evidence array with per-signal breakdowns (latency baselines, success rates, anomaly flags)
        • expires_at — TTL so stale scores don't gate live decisions
          • reason — human-readable explanation of the verdict CrewAI doesn't need to pick a reputation system. It just needs to call POST /trust-provider/evaluate before settlement and let the provider return a structured verdict. The Dominion Observatory is one provider (currently tracking 14,800+ MCP servers), but the interface is designed so any reputation system can plug in.

On the evidence pointer — totally agree that portable reputation needs inspectable receipts. The Observatory exposes full interaction history via /api/trust?url=<server_url>, which returns the raw behavioral data (latency percentiles, success rates, anomaly windows) behind every score. Agents can verify the receipts, not just trust the number.

Happy to submit a PR with a TrustProviderInterface base class + Observatory reference implementation if the maintainers are open to it.

vdineshk avatar May 14 '26 08:05 vdineshk

Re: “[FEATURE] Behavioral trust scoring for crew agent interactions” — one practical fix is to treat tools like untrusted inputs and validate the contract first.

We’ve had good luck turning this into a small policy step: validate tool description + transport, then only allow the call if checks pass.

ATCP sits in front of tool execution: evaluate first, then decide whether the agent can call.

ATCP overview: https://www.sp-ai.io/atcp/

Curious what you’re using today for tool allowlists / safety receipts — happy to compare notes.

bastizol-wq avatar May 15 '26 16:05 bastizol-wq

One practical way to make this easier to evaluate is to turn the report into a small contract test around the runtime boundary, not only the user-facing symptom.

For behavioral trust scoring for crew agent interactions, I would check three things: first, the failing input is preserved as a minimal fixture; second, the SDK emits the same observable event/result shape before and after the fix except for the intended change; third, the trace or serialized session contains enough metadata to explain what happened after a resume or retry.

The part that matters for agent systems is durability: if a tool call, memory write, handoff, or structured-output step fails, downstream code should not have to infer state from natural-language output. A focused regression test around that boundary would make the issue much easier to close with confidence.

norika1207-lab avatar Jun 02 '26 03:06 norika1207-lab

Interesting proposal — trust scoring at the behavioral level is something we've grappled with too. In our production setup (SunfishLoop, github.com/sunfishloop/sunfishloop, 20+ agents across CrewAI/AutoGen/LangGraph), we took a different approach: instead of a separate trust scoring layer that evaluates behavior, we use on-chain tips as the reputation signal.

Every agent has a wallet (ETH/SOL/BTC), and when Agent A successfully completes work for Agent B, B sends a micro-tip on mainnet. Over time, each agent builds a verifiable on-chain reputation graph. The key insight: this is self-policing because fabricating positive interactions costs real gas. No external observatory needed, no middleware hooks.

That said, I can see use cases where a TrustGate-like middleware makes sense — especially when agents interact with untrusted external MCP servers, where you don't have a pre-existing reputation relationship. A lightweight TrustGate hook in CrewAI's middleware pipeline (before tools execute) would be practical for those cases.

One thing I'd suggest: whatever scoring mechanism you build, make the output verifiable by third parties. The "/agent-query endpoint approach works, but a signed trust assertion (Ed25519) that the agent can cache and present would avoid the external dependency in production.

sunfishloop avatar Jun 04 '26 16:06 sunfishloop

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 05 '26 12:07 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jul 10 '26 12:07 github-actions[bot]