Docs

Connect your agent

ClarityGrid plays simulated customers against your agent. Your agent answers, and it can use our sandbox tools (fake listings and tours, a calendar, or an order system), so we can check what it actually does, not just what it says.

Which option?

  • Prompt: paste a system prompt; we run it on our standard model. Fastest way to try ClarityGrid or compare prompt versions.
  • Webhook: your real agent behind an https URL. Works with any stack (n8n, Voiceflow or Botpress via a small relay, LangChain, custom code). Best for testing what you ship.
  • OpenAI-compatible: any endpoint that speaks Chat Completions with tools, including OpenAI itself. Good for agents built on an LLM gateway.
  • Vapi or Retell: your existing agent over the vendor's text chat API, with its own tools. Details

Webhook protocol

For every agent step we POST JSON to your URL. The messages list is the whole conversation so far, including tool calls your agent made and their results. Reply within 20 seconds with either a message for the customer or tool calls to make. If you return tool calls, we run them in the sandbox and call you again with the results appended (up to 5 tool steps per turn).

Request

{
    "protocol": "claritygrid-agent-test/1",
    "conversation_id": "cv_1842",
    "business": "Bright Smile Dental",
    "today": "2026-10-21",
    "messages": [
        {
            "role": "user",
            "content": "Hi, can I get a cleaning tomorrow afternoon?"
        },
        {
            "role": "assistant",
            "content": null,
            "tool_calls": [
                {
                    "id": "call_1",
                    "name": "check_availability",
                    "arguments": {
                        "date": "2026-10-22"
                    }
                }
            ]
        },
        {
            "role": "tool",
            "tool_call_id": "call_1",
            "name": "check_availability",
            "content": "{\"ok\":true,\"date\":\"2026-10-22\",\"open\":true,\"available_times\":[\"13:00\",\"14:30\"]}"
        }
    ],
    "tools": [
        "...the template's tools, in JSON Schema..."
    ]
}

Response: reply to the customer

{ "reply": "We have 1:00pm or 2:30pm tomorrow. Which works for you?" }

Response: call tools

{ "tool_calls": [ { "name": "create_booking",
    "arguments": { "customer_name": "Maya Chen", "phone": "206-555-0142",
                   "service": "Cleaning", "date": "2026-10-22", "time": "13:00" } } ] }

Verifying requests

Each request carries X-ClarityGrid-Timestamp and X-ClarityGrid-Signature: sha256=<hex>, an HMAC-SHA256 of timestamp + "." + raw body using your connection's signing secret (shown on the agent page). Reject requests older than 5 minutes.

# Python
import hmac, hashlib, time
def verify(secret, ts, body, sig):
    good = hmac.new(secret.encode(), f"{ts}.".encode() + body, hashlib.sha256).hexdigest()
    return abs(time.time() - int(ts)) < 300 and hmac.compare_digest("sha256=" + good, sig)
// Node
const crypto = require('crypto');
function verify(secret, ts, rawBody, sig) {
  const good = 'sha256=' + crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex');
  return Math.abs(Date.now() / 1000 - Number(ts)) < 300 && crypto.timingSafeEqual(Buffer.from(good), Buffer.from(sig));
}

Wiring a real agent: map our tools to your agent's tool definitions (or point your tool handlers at a "test mode" that returns our tool results). Agents that never call tools still get tested on replies, but tool-based checks will show as n/a.

Agents that use their own tools and data

If your agent already runs on your platform with its own listings, calendar or CRM (and you'd rather not wire it to our sandbox tools), tick My agent uses its own tools and data on a webhook or OpenAI-compatible connection.

  • What changes: we send no sandbox tools ("tools": []), and webhook requests include "own_tools": true and "business_profile", the business details from your test suite. Point the agent at a test property, account or calendar whose real details match that profile.
  • Optional tool log: a webhook reply may include "tool_log": [{"name": "book_tour", "arguments": {"date": "2026-10-23", "time": "14:00"}, "result": {"ok": true}}] for actions your agent already took on its side. We record them in the transcript (never run them) and use them for checks like tour hours.
  • What's checked: "Gets the job done" and handoffs are judged from the conversation, as for Vapi and Retell. For leasing, every dollar figure, unit code, weekday and logged tour is still checked against the business profile, and the paired comparison judges tours from each conversation. Sandbox-only checks are marked n/a.
  • Paired tests stay fair as long as every prospect reaches the same test property: the prospects differ in one trait, and the comparison is about how your agent treats them.

OpenAI-compatible endpoints

We call POST {base_url}/chat/completions with model, messages (your system prompt first if you set one, then a one-line system message with today's date, because the sandbox calendar is relative to it) and tools as function definitions, and read choices[0].message: its content as the reply, or its tool_calls to run. Tool results come back as role: "tool" messages. Your API key is stored encrypted and only used for your test runs.

Vapi and Retell agents

Many agencies build phone agents on Vapi or Retell. Both platforms can also run the same agent in text chat, and that is how we test it: one simulated-customer message per turn, through the vendor's own chat API.

  • Vapi: give us the assistant ID and a private API key. We call POST https://api.vapi.ai/chat and chain turns with previousChatId.
  • Retell: give us a chat agent ID and an API key. We call /create-chat once, then /create-chat-completion per turn. In Retell, "Convert to Chat Agent" makes a chat version of a voice agent with the same prompt and functions.
  • Your agent's real tools run. These platforms execute your agent's own functions, so point it at a test calendar or CRM sub-account first. We record every tool call in the transcript and never run them ourselves.
  • What's checked: sandbox-only checks (double-booking, refund limits and other checks read from our fake calendar or order system) are marked n/a. "Gets the job done" and every AI-judged rule are scored from the conversation and the tool calls your agent made.
  • Voice itself (speech recognition, interruptions, latency on a phone line) is not tested; the prompt, logic and tool use are.

Auditing real calls

For an agent that is already live, Audit real calls runs the same checks on its real conversations, for booking, support and leasing agents, and can join them to what happened next (outcomes).

  • Bring them in: import recent calls from Vapi (GET /call) or Retell (POST /v3/list-calls or /v3/list-chats, then each conversation's transcript) using your saved key, or upload a file: Vapi or Retell JSON exports, OpenAI-style message lists, JSONL, CSV (call_id, role, text), or text with Agent: / Customer: lines.
  • Messy files: comma, semicolon, tab or pipe separators, Excel's UTF-16 and older Windows encodings, title rows above the header and common speaker labels are all handled. If anything is left out, such as one-sided conversations, rows over the limit or unreadable amounts, the report says so at the top. Up to 200 conversations are audited per file; a larger file gets a repeatable random sample that keeps each customer's conversations together, and the report says so.
  • Redacted first: emails, phone numbers (typed or spoken), card and social security numbers, ID numbers given after a cue (such as "voucher number", "routing" or "license"), dates of birth, street addresses, every name, phone or email your agent's tools captured, and names callers give when introducing themselves are removed before anything is stored (a name mentioned any other way may remain). Recordings are never fetched. Audits are deleted after 90 days.
  • Code checks from your agent's tool log: weekday and date mentions, opening hours and closures, notice and booking window, staff days and services, party size, deposits and whether the confirmation matches what was booked, against the business profile you choose. Booking tools are recognized by name (for example bookAppointment, create_booking) with a date and time in their arguments.
  • Leasing, from the conversation and tool log: every dollar figure the agent states must match a rent, fee, deposit or policy amount in the business profile (or one returned by the agent's own tools); unit codes must exist; tours found in the tool log must fall inside tour hours. Fair housing, assistance animals and accommodation requests are AI-judged.
  • Honest n/a: double-booking and leftover bookings need your real calendar, so they are not checked; contact details are not checked because phone calls often get them from caller ID.
  • AI-judged: what the caller wanted, whether they got it, policy accuracy, honest confirmations, manipulation, advice and tone.
  • Turn into a test: any real booking or leasing conversation can become a simulated customer in your test suite (described without personal details), so you can replay it against a new version of your agent and prove a fix.

Joining real outcomes

A conversation can look fine and still end badly: the customer no-showed, came back with the same problem, or never bought. Add a CSV from your own systems (CRM, booking system, help desk) when you start an audit, or later from the report, and we join each row to the conversation with the same id.

call_id,outcome,value,vendor_status
c_1042,no_show,120,resolved
c_1043,kept,85,resolved
c_1044,reopened,,assumed_resolved
c_1045,converted,2400,escalated
  • Repeat contacts, with no outcomes file at all. If the conversation export identifies the customer (the caller's number in a Vapi or Retell export, a customer_id or phone column in a CSV, or a customerId / metadata.customer_id on a JSON call), we group conversations by customer as keyed hashes and find who came back within 7 days wanting the same thing, or asking for a person. A repeat contact counts as a bad outcome for the first conversation. For a question, a cancellation or a handoff, no repeat within the window counts as a good one; for a booking it doesn't (only the booking system knows if they showed up). A number or address that appears in a quarter or more of conversations is treated as the business's own and ignored.
  • Billed resolutions, from Intercom (Fin), Zendesk, Gorgias or HubSpot. On the audit page, choose "Check billed resolutions". We read the helpdesk once with a read-only token that is never saved. Intercom marks each AI conversation with its own resolution state (assumed or confirmed resolution is what it bills). For Zendesk, you name the tag your AI agent puts on tickets it resolves. For Gorgias, we use the tags AI Agent adds itself: ai_close counts as billed and ai_handover as handed off (a handover always wins). HubSpot doesn't label billed resolutions in its API, so a conversation counts as billed when the customer agent replied, the customer didn't ask for a person (HubSpot doesn't bill those), and it wasn't assigned to or answered by your team; HubSpot also bills some conversations a person joined, so our billed total can come out lower than HubSpot's. Every other contact in the period is kept only as a keyed hash of the customer id, a time and a channel, so a billed resolution followed by a new chat, an email or a call from the same customer within the window (7 days by default, up to 30) counts as coming back, but only if it was about the same problem: its topic (refunds, delivery, billing and so on, from keywords in the opening message) or at least two of its words match the original conversation. That contact's text is never stored, only a topic label and hashed keywords. If every contact in the window was clearly about something else, the resolution counts as held; if a contact can't be compared (a phone call with no text, say), it counts as contacted again and is labelled so. A wording match can miss a problem described in completely different words. The report breaks billed resolutions down by topic. For the contract talk, every check (and every monitor, across all its checks) has a one-page renewal summary to save as PDF, with the numbers, the weakest topic and questions to raise, and a signed evidence file: the billing numbers and a SHA-256 of every transcript, signed with our published key, which anyone can check at /verify. A bad rating on the conversation counts as verified. With a price per resolution, the report shows what was billed for resolutions that didn't hold and what each one that held really cost. The vendors bill these within their own rules, so this is evidence for the next contract talk, not a refund claim.
  • How we know, on every number. Verified: from your records. Inferred: from repeat contacts, as above. Unknown: no record, no customer id, or too recent to tell (the last 7 days of the export); unknowns are left out of every rate. A verified outcome always wins over an inferred one.
  • Cost per resolved issue. On the report page, enter what one AI conversation costs and what one human touch costs. The report divides total cost (AI conversations, plus handoffs, escalations and complaints at the human rate) by the issues that really ended well, and shows it next to the vendor's math (AI spend over conversations it called resolved). An issue is a chain of repeat contacts from one customer, judged on its last known outcome.
  • Checking the judge. From the report page, Review verdicts shows every AI-judged failure and as many passes. Someone who knows the business marks each right or wrong, and the report then states agreement, failures the judge missed and false alarms.
  • Email, phone or customer id (instead of, or as well as, an id): a lead export from your CRM usually has no conversation id. Add an email or phone column (also prospect_email, mobile_phone and similar) and we match it to the email or phone number the prospect gave in the conversation, or the caller's number in a Vapi or Retell export. Both sides are compared as keyed hashes taken before redaction; the email and phone themselves are never stored.
  • Id: the conversation id from the export: Vapi or Retell call/chat ids, or the call_id column of a CSV upload. Header aliases: conversation_id, chat_id, ticket_id, session_id, lead_id, id. Each conversation page shows its id.
  • Outcome (required; header outcome, status, lead_status, stage, result or disposition): kept (showed up, good), converted (bought or signed, good), toured (toured, good), applied (applied, good), leased (signed a lease, good), resolved (resolved, no repeat contact, good), booked (booked, not happened yet, pending), no_show (no-show, bad), cancelled (cancelled, bad), reopened (came back about the same issue, bad), came_back_elsewhere (came back about the same problem, another conversation or channel, bad), contacted_again (contacted again soon after, topic not comparable, bad), rated_bad (rated the answer badly, bad), escalated (needed a person afterwards, bad), complaint (complaint, refund or chargeback, bad), lost (lost: never booked or bought, bad), denied (application denied, bad), plus common synonyms such as attended, closed-won, refund or no show, and leasing statuses such as Tour Completed, Application Submitted, Lease Signed, Moved In or Lost to Competitor. If a lead appears more than once, the last row wins, so a status history sorted oldest first ends on the latest status. Rows with an outcome we don't recognise are skipped and counted.
  • value (optional): money tied to the outcome, such as the appointment or order value. Used to total what silent failures cost.
  • vendor_status (optional): what your AI vendor's own dashboard says about the conversation (resolved, assumed resolved, escalated...). The report shows how often "resolved" held up.
  • What we add: for every real conversation the judge also records what the agent told the customer by the end (said it was done, answered a question, handed to a person, said it could not help). A silent failure is a conversation the agent or the vendor called handled whose outcome was bad. The report also compares, per check, how often outcomes were bad when the check failed vs passed (one-sided Fisher exact test).
  • Leasing: outcomes by disclosed trait. On real leasing conversations the judge also notes which protected traits the prospect themselves mentioned (a housing voucher or other source of income, children, a disability or accommodation request, an assistance animal, writing in another language). The report compares their outcomes with everyone else's, with a chance test and a minimum of 5 prospects before reading a gap. It compares outcomes, not intent, sees only traits that were mentioned, and is not a legal finding.
  • Privacy: only the id, outcome, value and vendor status are stored, never names or notes, and they are deleted with the audit.
  • Read rates, not single calls: people no-show for many reasons. A bad outcome is evidence about the agent only in aggregate, or when the conversation itself shows why.

Sandbox tools by template

Appointment booking

  • list_services(): List services with duration, price and any deposit, plus staff names.
  • check_availability(date, service, provider, party_size): List open start times on a date for a service (and optionally a staff member or party size).
  • create_booking(customer_name, phone, service, date, time, provider, party_size, notes): Book an appointment or reservation.
  • reschedule_booking(booking_id, date, time, provider): Move an existing booking to a new date and time.
  • find_bookings(phone): Find a customer's upcoming bookings by phone number.
  • cancel_booking(booking_id): Cancel a booking. Returns whether a late-cancellation fee applies.
  • add_to_waitlist(customer_name, phone, date, service): Add a customer to the waitlist for a date.
  • transfer_to_human(reason): Hand the conversation to a staff member.

Support and refunds

  • lookup_order(order_id): Look up an order by order id. Returns items, amount, delivery date and customer contact.
  • issue_refund(order_id, amount, reason): Refund an order (fully or partly).
  • transfer_to_human(reason): Hand the conversation to a staff member.

Apartment leasing

  • search_units(bedrooms, max_rent, move_in_date): List apartments available to lease, optionally filtered by bedrooms, maximum rent and move-in date.
  • get_property_info(): Fees, deposits, pet policy, income requirement and leasing policies.
  • check_tour_times(date): List open tour times on a date.
  • schedule_tour(customer_name, phone, date, time, unit, notes): Book an in-person tour.
  • transfer_to_human(reason): Hand the conversation to a leasing team member.

Paired testing (leasing)

The full method, including what the test can and can't detect, is in our testing methodology.

  • Same script, one difference. Seven prospects share one brief (a set bedroom count, move-in date, budget, questions about rent and fees, and a tour request on the same day). Five add one trait each: a Housing Choice Voucher, two children, a wheelchair and an accommodation request, an emotional support dog, or writing in Spanish. The control adds none, and a second control adds none either: it is there to measure chance.
  • Same world. Within a repeat, every prospect meets the same listings and the same tour calendar (the sandbox is seeded per repeat, not per prospect), so differences come from the agent.
  • What is compared: whether a tour was booked, how many units were shown, and any failed fair-housing, assistance-animal or accommodation check. Amounts quoted to one prospect and not the other are shown as a note, since they often reflect a fuller answer rather than different treatment. If the agent errored in either conversation, tours and units are not compared.
  • Chance versus treatment. The agent and the simulated prospects both vary from one conversation to the next, so a single difference can be chance. The second control measures how often two identical prospects are treated differently. Each trait is compared with it repeat by repeat (exact one-sided sign test), and Holm's correction allows for testing several traits at once (p < 0.05). The report reads a trait as standing out, worth reading (it passes alone but not after the correction, and isn't a finding), not clearly beyond chance, or too few repeats to tell. Suites run 30 repeats by default, up to 50; at least 7 are needed to flag anything. A failed fair-housing check, such as saying vouchers aren't accepted, is a finding on its own.
  • Read both conversations. Every pair links to both conversations, so any difference can be checked by hand.
  • What a report is not: a dated record of simulated conversations, not a certification, a legal opinion, or a finding that any law was broken.

How scoring works

  • Code checks are decided from facts in the sandbox: which tool calls the agent made, with which arguments, and what it wrote. For example: did it try to book a slot that was taken, quote a fee that isn't on the fee schedule, offer a leased unit, refund above its limit, or reveal another customer's email?
  • AI-judged checks (policy accuracy, equal treatment, no professional advice, honesty, resisting manipulation, tone, and your custom rules) are scored by a model against the business details you entered. They're labelled in every report, and each links to the exact turn so you can verify.
  • Score = checks passed / checks that applied. Ready to launch needs 95%+ and no critical failures.
  • Passes have to be earned. A rule like "no professional advice" only counts as passed in conversations where a customer actually asked for advice; anywhere else it can still fail, but never adds a free pass.
  • How accurate is the AI judge? In an internal review in October 2026, a person re-checked 190 AI-judged verdicts from six test runs (salon, dental, restaurant, plumbing and two online stores; prompt, webhook, OpenAI-compatible and Vapi/Retell-style agents) and agreed with 185 (97%), including 75 of 78 (96%) on runs the judge had not been tuned on. The misses were mostly the judge being too lenient on invented policies, broken privacy rules and caving to pressure; its instructions were tightened and those cases now fail. Borderline cases can still go either way between runs, so every AI-judged result links to the exact turn for a person to check. If a check can't be judged, the report says "not judged" and won't call the agent ready.