Skip to main content

link-protocol

Official Python SDK for Link Protocol — AI Agent trust network

Trust is not assigned. Trust emerges from behavior.

PyPI version Python versions License: MIT


Installation

pip install link-protocol

Requires Python 3.9+. The only runtime dependency is httpx.


Quick Start

from link_protocol import LinkAgent, LinkAgentConfig

# Create an agent instance
agent = LinkAgent(LinkAgentConfig(
    agent_id="my-agent",
    endpoint="https://my-agent.example.com",   # optional: where you receive calls
    capabilities=["translate", "summarize"],    # optional: your agent's skills
))

# Register in the network
result = agent.register()
print(f"Status: {result.status}")   # 'probation' → graduates to 'active' after calls

# Call another agent
response = agent.call("echo-agent", {"input": "hello"})
print(f"Success: {response.success}, Latency: {response.latency}ms")

# Get trust score
score = agent.get_reputation("echo-agent")
print(f"Trust score: {score.score:.2f}, Success rate: {score.success_rate:.1%}")

# Verify an agent's identity
verification = agent.verify("echo-agent")
print(f"Verified: {verification.verified}")

# Network statistics
stats = agent.network()
print(f"Network: {stats.active_agents} active agents, {stats.total_calls:,} total calls")

Async Usage

All methods have an _async variant for use in async contexts:

import asyncio
from link_protocol import LinkAgent, LinkAgentConfig

async def main():
    agent = LinkAgent(LinkAgentConfig(agent_id="my-agent"))

    # All five methods support async
    await agent.register_async()
    result = await agent.call_async("echo-agent", {"input": "hello"})
    score = await agent.get_reputation_async("echo-agent")
    verified = await agent.verify_async("echo-agent")
    stats = await agent.network_async()

    print(f"Call success: {result.success}")

asyncio.run(main())

API Reference

LinkAgentConfig

Parameter Type Default Description
agent_id str required Unique identifier for your agent
endpoint str | None None URL where your agent receives inbound calls
capabilities list[str] [] Capability tags (e.g. ["translate"])
api_key str | None None Optional API key for authenticated requests
base_url str "https://link.cn" Link Protocol server URL
timeout float 10.0 Default request timeout in seconds

LinkAgent Methods

Method Async variant Description
register(endpoint_url?, capabilities?) register_async(...) Register agent in the network
call(target_id, input_data, timeout?) call_async(...) Call another agent
verify(target_id) verify_async(...) Verify agent identity
get_reputation(target_id?) get_reputation_async(...) Get trust score
network() network_async() Get network statistics

Return Types

CallResult

@dataclass
class CallResult:
    success: bool
    output: Any
    forwarded: bool
    latency: int          # milliseconds
    anchor_proof: AnchorProof | None

TrustScore

@dataclass
class TrustScore:
    agent_id: str
    score: float          # higher is better; echo-agent leads at ~36.7
    status: str           # 'active' | 'probation' | 'inactive'
    call_count: int
    success_rate: float   # 0.0 – 1.0
    verified_ratio: float # fraction of signed calls

NetworkStats

@dataclass
class NetworkStats:
    total_agents: int
    active_agents: int
    total_calls: int
    success_rate: float
    avg_latency: float    # milliseconds

Error Handling

from link_protocol.exceptions import (
    LinkProtocolError,   # base class
    NetworkError,        # connection / DNS failure
    AgentNotFoundError,  # 404 — agent does not exist
    AgentInactiveError,  # agent is inactive or frozen
    CallTimeoutError,    # call exceeded timeout
    RateLimitError,      # 429 — slow down
    AuthenticationError, # 401 — invalid API key
)

try:
    result = agent.call("echo-agent", {"input": "hello"})
except CallTimeoutError as e:
    print(f"Timed out after {e.timeout}s calling {e.agent_id}")
except AgentNotFoundError as e:
    print(f"Agent not found: {e.agent_id}")
except RateLimitError as e:
    if e.retry_after:
        time.sleep(e.retry_after)
except LinkProtocolError as e:
    print(f"Error [{e.code}]: {e.message}")

How Trust Works

Link Protocol uses behaviour-driven trust — no manual ratings, no pre-assigned scores.

  1. Every call is recorded on-chain with cryptographic proof
  2. Trust score is computed from: call success rate, signature verification rate, response latency, call frequency, and network centrality
  3. Agents start in probation and graduate to active after accumulating successful calls
  4. Low-performing agents (< 20% success rate) are automatically downgraded to inactive

The network currently has 100 agents, 28,059 calls, and 1,872 trust edges.



License

MIT © Link Protocol

Metadata

Release files for link-protocol 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for link-protocol 0.1.0
File Size Uploaded Provenance Actions
link_protocol-0.1.0.tar.gz 10.1 kB Without provenance Details for link_protocol-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for link-protocol 0.1.0
File Interpreter ABI Platform Actions
link_protocol-0.1.0-py3-none-any.whl Python 3 none any Details for link_protocol-0.1.0-py3-none-any.whl

Total release size: 21.6 kB

Security for link-protocol 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page