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
Fix test_count_tokens_messages_only integration tests failing across Bedrock, Gemini, and OpenAI model test suites. The tests assert that "native token count" appears in caplog.text, but caplog was empty because the model fixtures were constructed without use_native_token_count=True. Without this flag, count_tokens() early-returns via the heuristic base class path, which never emits the expected debug log.
Added use_native_token_count=True to the model fixtures in all three test classes so the native token counting code path is actually exercised.
Related Issues
Documentation PR
Type of Change
Bug fix
Testing
The fix ensures the test fixtures match the code path the tests are designed to validate. These are integration tests requiring API credentials (AWS, Google, OpenAI) to run end-to-end.
I ran hatch run prepare
Checklist
I have read the CONTRIBUTING document
I have added any necessary tests that prove my fix is effective or my feature works
I have updated the documentation accordingly
I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
My changes generate no new warnings
Any dependent changes have been merged and published
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Issue: tests_integ/models/test_model_anthropic.py has the same bug — the TestCountTokens class at line 187 constructs an AnthropicModel without use_native_token_count=True, yet test_count_tokens_messages_only asserts "native token count" in caplog.text. The same early-return via super().count_tokens() applies in AnthropicModel (line 401 of src/strands/models/anthropic.py).
Suggestion: Add use_native_token_count=True to the AnthropicModel fixture in tests_integ/models/test_model_anthropic.py as well to fix the same issue consistently across all model providers.
The fix is correct and minimal — the model fixtures now match the code path the tests are designed to validate.
Review Details
Missing provider: tests_integ/models/test_model_anthropic.py has the identical bug (asserts on "native token count" without setting use_native_token_count=True). Consider including it in this PR for a complete fix across all providers.
Checklist items: The I ran hatch run prepare and I have read the CONTRIBUTING document boxes are unchecked — please confirm these before merge.
Clean, well-scoped fix — just flagging the missing Anthropic case for completeness.
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
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.
Description
Fix
test_count_tokens_messages_onlyintegration tests failing across Bedrock, Gemini, and OpenAI model test suites. The tests assert that"native token count"appears incaplog.text, but caplog was empty because the model fixtures were constructed withoutuse_native_token_count=True. Without this flag,count_tokens()early-returns via the heuristic base class path, which never emits the expected debug log.Added
use_native_token_count=Trueto the model fixtures in all three test classes so the native token counting code path is actually exercised.Related Issues
Documentation PR
Type of Change
Bug fix
Testing
The fix ensures the test fixtures match the code path the tests are designed to validate. These are integration tests requiring API credentials (AWS, Google, OpenAI) to run end-to-end.
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.