UN-3707 [FIX] Cover Claude 5 family in deprecated sampling-param strip#2162
UN-3707 [FIX] Cover Claude 5 family in deprecated sampling-param strip#2162pk-zipstack wants to merge 1 commit into
Conversation
Anthropic deprecated temperature/top_p/top_k starting with Claude Opus 4.7 and continued it across the Claude 5 family. The shared detection regex _SAMPLING_DEPRECATED_MODEL_PATTERNS only matched claude-opus-4-7, so Claude Sonnet 5 (and Opus 4.8 / Fable 5) reached the provider with the default temperature and 400'd — surfaced as the Azure AI Foundry "temperature is deprecated for this model" adapter-test failure. Extend the shared tuple to also match claude-opus-4-8, claude-sonnet-5, claude-fable-5, and claude-mythos-5. All four Claude-capable adapters (Anthropic, Bedrock, Vertex AI, Azure AI Foundry) read the same tuple, so the single change fixes every adapter. Opus 4.6 / Sonnet 4.6 and older still accept sampling params and are intentionally left out. Tests extended to pin the new model encodings (native, Bedrock ARN, Vertex @Date, Azure deployment names), lock the trailing-edge anchor against collisions (claude-sonnet-50, claude-sonnet-5verbose), and assert the Sonnet 5 strip across all four adapters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Summary by CodeRabbit
WalkthroughThe deprecated sampling-parameter detector now recognizes Claude Opus 4.8 and Claude 5 model identifiers across providers. Tests add positive, negative, and adapter return-path coverage for the expanded detection behavior. ChangesClaude sampling deprecation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
|
| Filename | Overview |
|---|---|
| unstract/sdk1/src/unstract/sdk1/adapters/base1.py | Adds the new Claude-family regex patterns to the shared deprecated-sampling list used by the Anthropic-backed adapters. |
| unstract/sdk1/tests/test_sampling_strip.py | Adds coverage for Claude 5 detection, collision negatives, and Sonnet 5 adapter validation. |
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
unstract/sdk1/src/unstract/sdk1/adapters/base1.py:52
**Deployment Name Drives Stripping**
When Azure AI Foundry receives an arbitrary deployment name that contains `claude-sonnet-5` but the deployment points at a model that still accepts sampling params, this regex treats the deployment name as the model id and removes `temperature`, `top_p`, and `top_k`. Callers then lose explicitly configured sampling behavior even though the target model could have used it.
Reviews (1): Last reviewed commit: "UN-3707 [FIX] Cover Claude 5 family in d..." | Re-trigger Greptile
Unstract test resultsPer-group results
Critical paths
|



What
_SAMPLING_DEPRECATED_MODEL_PATTERNStuple inunstract/sdk1/.../adapters/base1.pyfrom 1 entry to 5, so the proactive sampling-param strip also fires for the Claude 5 family:claude-opus-4-8,claude-sonnet-5,claude-fable-5,claude-mythos-5(in addition to the existingclaude-opus-4-7)._strip_deprecated_sampling_params, which reads this one tuple, the single change fixes every adapter at once — no per-adapter edits.Why
temperature/top_p/top_kstarting with Claude Opus 4.7 and continued the deprecation across the entire Claude 5 family — sending any of them returns a 400.azure_aiadapter, but the shared detection regex only matchedclaude-opus-4-7. So Sonnet 5 / Opus 4.8 / Fable 5 slipped through and the Pydantic-defaulttemperature=0.1reached the provider, producing the 400.How
adapters/base1.py: add fourre.compile(...)entries to_SAMPLING_DEPRECATED_MODEL_PATTERNS, each using the existing trailing-edge anchor(?=$|[-:@/]|v\d)so provider encodings (native,anthropic/…, Bedrockanthropic.…-<date>-v1:0and cross-region/ARN forms, Vertex…@<date>, Azureazure_ai/…deployment names, and dot/underscore variants) all match while prefix collisions (claude-sonnet-50,claude-sonnet-5verbose) do not. Comment block generalized to the Claude 5 family.tests/test_sampling_strip.py: added 22 positive cases across the four new models and their encodings; new negative cases locking the anchor against collisions and adjacent families (claude-sonnet-4-6,claude-sonnet-4-5,claude-opus-4-80, etc.); and adapter-wiring tests asserting Sonnet 5 is stripped on all four adapters (mirrors the existing Opus 4.7 coverage).Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
temperatureintact — explicitly pinned bytest_validate_retains_temperature_for_opus_4_6and negative-detection tests. No adapter interfaces, request shapes, or public APIs changed.Database Migrations
Env Config
Relevant Docs
temperature/top_p/top_k) removed on Opus 4.7+ and the Claude 5 family: https://docs.claude.com/en/about-claude/models/whats-new-claude-4-7Related Issues or PRs
Dependencies Versions
Notes on Testing
pytest unstract/sdk1/tests/test_sampling_strip.py→ 93 passed. The 22 new Claude 5 positives fail against the pre-change opus-4-7-only regex, confirming they exercise the new code.Known limitation (follow-up)
my-deploy). It also needs a new tuple entry each time Anthropic deprecates sampling on a future model. A durable follow-up is a reactive strip-and-retry that parses the " is deprecated" 400 and retries — out of scope here.Screenshots
Checklist
I have read and understood the Contribution Guidelines.
🤖 Generated with Claude Code