You'll notice
Token counting now only falls back to gateway sampling on a specific HTTP 501 error.
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.