You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reject non-finite x-credits-remaining values in CreditSink
A non-finite `x-credits-remaining` header value (e.g. `-Infinity`) parsed by
`_capture_credits_remaining` reached `CreditSink` and caused two defects:
- `-inf` later hit `int(remaining)` in the low-credits display branch of
`build_tool_response`, raising `OverflowError` and turning a successful tool
call into a hard error.
- A `nan`/`-inf` recorded first poisoned the running minimum: `value <
self.remaining` is `False` for every later observation, so a genuine low
balance was dropped and the advisory note silently suppressed for the whole
invocation.
Guard at the single chokepoint `CreditSink.record`: non-finite values are now
ignored, enforcing the invariant "remaining is None or a finite float". This
fixes both the crash and the suppression without touching `build_tool_response`.
Add unit tests (non-finite ignored, minimum not poisoned) and an end-to-end
regression test that a non-finite captured header neither crashes nor emits a
note. Bump version to 0.16.0.dev18.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments