{% if not tokenscape_ctx.has_data %}

{% if tokenscape_ctx.error %}Tokenscape unavailable. {{ tokenscape_ctx.error }}{% else %}No assistant turns yet — nothing to plot.{% endif %}

{% else %}

Where the money went · ${{ "%.2f"|format(tokenscape_ctx.total_cost) }}

Each stripe is one piece of context: it loads once, then drags along in the cache every turn until the session ends (or /compact wipes it). Later content stacks on top from the turn it arrived. Area = dollars — the stripe's label shows the total it cost. Only pieces worth ≥ 1/20 of the bill get their own stripe.

{% set bs = tokenscape_ctx.bill_split %}

Bill by token type: cache reads ${{ "%.2f"|format(bs.cache_read) }} ({{ "%.0f"|format(tokenscape_ctx.cache_read_pct) }}%) · cache writes ${{ "%.2f"|format(bs.cache_write) }} · output ${{ "%.2f"|format(bs.output) }} {% if bs.subagents > 0.005 %} · subagents ${{ "%.2f"|format(bs.subagents) }}{% endif %} {% if bs.uncached_input > 0.005 %} · uncached input ${{ "%.2f"|format(bs.uncached_input) }}{% endif %}

Per-turn spend (exact)

Same data, no smoothing: every column is one assistant turn and sums to what that API call actually cost. New content pays the cache-write rate when it arrives; persisting content pays the cheap cache-read rate. Tall red columns are subagent runs; dotted vertical lines are idle gaps where the whole cache was re-billed.

{% for s in tokenscape_ctx.swatches %}{{ s.label }}{% endfor %}

{{ tokenscape_ctx.turn_count }} assistant turns {% if tokenscape_ctx.compact_count %} · {{ tokenscape_ctx.compact_count }} /compact{% endif %} {% if tokenscape_ctx.ttl_break_count %} · {{ tokenscape_ctx.ttl_break_count }} cache rebuild{{ 's' if tokenscape_ctx.ttl_break_count != 1 else '' }}{% endif %}

{% if tokenscape_ctx.subagent_runs %}

Subagents — what each agent read

{% for run in tokenscape_ctx.subagent_runs %}

{{ run.label }} · ${{ "%.2f"|format(run.cost) }} · {{ run.turn_count }} turns{% if run.models %} · {{ run.models|join(', ') }}{% endif %}

{% endfor %} {% if tokenscape_ctx.subagent_runs_hidden.count %}

+ {{ tokenscape_ctx.subagent_runs_hidden.count }} smaller runs · ${{ "%.2f"|format(tokenscape_ctx.subagent_runs_hidden.cost) }} combined

{% endif %} {% endif %}

Cost by category

{% for c in tokenscape_ctx.category_totals %} {% endfor %}
Category Cost Share
{{ c.label }} ${{ "%.2f"|format(c.cost) }} {{ "%.1f"|format(c.pct) }}%
{% if tokenscape_ctx.top_bands %}

Most expensive single pieces of context

Ranked by total dollars caused — cache-write on arrival plus cache-read every turn it persisted. The top one is what to investigate first.

{% for r in tokenscape_ctx.top_bands %} {% endfor %}
# What Category Cost ≈ tokens arrived turn persisted turns share of bill
{{ loop.index }} {{ r.label }} {{ r.category }} ${{ "%.2f"|format(r.cost) }} {{ "{:,}".format(r.tokens) }} {{ r.arrival_turn }} {{ r.persisted }} {{ "%.1f"|format(r.pct) }}%
{% endif %} {% endif %}