# Costs and traces

> What Werker records about a run, what it cost and who changed what, and how far each record has been tested.

Source: https://werker.cloud/docs/costs-and-traces (updated 2026-12-01)

Werker records usage and estimated cost per run, a trace of each model
turn and tool call, an append-only audit log, and metrics per piece of
work. Several of these have been seen only against test data or the
local database. All of it is spike quality.

## Summary of what exists

| Record                    | Question it answers                                       | How far it has been exercised                                                                                    |
| ------------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Usage                     | What did this run spend on models?                        | Built.                                                                                                           |
| Run trace                 | What did this run do, turn by turn?                       | Built. Seen in a browser with made-up rows only, not with a trace from a real run.                               |
| Cost of a unit of work    | What did a step, agent, workflow or factory cost?         | Built. Same as the trace: seen with made-up rows.                                                                |
| Metrics per piece of work | Is the work succeeding, getting dearer, needing a person? | Built. Seen in a browser against the local database's runs.                                                      |
| Audit log                 | Who or what did something, to what, and when?             | Built. Seen recording real runs on Daytona. Signing in and editing through a browser were not tested end to end. |
| Interventions             | How often did a person step in?                           | Built. Tested against a disposable database. The part that shows it on run pages was not seen in a browser.      |
| Scores                    | Did a run do what it should have?                         | Built. No real judge call has been made.                                                                         |
| Visitor analytics         | Who visits, and from where?                               | Built. Not yet seen on a hosted instance.                                                                        |

## Usage per run

When a run finishes, stops or waits for input, the worker stores
input, output and cached tokens per model, and an estimated cost at
the model provider catalogue's prices. The cost is 0 when the
catalogue has no price. A run's page shows this once it has stopped,
and Admin → Usage shows a workspace's last 30 days: per day, per
model, and the runs that spent most. The spend of an attempt that
crashed before its first second was stored is not recorded.

## Run traces

A trace holds one span per model turn and per tool call, with
duration, failure, exit code, token counts and cost. The worker writes
spans while a run is going and again when it ends. The run page's
Trace tab shows cost, tokens, turns and tool calls, where each turn's
time went, a failures-only filter and a drawer for each span.
Observability (`/observability`) adds overview, runs, tools and costs,
over 24 hours, 7, 30 or 90 days.

Secrets such as API keys, tokens and passwords are redacted before
storage, long values are cut, and the model's thinking is never
stored. A missing duration is estimated from the surrounding turn.

## The cost of a unit of work

Cost is shown for a run, a step, an agent, a workflow and a
[factory](factories.md). It has three parts:

- **Model calls:** from the usage records.
- **Sandbox time:** seconds a sandbox ran, times the CPU and memory it
  had, times prices an instance admin sets in Admin → Sandboxes.
- **Service calls:** calls to connected services, times a price per
  call that an admin sets.

A part with no price is shown as seconds or calls with "no price set",
left out of the total, and the total is marked incomplete. Where only
some of it was priced the money is marked `*`.

**Observability → Costs** has a row for each workflow, factory and
agent. It starts with workflows and factories; clear the filter for
agents. A row opens to where its money went and its latest 20 pieces
of work. An agent's spend is also in the workflow or factory it worked
in, so rows do not add up to the total.

A run's page works its cost out from today's prices. Everything else
uses the prices from when the run ended, so a later change does not
alter past work. Prices per workspace are not built.

## Metrics per piece of work

A piece of work is one run of a workflow or agent, or one request to a
factory with every member turn it set off. The same five figures are
on **Observability → Overview** for the workspace, over the range you
pick, and on each workflow's, agent's and factory's own page, over the
last 30 days. They count work that began in that time.

| Figure               | What it is                                                                                    |
| -------------------- | --------------------------------------------------------------------------------------------- |
| Finished             | How many have ended: done, failed or stopped.                                                 |
| Succeeded            | The share of those that are done. Beside it, the judge's pass rate.                           |
| Typical cost         | The median cost of an ended piece of work. "High" is the 90th percentile.                     |
| Typical time working | The median time in model turns and tool calls, added up. Waiting for a person is not counted. |
| Stepped in           | How often [a person stepped in](#interventions), per ended piece of work.                     |

- Each shows the change from the equal period before, but only when
  both ended at least 5 pieces of work.

**Compare by** splits them, for up to 20 rows:

- **Version:** the saved version when the work began, so you can read
  before and after an edit. Editing an agent is a version of the
  agent, not of the workflow it is in.
- **Model:** the model the run was given.
- **Task:** the same text asked again. Different words are a different
  row.

One line gives what 100 and 1,000 more pieces of work would cost at
the average cost so far. A factory also lists its rooms, with what a
typical request in each cost.

Not built: replaying work under another model
([#26](https://github.com/werker-ai/werker/issues/26)), and trend
lines over more than two periods
([#28](https://github.com/werker-ai/werker/issues/28)).

## Versions

Each saved change to an agent, workflow, factory or role preset is
kept as a numbered version with who made it, and can be restored as a
new version. It is tested against a disposable database and in
component tests, and was not seen in a browser.

## The audit log

The audit log is append-only: the app's database role can add and read
events but not change or delete them. It is separate per workspace,
plus instance-level events. It records:

- sign-ins, sign-outs and failed sign-ins;
- changes to connections, members, roles, models, prices, settings,
  agents, workflows, factories and schedules;
- runs queued, stopped, answered, archived and restored, including
  those from schedules and scripts;
- sandbox created, started, stopped and deleted;
- shell commands an agent ran, and service and MCP calls, with status
  and duration.

It never stores keys, passwords or request bodies. It shows in Admin →
Audit and on each run's page, for people with the audit permission.

## Interventions

An intervention is a person answering a question, stopping a run, or
running again after a failure. Only actions by a signed-in person
count; schedules, scripts and edits made afterwards do not. The count
shows on the run page and feeds the metric above.

## Scores

A judge answers questions you set about a sample of finished runs,
pass or fail with one of eight fixed reasons. Three built-in questions
(did it do what was asked, did it report its problems, is the result
grounded) are on at 25 percent, and you can edit them or add more.
Pass rates and failing runs are in Observability → Scores. Judging
cost is kept on the verdict, not in the run's cost.

Not tested: no real judge call has been made.

## Visitor analytics

Werker counts page views without IP addresses, raw user agents or
cookies. A visitor is a daily hash that cannot be linked across days,
so counts are visitor-days. Bots and requests with Do Not Track are
skipped. Instance admins see totals in Admin → Analytics.

## What is not recorded or built yet

- **Trace retention:** not built; traces are kept.
- **Idempotency keys for external actions,** so a step re-run after a
  restart does not repeat them
  ([#16](https://github.com/werker-ai/werker/issues/16)).
- **Factory conversations,** and the role used on each audit event,
  are not recorded.
- **Before and after content** of an edit is in versions, not the
  audit log.
- **Proposed improvements** from low scores and traces are not built;
  nothing changes a definition by itself.
- **Alerts** on falling pass rates, and search of traces beyond recent
  failures.
- **Billing and credits** are not built. See
  [pricing](https://werker.cloud/pricing) and [status](https://werker.cloud/status).
