Commit graph

10 commits

Author SHA1 Message Date
Resham Joshi
efbc0db4f9 fix(why): normalise token counts before picking the tier
calculateCost clamps negative and non-finite counts to zero before it sizes
the prompt, so the tier prompt for a slice does the same; otherwise a corrupt
negative count could price the parts in a lower tier than the call.
2026-11-06 05:48:31 -08:00
Resham Joshi
8883af69f4 fix(why): count one-hour cache writes in the tier prompt
calculateCost tiers on the larger of the cache write and its one-hour part,
so a slice priced for a call whose prompt is mostly one-hour writes has to
use the same size.
2026-11-06 04:45:34 -08:00
Resham Joshi
f7138de0da fix(why): price token classes at the call's long-context tier
The per-class split, the hand-back, cache saving, carry and prefix estimates
and the one-tier-down reprice priced without the provider and on a slice of
the prompt, so Claude calls above the long-context threshold split into parts
that added up to a fraction of the call cost. Each slice now takes the tier
its whole call's prompt decides.
2026-11-06 04:34:19 -08:00
Resham Joshi
64d1a6985f
fix(sessions): keep the 0.9.27 step shape (#1883) 2026-11-05 18:44:42 +01:00
Resham Joshi
005f8bf2d4
fix(sessions): keep the --why payload under the desktop's 16 MiB pipe (#1881)
Every subagent's step list ships with the session since the agents view,
so a session with 863 helpers grew from 10.8 MiB to 42.4 MiB and the
desktop refused it. Steps now leave out default fields (isError false,
answer false, empty detail, calculated basis), the unused context delta,
and round the cached share. Past a 12 MiB budget the JSON drops whole step
lists, cheapest helper first and then prompts, with a truncatedSteps count
the Inspect, Agents and Story views show.
2026-11-05 18:02:10 +01:00
Resham Joshi
0de7efbc0a
feat(desktop): story view that tells a prompt in plain sentences (#1879)
* feat(desktop): inspect view for a prompt with request cards and insights

An open prompt now reads as one card per model request, newest first, with
the tool calls each request asked for nested under it. Each card shows the
request number and model, tokens in, out and cached share, what the request
did (asked for tool calls or wrote the answer), its duration against the
prompt's longest step, and its output tokens and cost. Tool rows show the
command or target, duration, the context the result added, a parallel label
when one message asked for several calls, and a muted failed state. A search
field and an All / Model / Tools switch narrow the list, and any card or tool
opens the existing step detail.

Above the cards a summary line and an insights strip name the slowest and the
costliest request, the tool that added the most context, how the tool calls
ran, and failed steps when there are any. Rows that cross the existing
slow-call and carried-result thresholds lead. The two-lane waterfall is gone:
the cards carry the same timing.

The session payload gains the fields this needs, computed at serve time:
each tool step names the model step that asked for it, a parallel position
and its result size; each model step carries its cached share, the context
delta to the next request, its tool call count, its cost basis and whether
it wrote the answer.

* fix(desktop): one place for out tokens on a request card

The request card showed output tokens twice, in the meta line and as a pill. The pill is gone; the meta line keeps the count and the dollar pill stays.

* feat(desktop): agents view with each subagent's lifecycle and cost by agent

* feat(desktop): story view that tells a prompt in plain sentences

* fix(desktop): story wording and copy feedback
2026-11-05 16:44:45 +01:00
Resham Joshi
7103a93778
feat(desktop): agents view with each subagent's lifecycle and cost by agent (#1878)
* feat(desktop): inspect view for a prompt with request cards and insights

An open prompt now reads as one card per model request, newest first, with
the tool calls each request asked for nested under it. Each card shows the
request number and model, tokens in, out and cached share, what the request
did (asked for tool calls or wrote the answer), its duration against the
prompt's longest step, and its output tokens and cost. Tool rows show the
command or target, duration, the context the result added, a parallel label
when one message asked for several calls, and a muted failed state. A search
field and an All / Model / Tools switch narrow the list, and any card or tool
opens the existing step detail.

Above the cards a summary line and an insights strip name the slowest and the
costliest request, the tool that added the most context, how the tool calls
ran, and failed steps when there are any. Rows that cross the existing
slow-call and carried-result thresholds lead. The two-lane waterfall is gone:
the cards carry the same timing.

The session payload gains the fields this needs, computed at serve time:
each tool step names the model step that asked for it, a parallel position
and its result size; each model step carries its cached share, the context
delta to the next request, its tool call count, its cost basis and whether
it wrote the answer.

* fix(desktop): one place for out tokens on a request card

The request card showed output tokens twice, in the meta line and as a pill. The pill is gone; the meta line keeps the count and the dollar pill stays.

* feat(desktop): agents view with each subagent's lifecycle and cost by agent
2026-11-05 15:54:32 +01:00
Resham Joshi
f96b46d8cd
feat(desktop): inspect view for a prompt with request cards and insights (#1877)
Some checks are pending
CI / semgrep (push) Waiting to run
macOS Menubar CI / test (push) Waiting to run
Tests / test-platforms (macos-latest) (push) Waiting to run
Tests / test (22) (push) Waiting to run
Tests / test (22.15.0) (push) Waiting to run
Tests / test (24) (push) Waiting to run
Tests / test (26) (push) Waiting to run
Tests / test-platforms (windows-latest) (push) Waiting to run
Tests / desktop (push) Waiting to run
Tests / vscode (push) Waiting to run
Windows Menubar CI / check (ubuntu-latest) (push) Waiting to run
Windows Menubar CI / check (windows-latest) (push) Waiting to run
* feat(desktop): inspect view for a prompt with request cards and insights

An open prompt now reads as one card per model request, newest first, with
the tool calls each request asked for nested under it. Each card shows the
request number and model, tokens in, out and cached share, what the request
did (asked for tool calls or wrote the answer), its duration against the
prompt's longest step, and its output tokens and cost. Tool rows show the
command or target, duration, the context the result added, a parallel label
when one message asked for several calls, and a muted failed state. A search
field and an All / Model / Tools switch narrow the list, and any card or tool
opens the existing step detail.

Above the cards a summary line and an insights strip name the slowest and the
costliest request, the tool that added the most context, how the tool calls
ran, and failed steps when there are any. Rows that cross the existing
slow-call and carried-result thresholds lead. The two-lane waterfall is gone:
the cards carry the same timing.

The session payload gains the fields this needs, computed at serve time:
each tool step names the model step that asked for it, a parallel position
and its result size; each model step carries its cached share, the context
delta to the next request, its tool call count, its cost basis and whether
it wrote the answer.

* fix(desktop): one place for out tokens on a request card

The request card showed output tokens twice, in the meta line and as a pill. The pill is gone; the meta line keeps the count and the dollar pill stays.
2026-11-05 14:10:28 +01:00
Resham Joshi
d3fecffa9a
feat(sessions): fold subagent sessions into their parent row (#1690)
* feat(sessions): fold subagent sessions into their parent row

The default sessions list (table, JSON, TUI, contributions, desktop) now shows
one row per parent session with its provider-recorded subagents summed in and
listed under subagents. Grouping reuses the work-unit resolver, so only rows
move; totals are unchanged. --by-work-unit keeps the flat rows.

* test: reconcile the session diagnosis with the folded sessions row

* fix(sessions): find and open a parent row by its subagents, count subagents apart from top-level rows
2026-10-08 06:27:58 +02:00
Resham Joshi
e42f1e5db3
Explain why one session cost what it did (CLI + app session view) (#1645)
* feat(sessions): explain why one session cost what it did

`codeburn sessions --id <id> --why` reads one Claude Code transcript on
demand and returns where the money went: a verdict, findings ranked by
dollars, spend by prompt with helper (sub-agent) cost stacked, and every
prompt's model calls and tool steps with timing, cost parts and step detail.
Money comes from the parser's own dedupe, turn grouping and calculateCost,
so the session total matches its `sessions` row.

The desktop app opens this as a focused session view when a Claude Code
session is clicked. Transcript content is read on demand only: never cached,
never routed through serve's output memo, never synced or sent in telemetry.

* fix(sessions): audit fixes for the session cost view

Recovery after a failed step stays inside its prompt; neutral note when the
view and the row differ (forked/resumed transcripts); starting-context
estimate compares against the cached prefix; local dates with the end date
when the session spans days; idle gaps that end with a helper reporting back
say so; savings are the difference of the shown figures; singular counts;
more secret patterns (sk_live_/sk_test_, aws_secret_access_key, URL
credentials); a note when the prompt count differs from the row's turns.
2026-10-06 11:49:58 +02:00