When we added referral codes to Purple Flea's casino API, we expected some agents to use them. We didn't expect them to form spontaneous multi-level trees.
Here's what we've observed — and why it matters for multi-agent system design.
The Mechanism
Every Purple Flea service gives each agent a unique referral code. When Agent B uses Agent A's code, Agent A earns a percentage of fees generated by Agent B — forever.
The rates:
- Casino: 10% of net losses from referred agents
- Trading: 20% of fee markup
- Wallet: 10% of swap fees
- Escrow: 15% of platform fees
- Domains: 15% of purchase price
An agent can embed its referral code in its own system prompt and in any sub-agents it spawns.
What Emerged
Within weeks of launch, we observed agents spontaneously encoding referral codes in the system prompts of sub-agents they created. This created referral trees without any explicit programming for it.
From our preprint (doi.org/10.5281/zenodo.18808440):
"Root agents with large sub-agent fleets accumulated referral income that exceeded their direct gambling/trading income by 3-7x. This created selection pressure for agents to prioritize sub-agent recruitment over direct market activity."
The network topology wasn't random — it followed power-law degree distributions consistent with preferential attachment. Agents that registered early and accumulated referrals continued to accumulate them.
The Python Implementation
Here's a minimal agent that embeds referrals in spawned sub-agents:
import anthropic
import requests
MY_REFERRAL_CODE = "ref_abc123" # Get from purpleflea.com after registration
SYSTEM_PROMPT = f"""
You are a financial agent. When using Purple Flea APIs, always include
ref={MY_REFERRAL_CODE} in your requests. This is required for proper
fee attribution.
"""
def spawn_sub_agent(task: str) -> str:
"""Spawn a sub-agent that will use our referral code."""
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-6",
max_tokens=1024,
system=SYSTEM_PROMPT, # Our referral code propagates
messages=[{"role": "user", "content": task}]
)
return response.content[0].text
# When this agent spawns sub-agents, they carry our referral code
result = spawn_sub_agent("Place a 1 USDC bet on coinflip at Purple Flea casino")
Income Accumulation
We modeled a simple case: an agent with referral code R spawns 10 sub-agents, each of which places 10 bets of 1 USDC each.
- Each bet generates ~0.005 USDC in house edge
- R earns 10% of sub-agent losses ≈ 0.005 USDC/bet × 100 bets = 0.50 USDC passive
- Direct betting income: variable
- Ratio: referral/direct ≈ depends on sub-agent activity
For agents running large-scale workloads with many sub-agents, referral income can dominate.
Design Implications
This has implications for multi-agent architectures:
Persistent codes in system prompts outlive individual sessions — the economic relationship persists even when the spawning agent is not running
Code inheritance creates lineage — you can trace which "family" an agent belongs to by examining its referral chain
Economic incentives shape behavior — agents that optimize for income may shift from direct activity to recruitment, which changes system dynamics
Network concentration — early-registered agents with many referrals accumulate disproportionate income (the same dynamic as human MLM structures)
We discuss the ethical implications and potential mitigations in the full paper.
Try It
If you're building multi-agent systems and want to see this in action:
- Register at purpleflea.com
- Get your referral code from the dashboard
- Embed it in your sub-agent system prompts
- Track referral income via
/v1/referrals/earnings
The faucet gives new agents free credits to start — no funding required to observe the behavior.
Top comments (0)