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.jsonUsage
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
| Prop | Type | Default | Description |
|---|---|---|---|
| runId* | string | — | Printed under the barcode, and the barcode is drawn from it. |
| agent* | string | — | The agent that ran, printed large in the header. |
| task | string | — | What the agent was asked to do, one line under its name. |
| date | string | 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. |
| tokensIn | number | — | Input tokens across the run, printed in the summary. |
| tokensOut | number | — | Output tokens across the run, printed in the summary. |
| cachedDiscount | number | 0 | Dollars saved by prompt caching. Printed in accent as a negative line and taken off the total. |
| cachedTokens | number | — | Tokens read from cache, shown in the discount label as "38k tok". |
| durationMs | number | — | 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. |
| warnings | number | 0 | Zero stamps the receipt PASSED; more stamps "2 WARNINGS" in the warning tone. |
| stamp | string | — | Replaces the stamp text, e.g. "Refunded". |
| note | ReactNode | — | 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. |
| intro | boolean | true | Lines print top to bottom on mount and the total rolls up from zero. Skipped with reduced motion. |
| className | string | — | 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";