fix: report an Anthropic token-count failure as an LLM error instead of an SDK traceback - #168
Open
vitali87 wants to merge 1 commit into
Open
fix: report an Anthropic token-count failure as an LLM error instead of an SDK traceback#168vitali87 wants to merge 1 commit into
vitali87 wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
vitali87
force-pushed
the
fix/count-tokens-errors
branch
from
August 30, 2026 19:15
a9a1b9e to
6f604c5
Compare
vitali87
force-pushed
the
fix/count-tokens-errors
branch
from
August 30, 2026 19:16
6f604c5 to
e3e62c4
Compare
vitali87
force-pushed
the
fix/count-tokens-errors
branch
from
August 30, 2026 19:17
e3e62c4 to
af449a4
Compare
…of an SDK traceback
vitali87
force-pushed
the
fix/count-tokens-errors
branch
from
August 31, 2026 01:10
af449a4 to
fa37abf
Compare
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.
Summary
_count_tokens_anthropiccalledclient.messages.count_tokenswith no error handling. It is the first API call of asplitrun, so a bad key, an unreachable proxy or a rate limit surfaced as a rawanthropic.AuthenticationError/APIConnectionErrortraceback rather than theLLMErrorpath_call_anthropicalready uses.anthropic.APIErroris now wrapped intoLLMError(ErrorMsg.LLM_TOKEN_COUNT_FAILED)at both count call sites (single-shot sizing and chunked overhead). No local fallback estimate: the count uses the same key/host as the planning call, so anything that breaks it breaks the next request too, and the SDK's own retries already absorb transient blips. With #63'sPRSplitErrorguard this becomes a clean red message.Stacked on #146 (stack #81 = #49→#50→#69→#70→#93→#105→#113→#146→this).
Test plan
test_api_failure_is_an_llm_error:APIConnectionErrorfromcount_tokens→LLMErrornaming the detail; fails on the base_count_tokens_openai(tiktoken, local) needs nothing