# Inside Unify's eval playbook for AI agents <!-- ref: @content/youtube/langchain/2026-08-13-inside-unify-s-eval-playbook-for-ai-agents version: 3 updated_at: 2026-10-31T18:21:02.790Z --> Connor Hegy (LangChain, 2026-08-13): Connor Hegy frames go-to-market as a search problem over huge amounts of unstructured web data, which makes it a natural fit for LLM agents, but argues that making those agents viable at scale is mostly hard engineering, not model magic. **[Watch on YouTube](https://www.youtube.com/watch?v=6898VdRtKDE)** *Synthesized from Connor Hegy on LangChain, 2026-08-13.* Connor Hegy is co-founder and CTO of Unify, an outbound go-to-market agent platform credited with powering $900 million in pipeline; before Unify they worked on the ML/mapping team at Scale and at a 15-person self-driving startup where 11 people held math PhDs. ## Core Thesis Connor Hegy frames go-to-market as a search problem over huge amounts of unstructured web data, which makes it a natural fit for LLM agents, but argues that making those agents viable at scale is mostly hard engineering, not model magic. Unify's newly launched chat agent behaves like a coding agent that writes TypeScript over tabular data, and its economics depend on deliberate prompt-cache management, cheap in-process sandboxes, structured memory, and an eval practice built on looking at lots of real traces and turning failures into targeted regression sets. ## Key Insights - **Evolution of the product.** Unify's first agent (about 3 years ago) was a scaled web-research agent built on GPT-4o with a reflect/tool-call loop, answering structured questions like "does this company perform KYC?" (e.g., checking terms of service for Social Security number collection). Adding an o1 planning step up front massively improved quality. The pitch: replace a team of 10 sales reps doing research with one growth marketer launching "a million agents a month." - **From async workflows to chat.** The original product was a drag-and-drop nodes-and-edges workflow builder run in an async background system over tables of thousands to millions of records. The new chat product (launched the week before recording) gives each sales rep "an engineer in their back pocket" that hits APIs and builds tables dynamically. Frontier models now let much of the distribution be covered by chaining data-vendor APIs plus lightweight classification, reserving per-row agents for the long tail. - **Harness is "hilariously similar" to a coding agent.** The difference is the artifact: instead of edits to a file system, outputs are database records, email sequences, etc. The agent still gets there by writing code. - **Harness requirements Hegy listed:** cloud-run (sales reps won't run things locally); durable, restarting gracefully if killed, and detachable/re-attachable since ALBs time out after 60 seconds; TypeScript code generation (Unify is a full TypeScript shop); very cheap, fast-spinning environments; file access (via the native OpenAI Files API, with uploaded CSVs wrapped into a native "table artifact"); first-class tabular data; and P0 strong tenancy that must be provably impossible to cross. - **Tabular data via a pandas-like TypeScript class.** Models are bad at reading tables directly but good at writing pandas-style code, so Unify virtualized tables (stored in its database) behind a class exposing roughly 10 common operations: reorder columns, map a function over rows, add/delete/filter rows, fetch rows, resort columns, change data types. They considered reimplementing all of pandas or exposing raw SQL (with row-level security), but settled on the curated set. Over 80% of agent runs touch a table. - **A sub-agent is just a function call.** The agent can pass prompt, model, and reasoning budget, and all long work (sub-agents, row maps) follows the async "kick off, get a job ID handle, await or poll" pattern. Sleeps must be non-blocking because the stack runs on Temporal. - **Cost-aware waterfalls.** At 1 cent per sub-agent, 1,000 rows costs $10 against a $20 base plan. So in row maps the agent waterfalls through cheap APIs first and only calls a sub-agent as the last-resort fallback. - **How OpenAI prompt caching actually behaves (per Hegy).** Cached input is ~90% cheaper, so cache hits essentially decide whether the product is viable. OpenAI hashes roughly the first 60–70 characters to route requests; above ~15 requests per second on a single prompt cache key, there are no guarantees. If you send one large request then 100 more, roughly 15 hit the cache and the other 85 route to cold machines (which then warm up). It's all best effort. Unify sits around a 95% cache hit rate. - **Use the Responses API.** Hegy says skipping it costs 20–30% in quality because thinking traces aren't retained between calls; the response ID also routes to the right machine. - **Two sub-agent types: child and fork.** Child sub-agents get a fresh context window; fork sub-agents inherit the current chat via the previous response ID. Forking 10–15 is usually fine, but forking 20 can produce a full cache miss on the whole context, around 80 cents on GPT-5.5, which matters a lot on a $20/month plan. - **Stripped thinking tokens break caching.** By default OpenAI removes prior-turn thinking tokens on the next user message, causing a cache miss. For Unify, tool-call outputs dwarf the ~10K thinking tokens, so they were repaying full price for everything. A newer API parameter (released about a month before recording) retains them, making turns faster and cheaper; the quality gain was hard to measure across 100–200 examples. - **Distributing warm cache across users.** For big sub-agent fan-outs, the shared expensive prefix (system prompt + tools) is common across users. Unify's prompt cache key = one of 16 hashed user-ID buckets + a random number from 1–30, sized so that roughly 30 × 16 matches peak sub-agent throughput and keys stay warm all day. - **Providers can't solve caching for you.** They lack your inductive bias (same user, same sub-agent batch, same tenant prefixes), and since they charge either way, it falls on the developer. - **Why fork instead of re-prompting a fresh sub-agent.** Summarizing context for a child agent is either lossy or huge (and a cache miss). Hegy's deeper intuition: after a long chat, the model is positioned in exactly the right part of the language distribution, so the next output (e.g., a personalized email to each of 5–20 researched founders) comes out nearly perfect. - **Human-in-the-loop UX.** Exactly-once email sending (pre-existing deliverability infrastructure) is hard and was built before the AI wave. Emails go through a proposal-and-approval artifact pane (similar to Claude's right-side artifacts). Showing all emails in a table proved noisy; reviewing one at a time with full context (recipient, title, company) works better, inspired by Scale's internal "speed audit" hotkey tool. Edits (e.g., highlight a sentence and change it) apply across, say, 100 enrollments. Users typically review the first ~15 emails, give batch-wide feedback, then send all. The personal touch (no em dashes, shared hobbies like surfing) is the rep's real edge. - **Memory design.** Two inputs: (1) a bootstrap step that ingests a connected Gmail inbox to learn how the rep writes and talks about their product, and (2) ongoing proposals extracted roughly every third message. Memories live in Postgres as natural-language values under a fixed set of 6–7 categories (rep email voice, rep attributes, company attributes, soft preferences, hard/direct preferences, plus "other"). The agent can't invent keys, because each added dimension of self-management multiplies complexity. A background cron consolidates draft and active memories using explicit operations (promote, merge into a new memory, deprecate, supersede, drop) with lineage kept for observability. Anything a user explicitly says to remember becomes a first-class "direct preference" (e.g., "always talk to me like a pirate"). Memories aren't shown in a UI; users can ask the agent. - **Skills vs. memory.** Unify curates "dozens and dozens" of skill files internally. For company-specific behavior (e.g., how a given Salesforce instance works), Hegy leans toward memory over user-authored skill files, since non-engineers don't like writing runbooks. - **Spend controls.** Plans are $20 or $60 per seat per month with pooled credits for overage; per-user guardrails are coming. Trust is earned: Hegy spent ~$7,000–8,000 on LLMs in a month and the next-highest engineer ~$5,500, both justified, but others would start at $500/month and move to $1,000 if it goes well. - **Eval philosophy from self-driving.** The gate for shipping a vision model was a team watching a 1.5–2 hour video of 7-second clips on a projector, in a grid of ~6 model runs (rows) × 5 checkpoints (columns) with the current best at the bottom. Hegy's takeaway: nothing beats looking at 100 or 1,000 examples. - **Unify's eval loop.** Classify every message by user intent (finding people, sending emails, etc.), review filtered slices, then pull traces into "DQA sets" (dedicated QA sets) covering specific distributions: hero use cases, prompt injection, unexpected Spanish mid-conversation, and so on. They iterate on one set at a time in LangSmith. Example: a data vendor the agent called ~500 times when asked for 10 companies got a 40-example DQA set, measured on tool-call count, trace efficiency, customer credit cost, and LLM cost. Evals use pass@k with 5 runs per trace. - **Judges and simulated users must come from a different model family.** If the agent runs GPT-5.4, the judge or simulated user should be an Anthropic model, to avoid overlapping distributions and agent "groupthink." You want it almost adversarial. - **Testing side-effecting and paid APIs.** Email sends are mocked. Data APIs have a replay mode, but replay breaks when a better agent issues different (better) parameters, so they often just pay for real calls; data cost is marginal next to LLM cost. - **Sandbox: "brain and hands" split, no VM.** The agent runs outside the execution environment. Full VMs (e.g., Daytona-style) meant writing tenancy-safe CLIs and scary networking. Instead, Unify adopted the idea behind Monty (an open-source Python interpreter where bound host functions suspend the REPL, hand the function name and args to the host, then resume with the result) and rebuilt it in TypeScript. Tenancy, scoping to user/thread, and billing are injected at that host-function boundary. These REPLs are stateful (notebook-like variables persist across calls) but ephemeral, running in backend workers, so sandbox cost is effectively zero. (The host notes LangChain shipped a similar QuickJS-based capability in Deep Agents for programmatic sub-agent calls.) - **RLMs as a wish list.** Recursive language models enable something like semantic merge sort, e.g., ranking 100 assigned accounts properly instead of the current lossy research-then-scoring-function approach, but they're too expensive to offer customers today. - **How they cut cost 90–95% in the two weeks before launch.** Without it, one message would have exhausted a $20 plan. Levers: replace swarms of sub-agents with a smarter main agent that writes code mapped over the table; trace-driven prompt fixes; removing contradictions across all skill files and the system prompt (each one caused botched tool calls or orderings); moving from GPT-5.5 to GPT-5.4 where possible; eliminating wasted tool calls whose results go unused (the number-one metric to drive down); and adding a robust planning step that pauses, asks clarifying questions, and scouts trajectories (e.g., comparing a high-recall vs. a high-precision data vendor for "30 companies not in my CRM, hiring AI engineers, Series B in the last 2 years"). - **Prompting rule: give the why, avoid "always/never."** Models follow absolute instructions even in the ~3% of cases where they're wrong, so explain reasoning instead. - **Model choice.** Unify runs on OpenAI (its first investor), with Azure capacity as an incident fallback, chosen for price-performance: users get 30–50 useful messages rather than one excellent but expensive message. In Q4 of the prior year they brought the old research agent below 1 cent per run and cut customer credit prices 10x; tool calls now dominate that agent's cost. Open-source models were less tool-efficient, so even a 10x token discount didn't pay off net, though Hegy is hearing good things about GLM 5.2. Fable uses far fewer tokens than Sonnet 5, so per-task cost isn't obvious from list price, which only rigorous evals can settle. ## Actionable Takeaways 1. **Treat prompt caching as core infrastructure.** Use the OpenAI Responses API, pass your own prompt cache key, stay under ~15 requests/second per key, and build keys from a hashed user bucket (Unify uses 16) plus a random suffix (1–30) sized to your peak sub-agent throughput. Enable the parameter that retains thinking tokens across turns. 2. **Cap fork fan-out.** Fork sub-agents from the previous response ID in batches of about 10–15. Around 20 risks a full-context cache miss. Use child sub-agents (fresh context) when inherited context isn't needed. 3. **Expose tables to the agent as code, not text.** Wrap stored data in a pandas-like class with ~10 operations (filter, map rows, add/delete rows, fetch, reorder/resort columns, change types), and model sub-agents as async function calls returning job handles. 4. **Make expensive calls the fallback.** In row maps, waterfall cheap APIs first and invoke an LLM sub-agent only when they're exhausted. Do the per-row math against your plan price. 5. **Sandbox via host-function interception instead of VMs.** Use a Monty-style interpreter (or QuickJS in TypeScript) that suspends on bound functions, then enforce tenancy, scoping, and billing in the host before resuming. 6. **Structure memory with fixed categories and a consolidation cron.** Over-propose memories every ~3 messages, then run a background job that must emit explicit ops (promote, merge, deprecate, supersede, drop) with lineage. Always store explicit "remember X" requests as hard preferences. 7. **Run evals in this order:** (a) tag messages by user intent and hand-review 100–1,000 examples per slice; (b) pull failing traces into a focused DQA set (e.g., 40 examples); (c) iterate on one set at a time, tracking tool-call count, trace efficiency, credit cost, and LLM cost; (d) use pass@k with 5 runs per trace. 8. **Use a different model family for LLM judges and simulated users** than the agent under test (e.g., GPT agent, Anthropic judge). 9. **Mock side-effecting actions** like email sends. For paid data APIs, accept the cost of live calls when replay can't reflect better agent behavior. 10. **Lint your prompts.** Remove contradictions across the system prompt and every combination of skill files, ban stylistic artifacts you don't want in output (e.g., em dashes), and replace "always/never/do not" rules with explanations of why. 11. **Add an upfront planning step** that pauses, asks the user a few clarifying questions, and scouts a couple of tool trajectories (recall vs. precision) before executing. 12. **Design review UX one item at a time** with full context and batch-applicable edits. Expect users to review ~15 items, give feedback, then approve the rest. 13. **Gate per-user spend by earned trust**, e.g., start at $500/month and raise to $1,000 after it goes well. ## Notable Quotes > "It's really important that you get these cache hits or otherwise you're just you're cooked by default." — Connor Hegy > "It can't be built into the providers... because they don't know the distribution that's coming in." — Connor Hegy > "When you have an LLM as a judge... it can never be the same distribution as the original model." — Connor Hegy > "There's just no better eval than looking at a hundred examples or a thousand examples." — Connor Hegy > "Engineers love writing things like skill files... But most other people don't." — Connor Hegy > "Our formulation is that a sub agent is just a function call." — Connor Hegy > "If you say always blank or do not blank in the 3% of cases where that's wrong, it'll never do it." — Connor Hegy --- *You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).* *Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*