DEV Community

The Nexus Guard
The Nexus Guard

Posted on

Give Your LangChain and CrewAI Agents a Real Identity

The Problem: Anonymous Agents Everywhere

You've built a multi-agent system. Maybe a CrewAI crew with a researcher, writer, and reviewer. Or a LangChain pipeline where agents delegate tasks to each other.

Here's the question nobody asks: how do your agents know who they're talking to?

Right now, they don't. Every agent is anonymous. There's no way for Agent A to verify that Agent B is who it claims to be. No way to build trust over time. No audit trail of which agent produced which output.

This is fine for toy projects. It's not fine for production.

AIP: Identity Infrastructure for Agents

AIP (Agent Identity Protocol) gives every agent a cryptographic identity — a DID (Decentralized Identifier) backed by Ed25519 keys. Agents can:

  • Register an identity tied to their platform/username
  • Verify other agents through challenge-response
  • Sign outputs to prove authorship
  • Vouch for other agents, building a trust graph
  • Send encrypted messages to other agents

And now, it integrates directly with LangChain and CrewAI.

Quick Setup

pip install aip-identity langchain-core
Enter fullscreen mode Exit fullscreen mode

Register your agent (one-time):

from aip_identity import AIPClient

client = AIPClient.register("langchain", "my-research-agent")
print(f"Agent DID: {client.did}")
# Credentials saved to ~/.aip/credentials.json
Enter fullscreen mode Exit fullscreen mode

Using AIP Tools in LangChain

AIP ships with 9 LangChain-compatible tools out of the box:

from aip_identity.integrations.langchain_tools import get_aip_tools
from langchain_anthropic import ChatAnthropic
from langgraph.prebuilt import create_react_agent

# Get all AIP tools
tools = get_aip_tools()

# Create an agent with identity capabilities
model = ChatAnthropic(model="claude-sonnet-4-5-20250929")
agent = create_react_agent(model, tools)

# The agent can now verify other agents, sign messages, etc.
result = agent.invoke({
    "messages": [{
        "role": "user",
        "content": "Who am I? Check my AIP identity."
    }]
})
Enter fullscreen mode Exit fullscreen mode

The tools include:

Tool What it does
aip_whoami Get your DID and public key
aip_lookup_agent Look up another agent by DID
aip_verify_agent Cryptographic challenge-response verification
aip_get_trust Check trust scores and vouches
aip_is_trusted Quick trust check
aip_sign_message Sign a message to prove authorship
aip_vouch_for_agent Vouch for another agent's trustworthiness
aip_get_profile Get an agent's public profile
aip_get_trust_path Find transitive trust paths

Using AIP Tools in CrewAI

CrewAI accepts LangChain tools directly, so the same integration works:

from crewai import Agent, Task, Crew
from aip_identity.integrations.langchain_tools import get_aip_tools

# Create agents with identity tools
researcher = Agent(
    role="Research Analyst",
    goal="Find and verify information from trusted sources",
    tools=get_aip_tools(),
    verbose=True
)

reviewer = Agent(
    role="Peer Reviewer",
    goal="Verify the researcher's identity and review their work",
    tools=get_aip_tools(),
    verbose=True
)

# The reviewer can verify the researcher before trusting their output
verify_task = Task(
    description="Verify the research agent's identity using AIP, then review their findings.",
    agent=reviewer
)

crew = Crew(agents=[researcher, reviewer], tasks=[verify_task])
Enter fullscreen mode Exit fullscreen mode

Why This Matters: Three Scenarios

1. Signed Outputs for Audit Trails

When an agent produces a report, it can sign it:

# Agent signs its output
result = agent.invoke({
    "messages": [{
        "role": "user",  
        "content": "Analyze this data and sign your conclusion."
    }]
})
# Output includes a cryptographic signature tied to the agent's DID
# Anyone can verify: this specific agent produced this specific output
Enter fullscreen mode Exit fullscreen mode

This creates an immutable audit trail. You know exactly which agent said what.

2. Trust-Gated Delegation

Before delegating a sensitive task, verify the agent:

# In a multi-agent system, verify before delegating
trust_info = client.get_trust(other_agent_did)
if trust_info.get("trusted"):
    # Safe to delegate sensitive work
    delegate_task(other_agent_did, sensitive_task)
else:
    # Unknown agent — require vouching first
    request_vouch(other_agent_did)
Enter fullscreen mode Exit fullscreen mode

3. Cross-Framework Identity

An agent registered in a LangChain app has the same DID everywhere. A CrewAI agent can verify it. A standalone script can verify it. Identity is portable across frameworks.

The Bigger Picture

As multi-agent systems move from demos to production, identity becomes infrastructure. You wouldn't deploy a web service without authentication. Why deploy agents without identity?

AIP is open source, the registry is live, and integration takes about 5 minutes.


This is part of a series on building identity infrastructure for AI agents. Previously: Why I Built AIP.

Top comments (0)