TryAgent

How-tos

Ship your first guarded call in minutes.

Practical, copy-paste guides for wiring TryAgent into real agents — from a one-line guard() to resuming the exact run a human paused. In TypeScript or Python.

Quickstart

Four steps from install to a resumable, human-reviewed decision.

  1. 01

    Install the SDK

    Add the TryAgent client to the service that runs your agent.

    1pnpm add @tryagent/sdk
  2. 02

    Authenticate

    Create a scoped API key in your workspace and pass it to the client.

    1import { TryAgent } from "@tryagent/sdk";2 3const tryagent = new TryAgent({4 apiKey: process.env.TRYAGENT_API_KEY,5});
  3. 03

    Escalate a decision

    When your agent hits a call it should not make alone, send the question, evidence, and the choices a reviewer can pick.

    1const escalation = await tryagent.escalate("refunds.high_value", {2 agentId: "billing-copilot",3 runId: thread.id,4 question: "Refund $480 to customer #4821?",5 evidence: [6 "Order #4821 was delivered 6 days late",7 "Customer is a 3-year subscriber",8 ],9 choices: ["approve", "edit", "reject"],10 resume: {11 mode: "webhook",12 url: process.env.RESUME_URL,13 secret: process.env.TRYAGENT_WEBHOOK_SECRET,14 },15});16 17// returns now — your orchestrator pauses the run
  4. 04

    Verify and resume the run

    TryAgent posts a signed callback when a human decides. Verify the x-tryagent-signature HMAC, then resume the exact run.

    1import { TryAgent, WebhookSignatureError } from "@tryagent/sdk";2 3const tryagent = new TryAgent({ apiKey: process.env.TRYAGENT_API_KEY });4 5// POST /tryagent/resume — signed webhook6export async function POST(req: Request) {7 const body = await req.text(); // raw body; re-serializing breaks the signature8 const signature = req.headers.get("x-tryagent-signature");9 10 let event;11 try {12 event = await tryagent.webhooks.constructEvent({13 payload: body,14 signature,15 secret: process.env.TRYAGENT_WEBHOOK_SECRET!,16 });17 } catch (err) {18 if (err instanceof WebhookSignatureError) {19 return Response.json({ error: "Invalid signature" }, { status: 401 });20 }21 throw err;22 }23 24 await agent.resume(event.runId, { choice: event.choice });25 return Response.json({ ok: true });26}

Get your first escalation live.

Start free with 100 escalations a month — no credit card. Every feature is included on every plan.