发布

  • [OPIK-7438] [BE] fix: gate sampling params for Anthropic adaptive-thinking models on the playground/inference path (#7575)

    frostbyte_neo 发布于 2026-07-28 14:57:00 +00:00

    • [OPIK-7438] [BE] fix: gate sampling params for Anthropic adaptive-thinking models on the playground/inference path

    LlmProviderAnthropicMapper.toCreateMessageRequest forwarded temperature/top_p unconditionally, so
    adaptive-thinking models (claude-sonnet-5, claude-opus-4-7/4-8) 400 with "temperature is deprecated for
    this model" on API-created playground/inference/proxy requests that bypass the FE sanitizer (OPIK-6244).

    Gate temperature and top_p by AnthropicModelName.supportsSamplingParams(model) and whenever extended
    thinking is enabled per-request via custom_parameters, mirroring the judge-path logic in
    AnthropicClientGenerator (OPIK-7526 / PR #7531). top_k is not sent on this path (ChatCompletionRequest has
    no top_k), so nothing to gate there.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(anthropic): cover claude-opus-4-7 and temperature-over-top_p precedence in sampling gate

    Addresses review on #7575: add claude-opus-4-7 to the adaptive-model gating parameterization
    (all three adaptive models now asserted to drop temperature/top_p), and add a case setting both
    temperature and top_p on a sampling-capable model to guard the precedence branch (temperature kept,
    top_p null).

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • refactor(anthropic): consolidate sampling-gate tests and make thinking type match case-insensitively

    Address review on #7575 (andrescrz):

    • Collapse the 8 SamplingParamsGating test methods into one @ParameterizedTest driven by
      (description, request, expectedTemperature, expectedTopP), asserting via getTemperature()/getTopP()
      accessors instead of direct field access.
    • Match thinking type case-insensitively (equalsIgnoreCase("disabled")) in both the mapper and the
      judge-path AnthropicClientGenerator, keeping the two gates in parity.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(anthropic): assert full mapped payload and cover explicit null thinking type

    Address follow-up review on #7575 (andrescrz):

    • gatesSamplingParams now asserts actual vs expected AnthropicCreateMessageRequest via
      usingRecursiveComparison() (full payload), not just temperature/top_p, so a collateral change to
      any other mapped field is caught.
    • Add an explicit null thinking.type case asserting sampling params are still forwarded (null falls
      through thinkingEnabled() as not-enabled, same path as blank/absent).

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

    • test(anthropic): build expected payload independently of the mapper under test

    Address review on #7575 (baz): the full-payload assertion built expected by re-calling
    toCreateMessageRequest, so a collateral mapper bug would change actual and expected identically and
    hide. Build expected directly from the known fixture (model, single user message, empty system,
    default max_tokens, stream=false) plus the gate-derived temperature/top_p, so a regression in any
    mapped field now fails the recursive comparison.

    Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com


    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件