Skip to content

A call's estimated cost prices tokens written to a cache at the cache-read rate #50

Open

Description

@aitianshi

Priority

high

Components

  • app/nullius (backend)
  • app/web (routes)
  • templates and static files
  • docs and the site
  • catalogue (benchmarks, agents, capabilities)
  • the standard (ports, kits, relay, runs)
  • CI, workflows and skills

Evidence

app/nullius/standard/relay.py, reading a reply's usage, adds the tokens written to a cache to those read from it:

cache = (u.get("cache_read_input_tokens") or 0) + (u.get("cache_creation_input_tokens") or 0)

and _cost prices all of them at the cache-read rate:

fresh * p["input"] + usage["cached"] * p.get("cached", p["input"]) + usage["output"] * p["output"]

A price row carries cache_write (app/nullius/prices.py, from the list's cache_creation_input_token_cost), which is not used. On Anthropic's prices a cache write costs 1.25 times the input rate and a cache read 0.1 times: tokens written to the cache are counted at a twelfth of their bill. Found by a review of the spending cap, not by a run.

Reproduction

  1. A standard run on a provider whose replies carry cache_creation_input_tokens and no cost of their own, with a model whose price row has cached and cache_write.
  2. Compare a call's cost_usd in its calls.jsonl with the provider's bill for it.

Expected

Tokens written to a cache are priced at cache_write, those read from it at cached.

Acceptance

  • A reply's cache-write tokens are priced at the row's cache_write rate (the input rate when the row has none), apart from its cache-read tokens.
  • A test with a reply carrying both kinds shows the estimate.

Dependencies and related

A run's spending cap (#14, #46) settles a call at this estimate when the reply carries no cost of the provider's own, so on such a provider it can let a run spend past its cap. Placeholder priority: the lowest defensible, it changes a number shown, not what runs.

Activity

  1. self-assigned this
    on Nov 11, 2026
  2. added theissue type on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions