Skip to content

fix: clamp unsupported reasoning effort to highest supported tier - #70

Open
Michael J. Jabbour (michaeljabbour) wants to merge 1 commit into
microsoft:mainfrom
michaeljabbour:fix/289-clamp-effort
Open

fix: clamp unsupported reasoning effort to highest supported tier#70
Michael J. Jabbour (michaeljabbour) wants to merge 1 commit into
microsoft:mainfrom
michaeljabbour:fix/289-clamp-effort

Conversation

@michaeljabbour

Copy link
Copy Markdown

Problem

Follow-up to #61 (config-level reasoning effort). When requesting effort: max on a model without max support (e.g., claude-sonnet-5), the provider warned per-request and OMITTED output_config.effort, silently downgrading to the server's default. This created a silent behavioral change — the configured effort tier was lost, with no auditable record.

Solution

Replaced warn-and-omit with clamp-and-log-once:

  • Clamp to highest supported tier: Maintains EFFORT_ORDER (low < medium < high < xhigh < max). Requests for unsupported tiers are clamped to the nearest supported level ≤ the request. For example: effort: max on claude-sonnet-5 (supports up to xhigh) clamps to xhigh.
  • Emit clamped value in output_config.effort: The actual effort sent to the API is recorded in the response, making the change auditable.
  • One-time INFO per (model, requested_effort) pair instead of per-request WARNING — reduces log noise while preserving visibility. Uses same one-time-notice pattern (_effort_downgrade_logged cache) as existing _warned_deprecated_models.
  • Exact-support models (fable-5, opus-4.8) pass through untouched — zero behavior change when model supports the requested tier.
  • Below-floor edge case handled — clamps up (defensive). No current model exercises this, but tested directly via the helper.

Testing

  • 25 new test cases covering exact-support passthrough, above-ceiling downclamp, below-floor upclamp, one-time logging per pair, no mutation of input, and state cleanup.
  • Test suite: 551 passed (same 3 pre-existing unrelated failures)
  • DTU end-to-end: Live two-turn run against api.anthropic.com with claude-sonnet-5 + effort: max → exactly ONE INFO log (Effort 'max' exceeds claude-sonnet-5's supported range … using 'xhigh'), both turns returned 200 OK with effort: xhigh in output_config.

Implementation Detail

The EFFORT_ORDER constant is the single source of truth for tier ordering and is used in both the global config validation (which only validates that an effort string is recognized, not model-supported) and the per-model gate (which applies the clamp). This avoids duplicating model-aware logic in two places.

Compatibility

  • No changes to mount(), complete(), or other public contracts
  • One legacy test updated (it asserted the old warn-and-omit behavior)
  • Merges cleanly with the sanitize-thinking-blocks PR (fix/207) — disjoint init.py regions, validated in combined DTU test

Fixes microsoft-amplifier/amplifier-support#289 (follow-up to #61)

…pported range

Follow-up to provider PR microsoft#61 (config-level effort support). Requesting an effort a model doesn't support (e.g. 'max' on claude-sonnet-5) previously warned per-request and OMITTED output_config.effort, silently downgrading to server default. Now clamps to highest supported tier ≤ requested (EFFORT_ORDER: low<medium<high<xhigh<max), emits clamped value in output_config.effort, and logs ONE-TIME INFO per (model, requested_effort) instead of per-request WARNING.

- Exact-match models (fable-5, opus-4.8) pass through untouched
- Below-floor edge handled (clamp up, tested via helper)
- One legacy test updated (asserted old warn-and-omit behavior)
- 25 new tests covering clamp range, legacy models, edge cases

Fixes: microsoft-amplifier/amplifier-support#289

Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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