Skip to content
TuffTasks, docs and chat for teams and AI agents

Settings & Usage

Run Receipt

What you bought with an agent run, printed as a receipt — steps and tools with cost, tokens, the cache discount, a rolling total, a PASSED stamp and a barcode of the run id.

1 variantMIT

Preview

Agent run receipt

research-agent

Compare EU grid-storage subsidies for the Q1 memo

Nov 13, 2026 · 14:32 UTC

ItemAmount

    Printing…

    Running$0.00

    Installation

    Copies the component into components/ui and installs its dependencies and theme tokens.

    pnpm dlx shadcn@latest add https://tuffui.com/r/run-receipt.json

    Usage

    Pass your own data and wire the callbacks to your agent runtime.

    import { RunReceipt } from "@/components/ui/run-receipt";
    
    // Shown at the end of an agent run, or from the run's page.
    export function RunReceiptCard({ run }: Props) {
      return (
        <RunReceipt
          runId={run.id} // "run_01JD8K3Q7VX2"
          agent={run.agent} // "research-agent"
          task={run.prompt}
          date={new Date(run.startedAt)}
          lines={run.steps.map((s) => ({
            id: s.id,
            label: s.tool ?? `${s.model} · ${s.name}`, // "web_search", "opus-5.5 · synthesize"
            qty: s.calls,
            detail: s.model ? `${k(s.inputTokens)} in · ${k(s.outputTokens)} out` : undefined,
            cost: s.costUsd,
          }))}
          tokensIn={run.usage.input}
          tokensOut={run.usage.output}
          cachedTokens={run.usage.cacheRead}
          cachedDiscount={run.cacheSavingsUsd}
          durationMs={run.durationMs}
          status={run.finished ? "complete" : "running"}
          warnings={run.warnings.length}
          onCopyRunId={(id) => toast(`Copied ${id}`)}
          onShare={(id) => navigator.share?.({ url: `/runs/${id}` })}
        />
      );
    }

    Props

    PropTypeDefaultDescription
    runId*string—Printed under the barcode, and the barcode is drawn from it.
    agent*string—The agent that ran, printed large in the header.
    taskstring—What the agent was asked to do, one line under its name.
    datestring | Date—When the run started. A string prints as is, so the server and the client agree.
    lines*ReceiptLine[]—Steps and tools with their cost, in order. Lines added later print in at the bottom.
    tokensInnumber—Input tokens across the run, printed in the summary.
    tokensOutnumber—Output tokens across the run, printed in the summary.
    cachedDiscountnumber0Dollars saved by prompt caching. Printed in accent as a negative line and taken off the total.
    cachedTokensnumber—Tokens read from cache, shown in the discount label as "38k tok".
    durationMsnumber—Wall-clock time of the run, printed as "4m 12s".
    status"running" | "complete""complete"Running keeps a running total and a Printing… line. Complete prints the summary, the stamp and the barcode.
    warningsnumber0Zero stamps the receipt PASSED; more stamps "2 WARNINGS" in the warning tone.
    stampstring—Replaces the stamp text, e.g. "Refunded".
    noteReactNode—Centered line at the bottom of the receipt.
    onCopyRunId(runId: string) => void—Shows Copy run id. The id is written to the clipboard first, and the button confirms with Copied.
    onShare(runId: string) => void—Shows the Share button.
    formatCost(dollars: number) => string"$0.046"Line items, subtotal and discount.
    formatTotal(dollars: number) => string"$1.39"The rolling total.
    formatDate(date: Date) => string"Nov 13, 2026, 14:32 UTC"Used when `date` is a Date.
    introbooleantrueLines print top to bottom on mount and the total rolls up from zero. Skipped with reduced motion.
    classNamestring—Extra classes for the root element.
    type ReceiptLine = {
      id: string;
      label: string;   // "web_search", "opus-5.5 · synthesize"
      qty?: number;    // printed as ×14 when above 1
      detail?: string; // "61.3k in · 6.8k out"
      cost: number;    // dollars, 1.43
    };
    
    type RunReceiptStatus = "running" | "complete";