Repository navigation
feat(observability): show the cached input and the reasoning inside a run's tokens - #230
Merged
Merged
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.
Follows #229 (
LlmCallrecord), point 3 of the measurement plan for the provider comparison runsTwo parts of the tokens made visible: cached input (served from the provider's prompt cache, usually billed lower) and reasoning output (spent thinking, billed as output, never in the changelog). Both come from
Microsoft.Extensions.AI'sUsageDetails, so no provider type is named.Checked what each adapter fills, against the real SDKs:
cache_read_input_tokensprompt_tokenscached_tokensreasoning_tokensSame meaning on both: cached is a part of input, reasoning a part of output, so
in / outstay complete totals.Not reported stays unknown: summed over the calls that reported it,
nulluntil one does; the summary saysreasoning not reportedrather than 0, which would claim the model did not think.Cache writes (Anthropic's
cache_creation_input_tokens) are left out: they arrive only under an adapter-specific key, and occur only when caching is requested, which Chartula does not do today.Summary: a
of which N in cached, M out reasoningline under each operation with calls. Run record:cachedInputTokens,reasoningTokensper operation, left out when not reported; additive underschemaVersion: 1.Docs:
run-metrics.md,run-record.md.Verified end to end: the release binary against a local OpenAI-compatible fake reporting both details:
Tests:
UsageDetailTests(real Anthropic and OpenAI adapters),RunMetricsTests(summing with unreported calls),RunReportFormatterTests(detail line, not reported),RunRecordJsonSerializerTests(written and omitted); full suite 721 passing, build anddotnet formatclean.