Repository navigation
🧠 chore: Widen AnthropicClientOptions Thinking for Opus 4.7 Display - #106
Merged
Merged
Conversation
…ve display
Extends `ThinkingConfig` with a `ThinkingConfigAdaptive` variant carrying
an optional `display: 'summarized' | 'omitted'` field, and overrides the
`thinking` property on `AnthropicClientOptions` via `Omit<AnthropicInput,
'thinking'>` so callers can pass `{ type: 'adaptive', display: 'summarized' }`
without casting.
Claude Opus 4.7 omits reasoning content by default unless the caller opts
in via `thinking.display = 'summarized'`, so downstream consumers
(LibreChat `packages/api/src/endpoints/anthropic/helpers.ts`) previously
had to cast through `AnthropicClientOptions['thinking']`.
Ref: https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-7#thinking-content-omitted-by-default
AnthropicClientOptions Thinking for Opus 4.7 Display
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
I widened the
AnthropicClientOptions['thinking']type so downstream consumers can pass Claude Opus 4.7's new adaptive-thinkingdisplayfield without an unsafe cast. Previously the type came straight fromAnthropicInput['thinking']in@langchain/anthropic, which doesn't include{ type: 'adaptive', display?: 'summarized' | 'omitted' }, forcing callers (e.g., LibreChat PR #12701) to writeadaptive as AnthropicClientOptions['thinking'].ThinkingDisplayunion ('summarized' | 'omitted') with a JSDoc link to the Anthropic 4.7 release notes in src/types/llm.ts.ThinkingConfigAdaptivetype carrying the new optionaldisplayfield.ThinkingConfigalias to unionNonNullable<AnthropicInput['thinking']>withThinkingConfigAdaptive, so pre-4.7 adaptive callers that omitdisplaycontinue to type-check.AnthropicClientOptionsasOmit<AnthropicInput, 'thinking'> & { thinking?: ThinkingConfig; promptCache?: boolean }so the widenedthinkingtakes precedence over langchain's stale definition.Reference: https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-7#thinking-content-omitted-by-default
Change Type
Testing
Ran
npx tsc --noEmitagainst the full project — passes cleanly. Existing adaptive-thinking tests in src/llm/anthropic/llm.spec.ts that construct{ type: 'adaptive' }still compile against the widened union. Recommend reviewers also verify the downstream LibreChat build no longer requires theas AnthropicClientOptions['thinking']cast after this package publishes.Test Configuration:
@langchain/anthropic ^0.3.26,@anthropic-ai/sdk ^0.73.0.Checklist