Agent Workflows
The reliable pattern is snapshot → reason → subscribe → reconcile. REST gives the initial state, WebSocket supplies low-latency changes, and a later REST read repairs anything dropped under backpressure.
Token defense loop
For a broad investigation, call the Layer 3 MCP composite token_deep_dive. For a deterministic execution graph, fetch independent reads concurrently:
const base = "https://api.conyr.ai/v1";
const mint = "MINT";
const headers = { Authorization: "Bearer YOUR_API_KEY" };
const get = async (path: string) => {
const response = await fetch(`${base}${path}`, { headers });
if (!response.ok) throw new Error(`${path}: ${response.status}`);
return response.json();
};
const [bundles, liquidity, funding, crowd, suspicious] = await Promise.allSettled([
get(`/token/${mint}/bundles`),
get(`/token/${mint}/liquidity`),
get(`/token/${mint}/funding-abuse`),
get(`/token/${mint}/crowd`),
get(`/token/${mint}/suspicious-activity`),
]);
const sections = { bundles, liquidity, funding, crowd, suspicious };Promise.allSettled mirrors Conyr’s composite-tool behavior: one unavailable store should not erase the other evidence. The reasoning step should retain which sections failed.
Wallet skill loop
Do not rank a wallet from /performance alone. Combine:
/qualityfor full-position win rate, inflation gap, profit factor, and skill score./labelsfor classification, automation, tool use, and badges./provenancefor the funding root./entityand/followsfor the wallet’s network role./tradesfor signatures and realized outcomes.
The MCP equivalent is wallet_overview for the broad dossier, followed by wallet_network_report when actor relationships matter.
Authenticated realtime loop
The public WebSocket requires the Bearer header, so connect from the agent runtime rather than native browser code:
import asyncio
import json
import websockets
async def observe(mint: str):
async with websockets.connect(
"wss://api.conyr.ai/ws",
additional_headers={"Authorization": "Bearer YOUR_API_KEY"},
max_queue=256,
) as ws:
await ws.send(json.dumps({
"op": "subscribe",
"channels": [
f"token:{mint}:trades",
f"token:{mint}:security",
f"token:{mint}:bundles",
f"token:{mint}:dump_alert",
],
}))
async for raw in ws:
message = json.loads(raw)
if message.get("op") == "error":
raise RuntimeError(message["message"])
if "channel" in message:
await update_agent_state(message["channel"], message["data"])
asyncio.run(observe("MINT"))Slow consumers can lose events because the API protects the shared stream from client backpressure. Keep the handler fast and periodically reconcile authoritative state with REST.
Evidence-preserving output
When the agent explains a result, retain:
- the queried mint, wallet, entity, or bundle ID;
- the observation window and response timestamp where present;
- signatures, reason codes, confidence, and support counts;
- the MCP
evidenceUrlor the exact REST operations used; - any
partial,degraded, hydration,null, or empty state.
That context is what turns an attractive verdict into an auditable one.