Track per-run token usage and cost in meta.json#60
Open
RandomOscillations wants to merge 1 commit intomainfrom
Open
Track per-run token usage and cost in meta.json#60RandomOscillations wants to merge 1 commit intomainfrom
RandomOscillations wants to merge 1 commit intomainfrom
Conversation
Thread actual token counts from API responses through provider → facade → reasoning → engine → meta.json. Each provider's simple_call_async now returns (dict, TokenUsage). Two-pass reasoning captures tokens from both pivotal (Pass 1) and routine (Pass 2) calls. The engine accumulates totals across chunks and computes estimated USD cost via pricing.py, writing a cost block to meta.json with per-pass token breakdowns. Closes #59 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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
meta.jsonsimple_call_asyncnow returns(dict, TokenUsage)with real token counts from the API responsepricing.pyChanges
providers/base.py—TokenUsagedataclass, updated abstract signatureproviders/openai.py— Extract usage from Responses API (input_tokens/output_tokens) and Chat Completions API (prompt_tokens/completion_tokens)providers/claude.py— Extract usage fromresponse.usagellm.py— Pass-through tuple return fromsimple_call_asyncmodels/simulation.py— Token fields onReasoningResponsereasoning.py—BatchTokenUsagedataclass, capture tokens in two-pass flow, accumulate inbatch_reason_agentsengine.py— Running totals,_compute_cost()usingpricing.py, writecostblock tometa.jsonmeta.json output
Test plan
ruff checkandruff formatcleanmeta.jsoncontains correctcostblockCloses #59
🤖 Generated with Claude Code