Skip to content

[feat] synthpanel cost summary — standalone cost report for any past run #306

@openclaw-dv

Description

@openclaw-dv

Why

`synthpanel` already tracks per-turn cost (`src/synth_panel/cost.py`) and emits a summary at the end of `panel run`. But after-the-fact, you can't easily say "how much did all my runs from last week cost?" without scripting around the JSON output.

A `cost summary` subcommand fills that gap:

```bash
$ synthpanel cost summary --since 2026-04-01
Total: $4.27 across 28 runs
By model:
claude-3-5-sonnet-20241022 $2.18 (15 runs, 1840 turns)
gpt-4o-mini $0.34 (8 runs, 980 turns)
gemini-1.5-flash $1.75 (5 runs, 2100 turns)
By month:
2026-04 $4.27
```

Sketch

```bash
synthpanel cost summary # all-time
synthpanel cost summary --since 2026-04-01 # date filter
synthpanel cost summary --by model # group by model (default; consider 'run' too)
synthpanel cost summary --format json # for piping
synthpanel cost summary --runs-dir # override default runs root
```

Investigate

  • `src/synth_panel/cost.py` — primitives
  • `src/synth_panel/persistence.py` — how runs are saved/loaded
  • The default checkpoint root: `default_checkpoint_root` from `checkpoint.py` is probably the right runs-dir default
  • Each run probably has a `run.json` or `metadata.json` with the final cost — load that, don't re-aggregate per-turn

Edge cases

  • Runs that were aborted mid-flight: include partial cost; flag as `(partial)` in output
  • Runs with mixed providers (ensemble mode): break out by provider in the by-model view
  • Runs older than the current schema version: skip + warn count at the bottom

Test plan

  • Fixture: 3 fake runs with known per-run costs
  • Test that `cost summary` aggregates correctly
  • Test `--since` filter
  • Test `--format json` produces parseable output

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions