Description
AnthropicTokenCounter._count_message_estimated does not properly count message content blocks generated by Strands SDK.
To Reproduce
- Wrap bedrock model with HeadroomStrandsModel configured with some transformer that is dependent on exceeding a model_limit threshold and an Anthropic model
- Generate Strands agent from model
- invoke agent with block content
- any transformer that depends on model_limit threshold being exceeded never applies it's transforms due to Anthropic tokenizer never including block contents in token estimate
Expected Behavior
Properly estimates tokens
Actual Behavior
Tokenizer does not account for messages not containing a "type" property leading to not counting message contents in token total.
Code Sample
from os import environ
from strands.models import BedrockModel
from strands.types.content import ContentBlock
from strands.agent import Agent
from headroom import HeadroomConfig
from headroom.config import IntelligentContextConfig
from headroom.integrations.strands import HeadroomStrandsModel
from json import dumps
environ["HEADROOM_MODEL_LIMITS"] = dumps(
{
"anthropic": {
"context_limits": {
"us.anthropic.claude-sonnet-4-6": 200000
}
}
}
)
async def _test():
model = HeadroomStrandsModel(
config=HeadroomConfig(
intelligent_context=IntelligentContextConfig(
enabled=True
)
),
wrapped_model=BedrockModel(
model_id="us.anthropic.claude-sonnet-4-6"
)
)
agent = Agent(
model=model
)
await agent.invoke_async(
[
ContentBlock(
text="Some question" * 1000
)
]
)
# IntelligentContextConfig is never utilized b/c
# token count never includes content / system blocks
Environment
- Headroom version: 0.5.2
- Python version: v3.12.10
- OS: Windows 11
- LLM Provider: Anthropic
Additional Context
Example Strands SDK message block:
{'role': 'user', 'content': [{'text': 'test'}]}
See in debugger image below where will not possibly ever include message content blocks in token count due to type property not existing.

Description
AnthropicTokenCounter._count_message_estimateddoes not properly count message content blocks generated by Strands SDK.To Reproduce
Expected Behavior
Properly estimates tokens
Actual Behavior
Tokenizer does not account for messages not containing a "type" property leading to not counting message contents in token total.
Code Sample
Environment
Additional Context
Example Strands SDK message block:
{'role': 'user', 'content': [{'text': 'test'}]}See in debugger image below where will not possibly ever include message content blocks in token count due to

typeproperty not existing.