Collect costs for dispatched model attempts

This commit is contained in:
2026-11-22 18:27:01 +00:00
parent cd0e1f5d39
commit 81a2a7591d
9 changed files with 129 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ Timeout attribution is finalized and the child scope released before terminal
delivery, so observer latency cannot change the already selected outcome.
Prepared-content notification is a separate opt-in callback, not an event.
The facade masks inherited recorder and prepared-claim state when entering
The facade masks inherited recorder, cost, and prepared-claim state when entering
preparation or execution. Delegated calls from an injected collaborator retain
the caller's cancellation, deadline, and unrelated context values, but do not
reuse the enclosing invocation's accounting. Ordinary runs compose the request
@@ -56,6 +56,11 @@ attempts above the first in a generation, and repair generations with at least
one dispatch. A terminal event is an aggregate and must not be added to its
attempt events.
The generation coordinator resolves cost once per dispatched attempt and adds
it to invocation-local accounting independently of event delivery. A recorder
can read that same accumulator at termination; groups merge first terminal
costs independently of terminal coverage.
Reasoning counts use the same per-field rules and are a subset of completion
tokens. The public cache-hit helper derives a ratio from complete, consistent
summed input and cache-read counts; it does not aggregate ratios or use writes.