Skip to content

call log: a whole-body call's end row carries cost but no token counts #345

Closed

Description

@santoshkumarradha

Parent epic: #338

Part of the debug-record epic. Corrected after investigation (PR #364): the record was never lossy; the original measurement filtered the JSON keys and dropped the token fields itself. Every headless end row carries both token figures. The real loss was in the reader, which printed the completion tokens alone as N tok and never the prompt tokens. The sections below are kept as filed; the acceptance is the reader's.

What a debugger hits today

In a headless run on dev, every non-streamed end row (the compile, the grounding pass, the leaf calls, the gate) carries a cost and no prompt or completion token counts. The same log holds forty-two older non-streamed rows that do carry both. The row says how much was paid and not for how many tokens, which is the one figure a person uses to check a bill or a context size.

The law

A finished call's row carries its token counts whenever the provider reported them.

Fix shape

Find where the whole-body path's usage loses its counts between the decode and the record, and fix it there; if the provider genuinely did not report them, the row says nothing, as the emptiness law demands, and the trace body holds the raw usage object so the omission is checkable.

Replication

aforge do "count the lines in notes.txt and write the count to count.txt" --model deepseek/deepseek-v4-flash
aforge logs --tail 12

Today: the compile, ground, leaf and gate end rows show a cost and no token figures.

Acceptance (functional)

  • After the run above, every line aforge logs prints for an end row with a cost shows both figures (N in N out), and they match the raw rows.
  • A row for a provider reply with no usage object shows neither cost nor tokens.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added
    bug
    area:logging
    on Sep 2, 2026
  2. santoshkumarradha commented on Sep 2, 2026

    @santoshkumarradha
    MemberAuthor

    Investigation result (PR #364): the premise of this issue was a measurement error on my side, not a defect in the record. When I printed the headless run's rows I filtered the JSON keys and dropped prompt_tokens, completion_tokens, stream and ttft_ms myself. The lane proved with scripted and real runs that every headless end row carries both token figures, and that every completion is streamed, so there is no whole-body end row with a response on dev.

    What was genuinely lost was in the reader: aforge logs printed the completion tokens alone as N tok and never the prompt tokens, which is the figure a person uses to check a context size. #364 fixes that at the one line builder: 4142 in 304 out 4096 cached $0.0001, each half absent when the row does not carry it.

    Acceptance is unchanged in spirit and now reads: after a headless run, every line aforge logs prints for an end row with a cost shows both figures, and they match the raw rows.

  3. santoshkumarradha commented on Sep 3, 2026

    @santoshkumarradha
    MemberAuthor

    Landed inside #359 (dev 3379e15): the log line shows N in N out (N thinking) N cached $cost, each half absent when the row does not carry it. The record itself was never lossy; see the corrected body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:loggingbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions