fix(copilot): support max reasoning effort for claude-sonnet-4.6#33606
fix(copilot): support max reasoning effort for claude-sonnet-4.6#33606dzianisv wants to merge 1 commit into
Conversation
The Copilot API returns reasoning_effort: [low, medium, high, max] for claude-sonnet-4.6. Two bugs prevented max from being available: 1. transform.ts filtered out "max" in the @ai-sdk/anthropic+github-copilot fallback path with an outdated comment "Efforts currently supported: low, medium, high". Confirmed via live API test that output_config.effort=max is accepted and controls thinking depth on /v1/messages. 2. transform.ts used WIDELY_SUPPORTED_EFFORTS (no max) for the fallback claude path on @ai-sdk/github-copilot. Confirmed reasoning_effort=max works on /chat/completions for claude models. Also fix a model key mismatch: the static catalog keys claude-sonnet-4-6 (hyphen) while the Copilot API returns claude-sonnet-4.6 (dot). This caused the catalog entry to be deleted on every model refresh and re-added without the prev metadata, breaking saved model preferences. Added a normalized lookup index so the catalog key is preserved when model IDs differ only in version separator.
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR: PR #31570: feat: drive reasoning variants from models.dev reasoning_options This PR may be related because it also deals with reasoning options/variants for models, which overlaps with the reasoning effort support being fixed in PR #33606. However, it appears to be a different feature focused on driving reasoning variants from All other search results only returned PR #33606 (the current PR itself), indicating no direct duplicates exist. |
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Issue for this PR
Closes #33607
Type of change
What does this PR do?
Bug 1: max reasoning effort not available for claude-sonnet-4.6
The Copilot API returns
reasoning_effort: ["low", "medium", "high", "max"]for claude-sonnet-4.6. Two places intransform.tsblocked max from reaching the user:@ai-sdk/anthropic+ github-copilot fallback path filtered it out withefforts.filter(v => v !== "max" && v !== "xhigh"). Comment said "Efforts currently supported: low, medium, high" — outdated.@ai-sdk/github-copilotclaude fallback path usedWIDELY_SUPPORTED_EFFORTS(no max).Fix: remove the max filter (keep xhigh filtered, not in Copilot API); add max to the claude efforts list; extract
COPILOT_CLAUDE_EFFORTSconstant.Bug 2: model key mismatch drops catalog metadata on every refresh
Static catalog keys
claude-sonnet-4-6(hyphen). Copilot API returnsclaude-sonnet-4.6(dot).remote.get(model.api.id)fails the lookup, so the catalog entry is pruned and replaced with a new entry (noprev) on every refresh, discarding catalog metadata and breaking saved model preferences.Fix: build a secondary normalized map keying API IDs with dots replaced by hyphens, track matched IDs to avoid duplicates.
How did you verify your code works?
output_config.effort=maxaccepted by/v1/messages, produces more thinking tokens thaneffort=lowreasoning_effort=maxaccepted by/chat/completionsfor claude modelsScreenshots / recordings
N/A
Checklist