Skip to content

fix: guard unsupported Anthropic reasoning fields across providers#3031

Draft
amitksingh1490 wants to merge 9 commits intomainfrom
fix/anthropic-haiku-reasoning-effort
Draft

fix: guard unsupported Anthropic reasoning fields across providers#3031
amitksingh1490 wants to merge 9 commits intomainfrom
fix/anthropic-haiku-reasoning-effort

Conversation

@amitksingh1490
Copy link
Copy Markdown
Contributor

@amitksingh1490 amitksingh1490 commented Apr 16, 2026

Summary

Guard Anthropic reasoning parameters by model capability across Anthropic, Bedrock, and OpenAI-compatible provider paths to prevent 400 errors like "This model does not support the effort parameter."

Context

The critical case is models that support thinking but not effort-style fields.

For example, Claude Haiku 4.5 supports reasoning/thinking budgets but rejects effort-style parameters. If effort is sent, Anthropic-compatible providers can return 400 invalid request errors.

Fixes #3030.

Changes

Implemented transformer-based compatibility guards per request pipeline so unsupported reasoning fields are removed before sending upstream requests.

Key Implementation Details

  • Added Anthropic request transformer StripUnsupportedReasoning and wired it into the Anthropic provider pipeline.
  • Added OpenAI-request transformer StripUnsupportedAnthropicReasoning and wired it into the OpenAI provider pipeline so proxy providers (OpenRouter, Requesty, GitHub Copilot, etc.) also sanitize Anthropic reasoning fields by model.
  • Added Bedrock transformer StripUnsupportedReasoning to remove unsupported additional_model_request_fields thinking payloads for unsupported/non-Anthropic models.
  • Updated model capability checks so Claude Haiku 4.5 keeps thinking while stripping effort.
  • Registered new modules in transformer/provider mod declarations.
  • Added focused unit tests for Haiku, Sonnet 3.7, Sonnet 4, non-Anthropic cases, and Bedrock path behavior.

Use Cases

  • Running claude-haiku-4-5 with reasoning enabled no longer fails due to unsupported effort fields.
  • Anthropic models routed via OpenAI-compatible APIs (OpenRouter/Requesty/GitHub Copilot) no longer receive unsupported effort fields.
  • Bedrock requests avoid sending unsupported Anthropic thinking fields for incompatible model IDs.

Testing

cargo test -p forge_app -- dto::openai::transformers::strip_unsupported_anthropic_reasoning
cargo test -p forge_app -- dto::anthropic::transforms::strip_unsupported_reasoning
PROTOC="/tmp/protoc-bin/bin/protoc" cargo test -p forge_repo -- provider::bedrock_strip_unsupported_reasoning
PROTOC="/tmp/protoc-bin/bin/protoc" cargo check -p forge_repo
cargo check -p forge_app

Links

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 16, 2026
Comment thread crates/forge_repo/src/provider/bedrock_strip_unsupported_reasoning.rs Outdated
/// example, Claude 3.5 Haiku) reject both thinking and effort parameters,
/// while newer models such as Claude Haiku 4.5 support thinking but still
/// reject effort-style reasoning parameters.
pub struct StripUnsupportedAnthropicReasoning;
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.

Too much of duplicate code across transformers. We can create one on Conversation to remove reasoning effort thing.

@tusharmath tusharmath marked this pull request as draft April 17, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Guard Anthropic reasoning fields by model support

3 participants