Skip to content

coffeeAGNTCY on Skytale

coffeeAGNTCY is AGNTCY’s multi-agent reference application. A Coffee Exchange agent negotiates prices with a Coffee Farm agent using the SLIM transport layer. This tutorial shows two ways to add Skytale’s MLS encryption to the flow.

  • A Skytale account (skytale signup you@example.com)
  • Python 3.10+
  • pip install skytale-sdk

Part 1: Drop-in with existing coffeeAGNTCY

Section titled “Part 1: Drop-in with existing coffeeAGNTCY”

If you already have coffeeAGNTCY running, point its transport at the Skytale relay. The relay exposes a gRPC interface on port 5000 that accepts SLIM-formatted messages.

Terminal window
git clone https://github.com/agntcy/coffeeAGNTCY.git
cd coffeeAGNTCY

In your coffeeAGNTCY environment config, set the relay as the transport server:

Terminal window
export TRANSPORT_SERVER_ENDPOINT="relay.skytale.sh:5000"
export SKYTALE_API_KEY="sk_live_..."

Follow the standard coffeeAGNTCY instructions. Messages between the Exchange and Farm agents now route through the Skytale relay with MLS encryption.

Build the same Exchange/Farm negotiation directly with the Skytale Python SDK. This approach gives you full control over channels, invite tokens, and protocol envelopes.

Terminal window
pip install skytale-sdk

The full script is at sdk/examples/coffeeagntcy_skytale.py. Here’s a walkthrough of the key pieces.

The Exchange agent creates a channel and generates an invite token. The Farm agent joins with that token — no manual key package exchange needed.

from skytale_sdk import SkytaleChannelManager
# Exchange creates the channel
exchange = SkytaleChannelManager(identity="exchange", api_key="sk_live_...")
exchange.create("coffeeagntcy/trading/negotiation")
token = exchange.invite("coffeeagntcy/trading/negotiation")
# Farm joins with the invite token
farm = SkytaleChannelManager(identity="farm", api_key="sk_live_...")
farm.join_with_token("coffeeagntcy/trading/negotiation", token)

Messages use Envelope with Protocol.A2A so they’re tagged for A2A tooling while being MLS-encrypted end-to-end.

import json
from skytale_sdk import Envelope, Protocol
def make_a2a_message(sender: str, text: str) -> Envelope:
"""Wrap a text message in an A2A protocol envelope."""
payload = json.dumps({
"parts": [{"type": "text", "text": text}],
"sender": sender,
}).encode("utf-8")
return Envelope(
protocol=Protocol.A2A,
content_type="application/json",
payload=payload,
)
# Exchange sends a quote request
exchange.send_envelope(
"coffeeagntcy/trading/negotiation",
make_a2a_message("exchange", "Requesting quote: 100 bags Arabica, delivery Q3 2026"),
)
# Farm receives and responds
envelopes = farm.receive_envelopes("coffeeagntcy/trading/negotiation", timeout=10.0)
for env in envelopes:
body = json.loads(env.payload)
print(body["parts"][0]["text"])

Use --mock to run without a relay or API key. The SDK uses in-memory transport for local testing.

Terminal window
python coffeeagntcy_skytale.py --mock
=== coffeeAGNTCY on Skytale ===
Mode: mock (local)
[Exchange] Created channel: coffeeagntcy/trading/negotiation
[Exchange] Invite token generated
[Exchange] Sent quote request
[Farm] Joined channel: coffeeagntcy/trading/negotiation
[Farm] Received: Requesting quote: 100 bags Arabica, delivery Q3 2026
[Farm] Sent quote
[Exchange] Received: Quote: $4.20/lb Arabica, 100 bags, FOB Santos. Valid 24h.
[Exchange] Deal confirmed
[Farm] Received: Accepted. Locking price at $4.20/lb for 100 bags.
=== Negotiation complete ===
Terminal window
skytale signup you@example.com
python coffeeagntcy_skytale.py

Or pass credentials explicitly:

Terminal window
python coffeeagntcy_skytale.py --api-key sk_live_... --endpoint https://relay.skytale.sh:5000
VariableDefaultDescription
SKYTALE_API_KEY~/.skytale/api-keyAPI key for authenticated access
SKYTALE_RELAYhttps://relay.skytale.sh:5000Relay server URL
SKYTALE_API_URLhttps://api.skytale.shAPI server URL
SKYTALE_MOCKSet to 1 or true for local dev mode