fix(web): Add support for adaptive thinking parameters#1127
fix(web): Add support for adaptive thinking parameters#1127brendan-kellam merged 4 commits intomainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAnthropic provider thinking options in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/web/src/features/chat/utils.server.ts (1)
213-227: Consider making thinking mode configurable rather than hardcoded per model.Hardcoding the adaptive-vs-enabled branch by
modelIdcouples the provider-option shape to a single model string. As more Anthropic models support adaptive thinking, thisif/elsewill grow. A cleaner path is to expose athinkingMode(or similar) field on the AnthropicLanguageModelconfig schema — mirroring howreasoningEffort/thinkingBudgetare already surfaced for OpenAI/Google — and default it based on model when unset. Not blocking for this PR.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/web/src/features/chat/utils.server.ts` around lines 213 - 227, The current logic hardcodes adaptive vs enabled thinking via isAdaptiveThinkingSupported and switches providerOptions.anthropic based on modelId (in the anthropic(modelId) block); instead, add an optional thinkingMode (or similar) on the Anthropic LanguageModel config and use that if provided, otherwise default thinkingMode based on modelId (e.g., default to "adaptive" for known models), then build providerOptions.anthropic from that thinkingMode and env.ANTHROPIC_THINKING_BUDGET_TOKENS; update places that construct models to accept the new config and remove the direct modelId-only branching so AnthropicProviderOptions is derived from thinkingMode rather than hardcoded model checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/web/src/features/chat/utils.server.ts`:
- Around line 220-226: The object literal assigned to thinking uses an
inconsistent quoted key "display"; update it to use an unquoted identifier
(display: "summarized") so it matches the style of the sibling type key and
remains compatible with the AnthropicProviderOptions shape—edit the ternary
branch that references thinking, isAdaptiveThinkingSupported, and
env.ANTHROPIC_THINKING_BUDGET_TOKENS to remove the quotes around the display
key.
- Around line 213-214: The exact equality check for modelId in the
isAdaptiveThinkingSupported assignment is brittle and will miss dated Anthropic
aliases like "claude-opus-4-7-20260101"; change the check to match by prefix or
pattern (e.g., use modelId.startsWith('claude-opus-4-7') or a RegExp/allowlist)
so any dated suffix still yields true for isAdaptiveThinkingSupported, and
update any related conditionals that rely on that constant (search for
isAdaptiveThinkingSupported and modelId usage to adjust accordingly).
---
Nitpick comments:
In `@packages/web/src/features/chat/utils.server.ts`:
- Around line 213-227: The current logic hardcodes adaptive vs enabled thinking
via isAdaptiveThinkingSupported and switches providerOptions.anthropic based on
modelId (in the anthropic(modelId) block); instead, add an optional thinkingMode
(or similar) on the Anthropic LanguageModel config and use that if provided,
otherwise default thinkingMode based on modelId (e.g., default to "adaptive" for
known models), then build providerOptions.anthropic from that thinkingMode and
env.ANTHROPIC_THINKING_BUDGET_TOKENS; update places that construct models to
accept the new config and remove the direct modelId-only branching so
AnthropicProviderOptions is derived from thinkingMode rather than hardcoded
model checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 50102019-c71f-4fe1-953c-1191a2f09c74
📒 Files selected for processing (1)
packages/web/src/features/chat/utils.server.ts
Fixes #1123
Summary by CodeRabbit