Skip to content

feat: Converse API Adapter: support upstream tokenization - #479

Open
AlexFoxalt wants to merge 2 commits into
developmentfrom
feat/support-converse-tokenization
Open

feat: Converse API Adapter: support upstream tokenization#479
AlexFoxalt wants to merge 2 commits into
developmentfrom
feat/support-converse-tokenization

Conversation

@AlexFoxalt

@AlexFoxalt AlexFoxalt commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

fixes #475

Summary

  • Added Converse /tokenize integration coverage for mixed request and string inputs across default and upstream tokenizer model groups.
  • Routed models without Bedrock Runtime CountTokens support back to default Converse tokenization.
  • Updated README table

@AlexFoxalt
AlexFoxalt requested a review from adubovik as a code owner August 12, 2026 11:39
else None
)
condition = configuration is not None and (
"performanceConfig" in configuration

@adubovik adubovik Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dry it

Comment thread README.md
|Anthropic|Claude 5 Opus|anthropic.claude-opus-5|(text/image/document)-to-text|mantle: 🟢 \| legacy: 🟡|mantle: 🟢 \| legacy: 🟡|✅|✅|Anthropic SDK/Converse API|
|Anthropic|Claude 5 Sonnet|anthropic.claude-sonnet-5|(text/image/document)-to-text|mantle: 🟢 \| legacy: 🟡|mantle: 🟢 \| legacy: 🟡|✅|✅|Anthropic SDK/Converse API|
|Anthropic|Claude 5 Fable|anthropic.claude-fable-5|(text/image/document)-to-text|mantle: 🟢 \| legacy: 🟡|mantle: 🟢 \| legacy: 🟡|✅|✅|Anthropic SDK/Converse API|
|Anthropic|Claude 5 Fable|anthropic.claude-fable-5|(text/image/document)-to-text|mantle: 🟢 \| legacy: 🟢|mantle: 🟢 \| legacy: 🟢|✅|✅|Anthropic SDK/Converse API|

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right - the legacy still doesn't support the precise tokenisation, because the PR didn't do anything with respect to the legacy client.

_DEFAULT_CONVERSE_TOKENIZER_DEPLOYMENTS,
ids=lambda deployment: deployment.value,
)
async def test_default_converse_tokenization_with_mixed_inputs(

@adubovik adubovik Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added tests are irrelevant to the PR.
In other words, they would have passed on the development too.

request.original_request
),
request=request if isinstance(request, Request) else None,
request=request

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it work properly, we need to create an adapter for each Chat Completions request within TokenizeRequest, instead of reusing the same adapter for all sub-requests.

The same applies to the truncate_prompt request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude: support precise token counting via Converse API

2 participants