When the direct beta.messages.countTokens call fails, Claude Code now checks that the failure is specifically an HTTP 501 before falling back to the gateway sample-count path. If that fallback itself fails, a new error is logged with the underlying failure message.
countTokens now falls back to gateway sampling only on HTTP 501
Token counting now only falls back to gateway sampling on a specific HTTP 501 error.
You'll noticeTier: how much it should matter to you
1Useful: my rating, 1 to 5
1Signal: worth watching, 1 to 5
ElsewhereArea: what it touches
Bug FixesKind: in v2.1.261,
Bug FixesSection of the release