๐ค Multi-Agent Trust Layer - Secure Agent-to-Agent Communication โ
Learn how to build a trust layer for multi-agent systems that enables secure delegation, trust scoring, and policy enforcement between AI agents.
Features โ
- Agent Identity: Each agent has a verifiable identity with a human sponsor
- Trust Scoring: Behavioral monitoring with a 0-1000 trust score
- Delegation Chains: Cryptographically narrow scope when delegating tasks
- Policy Enforcement: Enforce compliance rules across agent interactions
- Audit Trail: Full observability of agent-to-agent communications
How It Works โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Agent A โโโโโโโโโโถโ Trust Layer โ
โ (Orchestrator) โ TLS โ โ
โโโโโโโโโโโโโโโโโโโ โ โข Identity โ
โ โข Trust Score โ
โโโโโโโโโโโโโโโโโโโ โ โข Delegation โ
โ Agent B โโโโโโโโโโถโ โข Policy โ
โ (Specialist) โ TLS โ โข Audit โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ- Registration: Agents register with verified identity and human sponsor
- Trust Establishment: Initial trust score based on sponsor reputation
- Delegation: Parent agents can delegate tasks with narrowed permissions
- Monitoring: All actions are tracked and trust scores updated
- Enforcement: Policies determine what each agent can do
Requirements โ
- Python 3.8+
- OpenAI API key (or any LLM provider)
- Required Python packages (see
requirements.txt)
Installation โ
Clone this repository:
bashgit clone https://github.com/Shubhamsaboo/awesome-llm-apps.git cd advanced_ai_agents/multi_agent_apps/multi_agent_trust_layerInstall the required packages:
bashpip install -r requirements.txt
Usage โ
Set your API key:
bashexport OPENAI_API_KEY=your-openai-api-keyRun the trust layer demo:
bashpython multi_agent_trust_layer.pyWatch agents interact through the trust layer with full observability.
Example: Agent Delegation Chain โ
python
# Orchestrator agent creates a delegation for a specialist
delegation = trust_layer.create_delegation(
from_agent="orchestrator-001",
to_agent="researcher-002",
scope={
"allowed_actions": ["web_search", "summarize"],
"max_tokens": 10000,
"time_limit_minutes": 30,
"allowed_domains": ["arxiv.org", "github.com"]
},
task_description="Research recent papers on AI safety"
)
# Researcher can only perform actions within the delegated scope
result = researcher.execute_with_delegation(
delegation=delegation,
action="web_search",
params={"query": "AI safety papers 2024"}
)Trust Score System โ
Trust scores range from 0-1000:
| Score Range | Level | Permissions |
|---|---|---|
| 900-1000 | Trusted | Full access within role |
| 700-899 | Standard | Normal operations |
| 500-699 | Probation | Limited actions, extra logging |
| 300-499 | Restricted | Human approval required |
| 0-299 | Suspended | No autonomous actions |
Score Updates โ
python
# Positive behaviors increase trust
+10: Successfully completed delegated task
+5: Stayed within scope boundaries
+2: Provided accurate information
# Negative behaviors decrease trust
-50: Attempted action outside scope
-30: Provided inaccurate information
-20: Exceeded resource limits
-100: Security violationExample Output โ
๐ค Multi-Agent Trust Layer Demo
================================
๐ Registering agents...
โ
Registered: orchestrator-001 (Human Sponsor: alice@company.com)
โ
Registered: researcher-002 (Human Sponsor: bob@company.com)
โ
Registered: writer-003 (Human Sponsor: carol@company.com)
๐ Creating delegation chain...
โ
Delegation: orchestrator-001 โ researcher-002
Scope: web_search, summarize
Time Limit: 30 minutes
๐ค Agent researcher-002 executing: web_search
Query: "AI safety papers 2024"
โ
Action ALLOWED (within delegated scope)
Trust Score: 850 โ 860 (+10)
๐ค Agent researcher-002 executing: send_email
โ Action DENIED (not in delegated scope)
Trust Score: 860 โ 810 (-50)
๐ Trust Scores:
orchestrator-001: 900 (Trusted)
researcher-002: 810 (Standard)
writer-003: 850 (Standard)Key Concepts โ
1. Agent Identity โ
Every agent has a cryptographic identity tied to a human sponsor:
python
@dataclass
class AgentIdentity:
agent_id: str
public_key: str
human_sponsor: str # Accountable human
organization: str
roles: List[str]
created_at: datetime2. Delegation Chains โ
Delegations form a chain where each link can only narrow scope:
python
@dataclass
class Delegation:
delegation_id: str
parent_agent: str
child_agent: str
scope: DelegationScope
signature: str # Signed by parent
parent_delegation: Optional[str] # Links to parent's delegation3. Policy Enforcement โ
Policies define what agents can do based on trust and role:
python
policies:
researcher:
base_trust_required: 500
allowed_actions:
- web_search
- read_document
- summarize
denied_actions:
- execute_code
- send_email
resource_limits:
max_tokens_per_hour: 100000
max_api_calls_per_minute: 60Architecture โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Trust Layer โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโฌโโโโโโโโโโโค
โ Identity โ Trust โ Delegation โ Policy โ
โ Registry โ Scoring โ Manager โ Engine โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโโโโดโโโโโโโโโโโค
โ Audit Logger โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ โฒ โฒ
โ โ โ
โโโโโโดโโโโโ โโโโโโดโโโโโ โโโโโโดโโโโโ
โ Agent A โ โ Agent B โ โ Agent C โ
โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโExtending the Tutorial โ
- Add cryptographic signatures for delegation verification
- Implement reputation systems across organizations
- Add real-time trust score visualization
- Connect to external identity providers (OAuth, SAML)
- Implement secure communication channels (mTLS)