Skip to content
GitHub (opens in a new tab)

RunCost

What one agent run has spent against its cap, live: a credit bar with a tick where the run pauses, and Raise cap near it.

stableOrganismcontracts/runcost.json

Preview

RunCost

What one agent run is costing as it goes. Not plan usage. Not ContextWindow.

Master

Spend ticks up on a kit Meter. A thin tick marks where the run pauses; near it the card warns and offers Raise cap. Raising the cap keeps the tick where it is and the fill eases down to its new share, so there is more room.

Run cost

Running…

Usage

RunCost is one run's spend against its cap. Pass spent and cap as amounts, not a percent, and set status yourself: near-cap and paused show Raise cap, paused shows Resume, done has no actions. Raise cap passes the new cap back; the tick stays at pauseAt% of it. Change pauseAt to move the tick. State words come with an icon, never colour alone. One polite live region announces only near cap, paused at cap and cap raised; translate them with KitLabelsProvider (runNearCap, runPausedAtCap, runCapRaised, runPausesAt).

Do's

  • show what one agent run is costing while it runs
  • warn before a run pauses at its spend cap and offer to raise it
  • a paused run waiting for a bigger cap or a Resume

Don'ts

  • plan or period usage — UsageMeter
  • prompt context in a thread — ContextWindow
  • a run's steps, clock and approvals — AgentMonitor (cost there is one line)
  • setting the cap before a run starts — TaskBrief
<RunCost
  spent={7.35}
  cap={10}
  pauseAt={80}
  currency="USD"
  status="near-cap"
  onRaiseCap={raiseCap}
  onPause={pause}
/>

When to use

  • show what one agent run is costing while it runs
  • warn before a run pauses at its spend cap and offer to raise it
  • a paused run waiting for a bigger cap or a Resume

When not to use

  • plan or period usage — UsageMeter
  • prompt context in a thread — ContextWindow
  • a run's steps, clock and approvals — AgentMonitor (cost there is one line)
  • setting the cap before a run starts — TaskBrief

What an agent reads

import { RunCost } from "agentic-ds-kit";
must
  • section aria-labelledby the h3 title
  • the bar is a kit Meter named with spent / cap and the pause point, e.g. "Run cost: 4.20 of 10.00 credits. Pauses at 80%" (KitLabels runPausesAt)
  • the tick and its Tooltip are aria-hidden; the Meter name already says where the run pauses
  • near cap, paused and done are a word and an icon, not colour alone
  • the number uses kit NumberTransition inside an aria-hidden figures line, so its own live region never reads each spend tick; the Meter's accessible name carries spent / cap
  • one polite role=status live region announces only KitLabels runNearCap, runPausedAtCap (paused below the tick: paused) and runCapRaised(cap), on live changes and never on first load; spend ticks are never announced
  • motion only on live changes, never on first load: the Meter fill eases, the number rolls, running shimmers, the tick pulses once when the fill crosses it and slides when pauseAt changes; prefers-reduced-motion keeps all of them static
defaults
  • pauseAt 80
  • unit credits
  • status running
stops if
  • Do not invent a local CostBar, BudgetMeter or RunBudget
  • Do not pass a percent as spent
  • Do not signal near cap by colour alone
  • Do not make Raise cap a solid primary
  • Do not use raw hex

From contracts/runcost.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
spentnumberYes—Amount spent so far in unit (or currency), not a percent. Without currency, spent and cap share one number of decimals (0–2), e.g. 3.1 / 10.0 credits.
capnumberYes—The run's spend cap. The track runs from 0 to cap.
pauseAtnumberNo80Percent of cap where the run pauses: a thin tick on the track with a kit Tooltip (KitLabels runPausesAt, "Pauses at 80%"). Raising cap keeps the tick at pauseAt% and the fill shrinks to its new share; change pauseAt to move the tick, and it slides there.
unitstringNocreditsWord after the amounts, e.g. "credits". Ignored when currency is set.
currencystringNo—ISO 4217 code, e.g. "USD". Amounts show as money.
statusrunning | near-cap | paused | doneNorunningSet by the caller. running: KitLabels running shimmers. near-cap: KitLabels runNearCap ("Near cap") with a TriangleAlert in status.warningText and icon.warning, and Raise cap. paused: KitLabels paused, Raise cap and Resume; when the fill has reached the tick, a short muted KitLabels runPausedAtCap ("Paused at cap") line too (a manual pause below the tick has none and announces KitLabels paused). done: KitLabels runDone and the final total, no actions.
onRaiseCapfunctionNo—Raise cap: outline neutral sm Button, the main action, shown in near-cap and paused. The caller passes the new cap.
onPausefunctionNo—Pause: ghost neutral sm Button in running and near-cap.
onResumefunctionNo—Resume: ghost neutral sm Button in paused.
  • Component
    →

    UsageMeter

    Plan usage or AI credits against a limit: total, usage by category, daily bars toned against the cap, and a warning near the limit.

  • Component
    →

    ContextWindow

    How full the prompt context is and what uses the space, by segment, with a warning near the limit, Trim oldest and compaction with Undo.

  • Component
    →

    AgentMonitor

    One agent at work: a live clock and running cost lead; finished steps sit in a time strip you can open.

  • Component
    →

    TaskBrief

    The brief a person hands an agent before it plans: a goal, one-line "done when" checks, optional spend, time and step limits, allowed tools, model and check-in level.