Skip to content

🧠 chore: Widen AnthropicClientOptions Thinking for Opus 4.7 Display - #106

Merged
danny-avila merged 1 commit into
mainfrom
claude/flamboyant-snyder-c52f6f
Apr 17, 2026
Merged

danny-avila merged 1 commit into
mainfrom
claude/flamboyant-snyder-c52f6f

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

I widened the AnthropicClientOptions['thinking'] type so downstream consumers can pass Claude Opus 4.7's new adaptive-thinking display field without an unsafe cast. Previously the type came straight from AnthropicInput['thinking'] in @langchain/anthropic, which doesn't include { type: 'adaptive', display?: 'summarized' | 'omitted' }, forcing callers (e.g., LibreChat PR #12701) to write adaptive as AnthropicClientOptions['thinking'].

  • Added a ThinkingDisplay union ('summarized' | 'omitted') with a JSDoc link to the Anthropic 4.7 release notes in src/types/llm.ts.
  • Added a ThinkingConfigAdaptive type carrying the new optional display field.
  • Extended the existing ThinkingConfig alias to union NonNullable<AnthropicInput['thinking']> with ThinkingConfigAdaptive, so pre-4.7 adaptive callers that omit display continue to type-check.
  • Rewrote AnthropicClientOptions as Omit<AnthropicInput, 'thinking'> & { thinking?: ThinkingConfig; promptCache?: boolean } so the widened thinking takes 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

  • Bug fix (non-breaking change which fixes an issue)

Testing

Ran npx tsc --noEmit against 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 the as AnthropicClientOptions['thinking'] cast after this package publishes.

Test Configuration:

  • Node.js 20+, TypeScript 5.5, @langchain/anthropic ^0.3.26, @anthropic-ai/sdk ^0.73.0.

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code
  • My changes do not introduce new warnings
  • Local unit tests pass with my changes

…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
@danny-avila danny-avila changed the title 🧠 fix: Widen AnthropicClientOptions Thinking for Opus 4.7 Display 🧠 chore: Widen AnthropicClientOptions Thinking for Opus 4.7 Display Apr 17, 2026
@danny-avila
danny-avila merged commit 0663b18 into main Apr 17, 2026
4 checks passed
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.

1 participant