Skip to content

[FEATURE] Model Specific Feature Mechanism #780

Description

@dbschmigelski

Problem Statement

Currently, different models on Bedrock and other providers have specific requirements and limitations that can cause runtime failures. For example, DeepSeek R1 has issues with reasoningContent in messages that other models like Claude don't have (as seen in PR #652 ). We need a systematic way to handle these model-specific configurations and requirements.

Proposed Solution

No response

Use Case

The system should implement a configuration registry pattern where model-specific behaviors are defined in external configuration files rather than scattered throughout the codebase with if-statements. This approach would be similar to how the SDK currently handles other features (as seen in various issues like #652, #1053, and #713).

For example, instead of:

if model == "deepseek":
    strip_reasoning_content()
elif model == "claude":
    handle_token_limits()

The system would use a declarative configuration approach where model capabilities and limitations are defined in configuration files, and a single handler processes these configurations. This keeps the core code clean and maintainable while moving model-specific logic to configuration rather than implementation.

This design would align with the SDK's existing architecture while preventing the proliferation of model-specific conditional statements throughout the codebase, as evidenced by the challenges seen in the DeepSeek reasoning content issue (#652) and other model-specific issues in the repository.

Alternatives Solutions

No response

Additional Context

No response

Activity

  1. changed the title [-][FEATURE] Bedrock Model Specific Feature Mechanism[/-] [+][FEATURE] Model Specific Feature Mechanism[/+] on Sep 2, 2025
  2. dbschmigelski commented on Sep 3, 2025

    @dbschmigelski
    ContributorAuthor

    Additional example of model/provider specific logic #630

    model = BedrockModel(
        model_id="openai.gpt-oss-120b-1:0",
        streaming=False,
    )
    

    Strands should know gpt oss must use Converse and automatically use it.

  3. dbschmigelski commented on Sep 3, 2025

    @dbschmigelski
    ContributorAuthor

    Additional example #686 relating to non-claude models and the inclusion of the status field.

  4. matheus-1618 commented on Sep 22, 2025

    @matheus-1618

    Hey, any news on it? Thanks!

  5. YAMABASS80 commented on Nov 14, 2025

    @YAMABASS80

    Qwen model has same issue with Deepseek. It rejects messages that include reasoning content. Currently only when using Deepseek model, it filtered out them

    https://github.com/strands-agents/sdk-python/blob/8cae18cdc9a70cd892188485c2df47698a17af55/src/strands/models/bedrock.py#L335

    For the just workaround, I replace if statement as bellow then it worked.

    if any(model in self.config["model_id"].lower() for model in ["deepseek", "qwen"]) and "reasoningContent" in content_block:

    I don't think it's a good idea at all, but it seems like this is the only option at the moment.

  6. self-assigned this
    on Dec 9, 2025
  7. azaylamba commented on Dec 10, 2025

    @azaylamba

    @dbschmigelski We should also consider #1241 while implementing this.

  8. removed their assignment
    on Dec 30, 2025
  9. dbschmigelski commented on Jan 27, 2026

    @dbschmigelski
    ContributorAuthor
  10. dbschmigelski commented on Feb 5, 2026

    @dbschmigelski
    ContributorAuthor

    Adding another note, that now that we have the TS repository, this should probably be created in a new repository as a single source of truth.

  11. added
    pythonPull requests that update python code
    on May 29, 2026
  12. removed
    pythonPull requests that update python code
    on Jun 9, 2026
  13. added
    pythonPull requests that update python code
    on Jul 10, 2026
  14. added theissue type on Jul 10, 2026
  15. self-assigned this
    on Oct 20, 2026
  16. ishayHudl commented on Oct 22, 2026

    @ishayHudl

    Hi, we hit a production bug that's related to this issue and wanted to flag it before opening a PR.

    When using Claude Sonnet 5.5 (anthropic.claude-sonnet-5-5), the model occasionally produces an assistant turn containing only a reasoningContent block — no trailing text or toolUse. Strands stores this in agent.messages and the next ConverseStream call fails with:

    ValidationException: messages.N: The final block in an assistant message cannot be thinking.

    The AWS docs confirm this is valid to handle by omitting thinking blocks from prior turns: "It is only strictly necessary to send back thinking blocks when using tools with extended thinking. Otherwise, you can omit thinking blocks from previous turns." Dropping the incomplete turn is safe — there is no answer content to lose.

    The natural fix is the same pattern already used for DeepSeek (PR #652) — in _format_bedrock_messages, after building cleaned_content for an assistant message, skip the message if its last block is reasoningContent:

    is_anthropic = "anthropic" in self.config["model_id"].lower() or "claude" in self.config["model_id"].lower()
    if (
        is_anthropic
        and message.get("role") == "assistant"
        and cleaned_content
        and "reasoningContent" in cleaned_content[-1]
    ):
        continue  # drop thinking-only turn, no answer content to lose
    

    We know this is another if model_id special-case that #780 wants to replace with a proper registry. Happy to submit the targeted patch now and update it once the registry lands, or wait if you'd prefer to fold it into #780 directly. Just wanted to flag the production impact before proceeding.

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

Metadata

Metadata

Assignees

Labels

area-modelRelated to models or model providersenhancementNew feature or requestpythonPull requests that update python code

Fields

Language

Python

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions