Skip to content

fix: skip extended thinking params for Haiku models#1127

Closed
frizynn wants to merge 1 commit into
NousResearch:mainfrom
frizynn:fix/haiku-thinking-params
Closed

fix: skip extended thinking params for Haiku models#1127
frizynn wants to merge 1 commit into
NousResearch:mainfrom
frizynn:fix/haiku-thinking-params

Conversation

@frizynn

@frizynn frizynn commented Mar 13, 2026

Copy link
Copy Markdown

Summary

Fixes a bug where Haiku models (e.g. claude-haiku-4-5-20251001) would receive extended thinking parameters, causing a 400 error from the Anthropic API.

Bug

The reasoning config logic in anthropic_adapter.py uses substring matching to detect model capabilities:

if any(v in model for v in ("4-6", "4-5", "4.6", "4.5")):

This check matches Haiku model names like claude-haiku-4-5-20251001 because they contain the substring "4-5". As a result, the adapter sends thinking: {type: "adaptive", budget_tokens: ...} to the API — but Haiku models do not support extended thinking at all, so the API returns a 400 error.

Root Cause

The substring-based version check does not account for the fact that Haiku models share version substrings (e.g. 4-5) with Sonnet/Opus models that do support thinking.

Fix

Added a guard clause to skip thinking parameters entirely when the model name contains "haiku":

if reasoning_config.get("enabled") is not False and "haiku" not in model.lower():

This ensures Haiku models are never sent thinking parameters, regardless of version substring matches.

Test plan

  • Verify that requests to claude-haiku-4-5-20251001 no longer include thinking params
  • Verify that claude-sonnet-4-5-20250514 still gets thinking: {type: "adaptive", ...}
  • Verify that older non-Haiku models still get thinking: {type: "enabled", ...}

Haiku models (e.g. claude-haiku-4-5-20251001) do not support extended
thinking, but the substring check `"4-5" in model` was matching them
and sending `thinking.adaptive.budget_tokens`, causing a 400 error
from the Anthropic API.

Skip thinking params entirely when the model name contains 'haiku'.
teknium1 added a commit that referenced this pull request Mar 13, 2026
Haiku models don't support extended thinking at all. Without this
guard, claude-haiku-4-5-20251001 would receive type=enabled +
budget_tokens and return a 400 error.

Incorporates the fix from PR #1127 (by frizynn) on top of #1128's
adaptive thinking refactor.

Verified live with Claude Code OAuth:
  claude-opus-4-6       → adaptive thinking ✓
  claude-haiku-4-5      → no thinking params ✓
  claude-sonnet-4       → enabled thinking ✓
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #1130 on top of #1128. Your Haiku guard was incorporated with authorship credit. Thanks @frizynn!

@teknium1 teknium1 closed this Mar 13, 2026
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
Haiku models don't support extended thinking at all. Without this
guard, claude-haiku-4-5-20251001 would receive type=enabled +
budget_tokens and return a 400 error.

Incorporates the fix from PR NousResearch#1127 (by frizynn) on top of NousResearch#1128's
adaptive thinking refactor.

Verified live with Claude Code OAuth:
  claude-opus-4-6       → adaptive thinking ✓
  claude-haiku-4-5      → no thinking params ✓
  claude-sonnet-4       → enabled thinking ✓
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Haiku models don't support extended thinking at all. Without this
guard, claude-haiku-4-5-20251001 would receive type=enabled +
budget_tokens and return a 400 error.

Incorporates the fix from PR NousResearch#1127 (by frizynn) on top of NousResearch#1128's
adaptive thinking refactor.

Verified live with Claude Code OAuth:
  claude-opus-4-6       → adaptive thinking ✓
  claude-haiku-4-5      → no thinking params ✓
  claude-sonnet-4       → enabled thinking ✓
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
Haiku models don't support extended thinking at all. Without this
guard, claude-haiku-4-5-20251001 would receive type=enabled +
budget_tokens and return a 400 error.

Incorporates the fix from PR NousResearch#1127 (by frizynn) on top of NousResearch#1128's
adaptive thinking refactor.

Verified live with Claude Code OAuth:
  claude-opus-4-6       → adaptive thinking ✓
  claude-haiku-4-5      → no thinking params ✓
  claude-sonnet-4       → enabled thinking ✓
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
Haiku models don't support extended thinking at all. Without this
guard, claude-haiku-4-5-20251001 would receive type=enabled +
budget_tokens and return a 400 error.

Incorporates the fix from PR NousResearch#1127 (by frizynn) on top of NousResearch#1128's
adaptive thinking refactor.

Verified live with Claude Code OAuth:
  claude-opus-4-6       → adaptive thinking ✓
  claude-haiku-4-5      → no thinking params ✓
  claude-sonnet-4       → enabled thinking ✓
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.

2 participants