Track LLM token usage in reports#244
Open
HexSleeves wants to merge 1 commit into
Open
Conversation
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.
Motivation
rawpayload).Description
LLMCallRecordandllm_call_record()defaults:input_tokens,output_tokens, andtotal_tokens.with_structured_output(..., include_raw=True)and unwrap{"raw","parsed","parsing_error"}responses, extracting usage fromraw.usage_metadata(supportsinput_tokens/output_tokensandprompt_tokens/completion_tokensvariants) and preserving parsing-error behavior.run_batches) and async (arun_batches) paths (including non-structured raw responses), and propagateanalyzer.llm_usageinto node-levelllm_call_logentries (success and failure).llm_call_logtoken counters into report JSON metadata undermetadata.llm_usagewhile keeping existing metadata intact.include_raw=Trueso local/CLI providers exposerawusage without changing parser expectations.include_raw=Trueparsing, and metadata aggregation; closes feat: expose LLM token usage in JSON report output #242.Testing
ruff format .andruff check .with no issues.pytest -q: all tests passed (1261 passed, 12 skipped, 34 deselected, 6 xfailed).mypy srcwas executed and reported pre-existing typing issues in unrelated modules; no new type regressions introduced by these changes (mypy warnings are repository pre-existing and not caused by this PR).