Repository navigation
Report a failed turn's tokens as None, not 0 - #12
Merged
Merged
Conversation
…lockers TurnRecord.input_tokens and output_tokens are now int | None, and None for a call that raised before answering. 0 read as "measured, and free", against the rule that None means "not reported". It changes a public model, so it ships in 0.6.0 with the other observer changes rather than in a later breaking release. BACKLOG: items 5 and 6 are done (Dependabot PR 10 and the main merge landed), so nothing blocks 0.6.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
A failed model call's
TurnRecordnow reports its tokens asNone(not reported) instead of0, and the BACKLOG release blockers are closed.Why
The project rule is that
Nonemeans "not reported", never zero. A call that raised before answering has no usage to read, but the timeline gave it0input and0output tokens. That reads as "measured, and free", so anyone summing the timeline couldn't tell a failed call from a cheap one without also checkingerror_type.TurnRecordis public (it's in__all__), so changing the field types is breaking. 0.6.0 already changesLoopObserver, so shipping this now avoids a second breaking release (BACKLOG item 5).Changes
summary.py:TurnRecord.input_tokensandoutput_tokensareint | None, withNoneas the default.loop.py:_add_turnfillsNonewhen there is no response.tests/test_summary.py: the failed-call timeline test asserts both fields areNone.[Unreleased]"Changed" entry tells code that sums the timeline to skipNone.docs/api/summary.mdanddocs/guides/summaries.mddescribe theNonetokens.BACKLOG.md: items 5 and 6 are removed. Item 6 was the Dependabot PR 10 andmainmerge, both done. The "Must land before 0.6.0" section now lists nothing open, and keeps the optional note about theanthropic>=1.0floor.No hand-written
LoopObserveris affected: this changes a summary model, not an observer hook.🤖 Generated with Claude Code