Repository navigation
feat(observability): record how long each model call took and how often it was retried - #229
Merged
Merged
Conversation
…en it was retried Closes #128
This was referenced Sep 22, 2026
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.
Closes #128
ChatModeltimes every model call, retries included, and the pipeline times the run from reading history to the last model call. The summary shows each operation's total and its longest call - one slow call and uniformly slow calls call for different fixes - and the run's total next to its tokens.HttpClientthey are given. ADelegatingHandlerunder each client (ModelRequestCountingHandler) reports every request to a counter that flows with the call's async context (Core/Llm/ModelCallAttempts); requests beyond the first are retries. No provider type is named in the domain, and a client Chartula did not build reports nothing, which reads asnot observed, never as zero.calls(which counts answers) and out of the unreported-usage lower bound.HttpClienthas an infinite timeout, as the SDKs' own clients do (checked by reflection); both SDKs still enforce their own timeout through it (checked with a slow stub: OpenAINetworkTimeoutand AnthropicTimeoutboth fire at 1 s).LlmCallrecord:IRunMetrics.RecordLlmCalltakes one record (tokens, duration, attempts, failed) instead of loose counts, so the next usage fields (reasoning and cached tokens) are additions, not signature changes.failedCalls,durationSeconds,longestCallSeconds,retries(left out when not observed) per operation, anddurationSecondsfor the run. Additive underschemaVersion: 1; a record written before reads with zeros.run-metrics.md(new "When a run was slow"),run-record.md.parkedremoved from [Feature] Record the duration and the retries of every model call in the run metrics #128.Verified end to end: the release binary against a local OpenAI-compatible fake that answers the first request with 503 and the next after 1.5 s:
Tests:
ModelCallTimingTests(late answer, failed call, retries from reported requests, not observed without a transport),ModelRequestCountingTests(real Anthropic and OpenAI SDKs retrying once through the handler, first-time answer is 0 not unknown, infinite client timeout),RunMetricsTests,RunReportFormatterTests,RunRecordJsonSerializerTests(fields, omission, older records),ReleasePipelineMetricsTests(run duration); full suite 715 passing, build anddotnet formatclean.