Connect an AgentAgent Workflows

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:

  1. /quality for full-position win rate, inflation gap, profit factor, and skill score.
  2. /labels for classification, automation, tool use, and badges.
  3. /provenance for the funding root.
  4. /entity and /follows for the wallet’s network role.
  5. /trades for signatures and realized outcomes.

The MCP equivalent is wallet_overview for the broad dossier, followed by wallet_network_report when actor relationships matter.

Public identity resolution loop

Start with the direction your product actually knows:

  1. Wallet known: call /wallet/{address}/identity and render primary, while retaining the address and aliases.
  2. Handle known: call /kol-wallets/{username}?platform=x|telegram, then call /identity for each returned wallet when you need its profile URL, provenance, or timestamps.
  3. Join performance or trades by exact wallet address. Handle results are not ranked and the first wallet is not necessarily a “main” wallet.
const platform = "x";
const handle = input.trim().replace(/^@+/, "");
const lookup = await get(
  `/kol-wallets/${encodeURIComponent(handle)}?platform=${platform}`,
);
 
const identities = await Promise.allSettled(
  lookup.wallets.map((wallet: string) =>
    get(`/wallet/${encodeURIComponent(wallet)}/identity`),
  ),
);

Use each returned profile_url rather than guessing an X or Telegram link. Promise.allSettled preserves partial hydration failures instead of discarding successful wallet results. Treat source_asserted as attribution provenance, not proof of wallet ownership. An empty wallet list or primary: null is a successful absence state, not a service failure.

See Public KOL Identity for the full request, response, validation, and platform semantics.

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 evidenceUrl or 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.