AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Langchain-Anthropic Manual Thinking Validation Misses Claude Opus 4.7/4.8 And Sonnet 5

ChatAnthropic._assert_valid_model_configuration() only rejects manual thinking for models starting with claude-opus-5. Anthropic also rejects manual thinking for claude-opus-4-7, claude-opus-4-8, and claude-sonnet-5, so LangChain forwards invalid requests and the API returns HTTP 400.

highConfidence 93%LangchainAffected V1.6.1

Origin Analysis

The local guard that prevents unsupported manual thinking is limited to `self.model.startswith("claude-opus-5")`. Anthropic's model matrix now marks claude-opus-4-7, claude-opus-4-8, and claude-sonnet-5 as adaptive-only, but the prefix check does not include those model families.
Run: ChatAnthropic(model='claude-opus-4-7', thinking={'type':'enabled','budget_tokens':1024}, max_tokens=1025, max_retries=0).invoke('hi') . The constructor accepts the configuration, then Anthropic returns 400 with "thinking.type.enabled is not supported for this model. Use thinking.type.adaptive".

Fixing Code Block

Edge Case Audit

If Anthropic later re-enables manual thinking for one of these prefixes or adds a new model with a matched prefix but different behavior, this hardcoded list will produce a false positive. Maintainers should consider deriving model capabilities from the client/model metadata so the list is not hardcoded. Rollback: revert to the original single-prefix check if this blocks a valid request. Test with claude-opus-4-7, claude-opus-4-8, claude-opus-5, and claude-sonnet-5 to confirm local rejection.

Ecosystem Topology