fix(v1): fall back to provider usage for dashboard token counts - #1627
Merged
Conversation
The --rich dashboard's per-rollout "X/Y tokens" was derived from the branch's token-id lengths, which are 0 for endpoints that don't return token ids (e.g. plain OpenAI completions) — so eval rows showed "0/0 tokens". Carry the response's usage onto the assistant node (transient, excluded from wire/disk, like the multimodal sidecar) and fall back to it when token ids are absent: input = final turn's usage.prompt_tokens, output = sum of usage.completion_tokens across turns. The renderer path (token ids present) is unchanged. Regression from #1606, which switched _tokens off response.usage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mikasenghaas
marked this pull request as ready for review
June 11, 2026 07:45
Contributor
ApprovabilityVerdict: Approved This is a self-contained display fix that adds fallback token counts for the dashboard when endpoints don't return token IDs. The new field is explicitly excluded from serialization (transient), and the logic changes are limited to UI display code with no impact on core runtime behavior. You can customize Macroscope's approvability policy. Learn more. |
pull Bot
pushed a commit
to Stars1233/verifiers
that referenced
this pull request
Jun 23, 2026
…eIntellect-ai#1627) The --rich dashboard's per-rollout "X/Y tokens" was derived from the branch's token-id lengths, which are 0 for endpoints that don't return token ids (e.g. plain OpenAI completions) — so eval rows showed "0/0 tokens". Carry the response's usage onto the assistant node (transient, excluded from wire/disk, like the multimodal sidecar) and fall back to it when token ids are absent: input = final turn's usage.prompt_tokens, output = sum of usage.completion_tokens across turns. The renderer path (token ids present) is unchanged. Regression from PrimeIntellect-ai#1606, which switched _tokens off response.usage. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--richeval dashboard showed0/0 tokensper rollout for endpoints that don't return token ids (e.g. plain OpenAI completions through an inference gateway):_tokensderived its counts from the branch's token-id lengths, which are empty there.usageonto the assistantMessageNodeas a transient (exclude=True) sidecar — same pattern as the multimodal sidecar, never written to wire /results.jsonl.Branch.num_prompt_tokens/num_completion_tokens(usage-based) and have_tokensfall back to them when token ids are absent. Semantics preserved: input = the final turn's prompt tokens (full final context), output = the sum of completion tokens across every turn._tokensoffresponse.usageonto token-id lengths.Verification
Synthetic OpenAI-style trace (usage reported,
response.tokens=None) driven through the realadd_turn→_tokens:0/0 tokens100/20 tokens— input = final turn'susage.prompt_tokens, output = summedusage.completion_tokensruff checkandruff format --checkpass on the three changed files.Note
Fall back to provider usage for token counts in dashboard when token IDs are unavailable
usagefield toMessageNodein graph.py to store provider-reported token usage for assistant responses (excluded from serialization); populates it inadd_turn.num_prompt_tokensandnum_completion_tokensproperties toBranchin trace.py that derive counts from provider usage when token IDs are absent._tokenshelper in dashboard.py to prefer token-ID-derived counts but fall back to provider usage, returning an empty string when both are missing.Macroscope summarized 76d9e9c.
Note
Low Risk
Display-only fallback in the live dashboard; usage is excluded from persistence and token-id counts still win when present.
Overview
Fixes the
--richeval dashboard showing0/0 tokenswhen the inference endpoint returns providerusagebut no token ids (e.g. plain OpenAI completions).MessageNodenow keeps a transientusagesidecar (same pattern as multimodal data,exclude=True), set inadd_turnfromresponse.usage.Branchaddsnum_prompt_tokens(last assistant turn’s reported prompt) andnum_completion_tokens(sum across turns)._tokensprefers existing token-id-basedprompt_len/completion_len, falls back to those usage properties, and omits the token column when both are zero.The renderer path with token ids is unchanged; usage is display-only and not persisted to wire /
results.jsonl.Reviewed by Cursor Bugbot for commit 76d9e9c. Bugbot is set up for automated code reviews on this repo. Configure here.