Skip to content

Report a failed turn's tokens as None, not 0 - #12

Merged
achildress83 merged 1 commit into
mainfrom
feature/failed-turn-tokens-unreported
Oct 19, 2026
Merged

achildress83 merged 1 commit into
mainfrom
feature/failed-turn-tokens-unreported

Conversation

@achildress83

Copy link
Copy Markdown
Contributor

What

A failed model call's TurnRecord now reports its tokens as None (not reported) instead of 0, and the BACKLOG release blockers are closed.

Why

The project rule is that None means "not reported", never zero. A call that raised before answering has no usage to read, but the timeline gave it 0 input and 0 output tokens. That reads as "measured, and free", so anyone summing the timeline couldn't tell a failed call from a cheap one without also checking error_type. TurnRecord is public (it's in __all__), so changing the field types is breaking. 0.6.0 already changes LoopObserver, so shipping this now avoids a second breaking release (BACKLOG item 5).

Changes

  • summary.py: TurnRecord.input_tokens and output_tokens are int | None, with None as the default.
  • loop.py: _add_turn fills None when there is no response.
  • tests/test_summary.py: the failed-call timeline test asserts both fields are None.
  • Docs: a CHANGELOG [Unreleased] "Changed" entry tells code that sums the timeline to skip None. docs/api/summary.md and docs/guides/summaries.md describe the None tokens.
  • BACKLOG.md: items 5 and 6 are removed. Item 6 was the Dependabot PR 10 and main merge, both done. The "Must land before 0.6.0" section now lists nothing open, and keeps the optional note about the anthropic>=1.0 floor.

No hand-written LoopObserver is affected: this changes a summary model, not an observer hook.

🤖 Generated with Claude Code

…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>
@achildress83
achildress83 merged commit fdd23f0 into main Oct 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant