Skip to content

UN-3707 [FIX] Cover Claude 5 family in deprecated sampling-param strip#2162

Open
pk-zipstack wants to merge 1 commit into
mainfrom
fix/sampling-param-models
Open

UN-3707 [FIX] Cover Claude 5 family in deprecated sampling-param strip#2162
pk-zipstack wants to merge 1 commit into
mainfrom
fix/sampling-param-models

Conversation

@pk-zipstack

Copy link
Copy Markdown
Contributor

What

  • Extend the shared _SAMPLING_DEPRECATED_MODEL_PATTERNS tuple in unstract/sdk1/.../adapters/base1.py from 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 existing claude-opus-4-7).
  • Because all four Claude-capable adapters (Anthropic, AWS Bedrock, Vertex AI, Azure AI Foundry) call _strip_deprecated_sampling_params, which reads this one tuple, the single change fixes every adapter at once — no per-adapter edits.

Why

  • Configuring Claude Sonnet 5 against an Azure AI Foundry environment fails at adapter-test time (reported by a customer):
    Error testing 'Claude Sonnet 5'. Error from LLM adapter 'azure_ai': Azure_aiException -
    {"type":"error","error":{"type":"invalid_request_error","message":"temperature is deprecated for this model."}}
    
  • Anthropic deprecated temperature / top_p / top_k starting with Claude Opus 4.7 and continued the deprecation across the entire Claude 5 family — sending any of them returns a 400.
  • The strip mechanism was already wired into the azure_ai adapter, but the shared detection regex only matched claude-opus-4-7. So Sonnet 5 / Opus 4.8 / Fable 5 slipped through and the Pydantic-default temperature=0.1 reached the provider, producing the 400.

How

  • adapters/base1.py: add four re.compile(...) entries to _SAMPLING_DEPRECATED_MODEL_PATTERNS, each using the existing trailing-edge anchor (?=$|[-:@/]|v\d) so provider encodings (native, anthropic/…, Bedrock anthropic.…-<date>-v1:0 and cross-region/ARN forms, Vertex …@<date>, Azure azure_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).
  • Models that still accept sampling params (Opus 4.6, Sonnet 4.6, Opus 4.5/4.1/4.0, Sonnet 4.5/4.0, Haiku 4.5) are intentionally excluded, verified against the current Anthropic model reference.

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)

  • No. The change only adds models to a deny-list regex that removes deprecated sampling params before the request reaches the provider. It cannot affect any model that previously worked. The excluded older families (Opus 4.6 / Sonnet 4.6 and earlier) still keep temperature intact — explicitly pinned by test_validate_retains_temperature_for_opus_4_6 and negative-detection tests. No adapter interfaces, request shapes, or public APIs changed.

Database Migrations

  • None.

Env Config

  • None.

Relevant Docs

Related Issues or PRs

Dependencies Versions

  • None.

Notes on Testing

  • pytest unstract/sdk1/tests/test_sampling_strip.py93 passed. The 22 new Claude 5 positives fail against the pre-change opus-4-7-only regex, confirming they exercise the new code.
  • All added lines are within the repo's 90-col limit.

Known limitation (follow-up)

  • The proactive-regex approach cannot detect an Azure AI Foundry deployment whose name does not embed the model id (e.g. a deployment literally named 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

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>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 219475aa-1691-4ff4-acd7-fd3dc90d8109

📥 Commits

Reviewing files that changed from the base of the PR and between 09b6834 and e259613.

📒 Files selected for processing (2)
  • unstract/sdk1/src/unstract/sdk1/adapters/base1.py
  • unstract/sdk1/tests/test_sampling_strip.py

Summary by CodeRabbit

  • Bug Fixes
    • Updated Anthropic model handling to recognize additional Claude models that reject sampling parameters.
    • Prevented unsupported temperature, top_p, and top_k settings from being sent to these models.
    • Improved handling across supported provider integrations, including inference-profile model identifiers.
    • Added safeguards to avoid incorrectly modifying similarly named models.

Walkthrough

The 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.

Changes

Claude sampling deprecation

Layer / File(s) Summary
Expand deprecated-model detection
unstract/sdk1/src/unstract/sdk1/adapters/base1.py
Documentation and regex patterns now cover Claude Opus 4.8, Sonnet 5, Fable 5, and Mythos 5 identifiers.
Validate model and adapter behavior
unstract/sdk1/tests/test_sampling_strip.py
Tests cover provider-specific Claude 5 identifiers, prefix-collision negatives, adjacent families, and Sonnet 5 sampling-parameter stripping.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: expanding deprecated sampling-param stripping to cover the Claude 5 family.
Description check ✅ Passed The PR description follows the template and fills the required sections with concrete details, testing notes, and breaking-change notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sampling-param-models

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR extends the existing Claude sampling-parameter strip to more model names. The main changes are:

  • Added deprecated-sampling regex entries for Claude Opus 4.8 and Claude 5 models.
  • Updated comments around the shared model-pattern list.
  • Added positive, negative, and adapter-wiring tests for the new patterns.

Confidence Score: 5/5

This looks safe to merge after a small cleanup around deployment-name matching.

  • The shared strip path still covers the intended Anthropic-backed adapters.
  • The new tests cover the main provider encodings and nearby model-name collisions.
  • One non-blocking edge case can strip sampling params when an arbitrary deployment name looks like a Claude 5 model id.

unstract/sdk1/src/unstract/sdk1/adapters/base1.py

Important Files Changed

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.

Fix All in Claude Code

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

Comment thread unstract/sdk1/src/unstract/sdk1/adapters/base1.py
@github-actions

Copy link
Copy Markdown
Contributor

Unstract test results

Per-group results

Status Group Tier Passed Failed Errors Skipped Duration (s)
e2e-login e2e 2 0 0 0 1.6
e2e-smoke e2e 2 0 0 0 1.1
integration-backend integration 56 0 0 27 45.0
integration-connectors integration 1 0 0 7 7.7
unit-backend unit 118 0 0 0 21.7
unit-connectors unit 63 0 0 0 9.7
unit-core unit 27 0 0 0 1.3
unit-platform-service unit 15 0 0 0 2.6
unit-rig unit 69 0 0 0 3.6
unit-sdk1 unit 416 0 0 0 25.1
unit-workers unit 0 0 0 0 27.4
TOTAL 769 0 0 34 146.7

Critical paths

⚠️ Critical paths not yet covered

  • workflow-create-execute — Create a workflow, configure source+destination, execute, poll, fetch result. (entry: POST /api/v1/workflow/{id}/execute/; declared coverage: e2e-workflow)
  • api-deployment-run — Deploy a workflow as an API, POST a document, receive structured JSON. (entry: POST /deployment/api/{org}/{name}/; declared coverage: e2e-api-deployment)
  • prompt-studio-fetch-response — Prompt Studio: create project, add prompt, run single-pass, get response. (entry: POST /api/v1/prompt-studio/prompt-studio-tool/{id}/fetch_response/; declared coverage: e2e-prompt-studio)
  • pipeline-etl-execute — Run an ETL pipeline from source connector to destination. (entry: POST /api/v1/pipeline/{id}/execute/; declared coverage: no groups declared)
  • usage-token-tracking — Per-execution token usage is recorded and retrievable. (entry: GET /api/v1/usage/get_token_usage/; declared coverage: no groups declared)
  • workflow-execution-fan-out — Multi-file workflow execution fans out to file-processing workers and rejoins. (entry: internal: backend → rabbitmq → workers/file_processing; declared coverage: no groups declared)
  • callback-result-delivery — Async results are posted back via the callback worker. (entry: internal: workers/callback → backend /internal endpoints; declared coverage: no groups declared)
✅ Covered critical paths
  • auth-login — covered by e2e-login
  • adapter-register-llm — covered by integration-backend

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.

2 participants