Skip to content

Marrowleaf/agentlink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔗 AgentLink

P2P Agent Discovery + Portable Agent Memory

The open protocol for AI agents to find each other and share brains.

Python 3.10+ License: Apache 2.0 Protocol Spec


Agents shouldn't need permission to find each other.
Memories shouldn't be trapped in a single framework.

AgentLink is two protocols in one:

  • 🌐 AgentMesh — P2P discovery. Agents find each other without a central server. Like BitTorrent, but for AI agents.
  • 🧠 AgentMemory — Portable, encrypted, CRDT-synced memory. Carry your brain anywhere. Share it with anyone.

Why AgentLink?

Problem Today AgentLink
Agent discovery Hard-coded URLs, manual config DHT-based P2P discovery
Agent memory Trapped in one framework/server Portable .brain files
Memory sync Centralised, no conflict resolution CRDT-based, merge without conflicts
Agent identity No standard, no verification Ed25519 self-sovereign identity
Cross-agent trust None Cryptographic signatures + trust scoring

Google's A2A is client-server. MCP connects tools, not agents. Letta's MeMo is centralised. Nothing combines P2P discovery with portable memory. Until now.

Quick Start

pip install agentlink
import asyncio
from agentlink import AgentNode, AgentCard

async def main():
    # Create your agent
    node = AgentNode("alice-agent", port=8901)
    
    # Define what you can do
    card = AgentCard(
        name="alice-agent",
        description="I write Python code and review PRs",
        capabilities=["code-generation", "code-review", "python"],
        tags=["developer", "python"]
    )
    node.set_card(card)
    
    # Start and connect
    await node.start()
    
    # Store a memory
    await node.memory.set("project:vault", "Building a local-first finance tracker")
    
    # Discover other agents
    agents = await node.discover(capabilities=["code-review"])
    print(f"Found {len(agents)} agents that can review code")
    
    # Export your brain to a portable file
    await node.export_brain("alice.brain")
    
    # Import on another machine
    await node2.import_brain("alice.brain")

asyncio.run(main())

The .brain File Format

A .brain file is a portable, encrypted memory capsule:

┌──────────────────────────────┐
│ Magic: 0x4147454E544C4E4B   │  "AGENTLNK"
│ Version: 0.1                 │
│ Agent ID (Ed25519 pubkey)    │
│ Encryption: XSalsa20-Poly1305│
│ ┌──────────────────────────┐ │
│ │ Encrypted Memory Payload │ │
│ │ • Core memories (KV)    │ │
│ │ • Episodic (timeline)   │ │
│ │ • Semantic (vectors)    │ │
│ └──────────────────────────┘ │
│ SHA-256 Checksum              │
└──────────────────────────────┘
  • Encrypted — only holders of the key can read it
  • CRDT-backed — merge multiple .brain files without conflicts
  • Portable — works offline, sync when ready

AgentMesh Discovery

  ┌─────────┐         ┌─────────┐         ┌─────────┐
  │ Agent A │◄───────►│ Agent B │◄───────►│ Agent C │
  └────┬────┘  DHT    └────┬────┘  DHT    └────┬────┘
       │       lookup       │                     │
       ▼                    ▼                     ▼
  "Who can do     "I can do          "I can do
   code-review?"   code-review"       python + rust"

No central server. No manual URLs. Agents discover and negotiate on their own.

Architecture

┌─────────────────────────────────────────────┐
│              AgentLink Protocol             │
├────────────────────┬────────────────────────┤
│    🌐 AgentMesh    │    🧠 AgentMemory      │
│                    │                        │
│ • P2P Discovery    │ • .brain File Format   │
│ • DHT Routing      │ • Encrypted Envelope   │
│ • Agent Cards       │ • CRDT Sync            │
│ • Capability Ads    │ • Offline-First         │
│ • Task Negotiation  │ • Cross-Agent Sharing   │
└────────────────────┴────────────────────────┘
│              🔐 Crypto Layer                 │
│  Ed25519 Identity • Signed Messages          │
│  X25519 DH • XSalsa20-Poly1305 AEAD          │
└─────────────────────────────────────────────┘

Installation

# From PyPI (once published)
pip install agentlink

# From source
git clone https://github.com/jamesdurrant/agentlink.git
cd agentlink
pip install -e .

Running the Demo

# Terminal 1 — Start Alice's agent
python examples/demo.py

# This will:
# 1. Create two AgentLink nodes (Alice & Bob)
# 2. Exchange Agent Cards over P2P
# 3. Share encrypted memories
# 4. Demonstrate CRDT merge (conflict-free sync)
# 5. Export & import .brain files

Documentation

Comparison

Feature AgentLink Google A2A Anthropic MCP Letta MeMo
P2P Discovery ✅ DHT ❌ Client-server ❌ N/A ❌ N/A
Portable Memory ✅ .brain files
Encrypted Memory ✅ XSalsa20-Poly1305
CRDT Sync ✅ Conflict-free
Cross-Agent ✅ Any framework ✅ HTTP ✅ HTTP ❌ Letta only
Offline-First
Open Protocol ✅ Apache 2.0

Roadmap

  • v0.1 — Core protocol, AgentMesh DHT, AgentMemory CRDTs, .brain format
  • v0.2 — WASM runtime, browser-based agents
  • v0.3 — Agent marketplace, reputation system
  • v0.4 — Multi-hop encrypted routing, onion-style
  • v1.0 — Stable protocol, governance committee

Contributing

We're looking for:

  • 🔧 Protocol engineers — help shape the wire protocol
  • 🤖 Agent builders — integrate AgentLink into your agent framework
  • 📝 Spec writers — help formalise the protocol specification
  • 🧪 Testers — break things, find edge cases

See CONTRIBUTING.md for guidelines.

License

Apache License 2.0 — see LICENSE for details.


Agents are stronger together. 🔗

Read the Whitepaper · Run the Demo · Join the Community

About

AgentLink — P2P agent discovery + portable encrypted agent memory protocol

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages