Commit c6f6cd6
[issue-7526][BE] fix: support Anthropic adaptive-thinking models as online-rule judges (#7531)
* [issue-7526] [BE] fix: support Anthropic adaptive-thinking models as online-rule judges
Online LLM-as-judge rules failed with Anthropic adaptive-thinking models
(claude-sonnet-5, claude-opus-4-7/4-8): the judge-path builder forwarded
temperature unconditionally (400 "temperature is deprecated for this model")
and never set max_tokens or read the rule's custom_parameters, so thinking
consumed the whole budget and the judge returned an empty response
(finishReason=LENGTH).
In AnthropicClientGenerator.newChatLanguageModel (the judge path):
- Gate temperature server-side via AnthropicModelName.supportsSamplingParams,
and also skip it whenever thinking is enabled per-rule via custom_parameters
(Anthropic rejects sampling params while thinking is on) — covers API-created
rules that bypass the FE sanitizer.
- Forward custom_parameters (thinking type/budget, max_tokens) onto the native
langchain4j builder.
- Always send max_tokens, defaulting to the Playground default (4096) and
stacking it above any thinking budget so max_tokens > budget_tokens holds.
- Ignore non-positive max_tokens/budget_tokens from the bypass path.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(online-rules): address Anthropic judge review feedback
Address baz-reviewer comments on the Anthropic adaptive-thinking judge fix:
- Fail closed for unknown model names in AnthropicModelName.supportsSamplingParams
(default false) so a new adaptive-thinking model can't reintroduce the temperature
400 before it is added to the enum; back the lookup with a cached static map instead
of streaming values() on every call.
- Treat thinking as enabled unless the type is explicitly "disabled" (covers "adaptive"
and any future type), and decode the thinking block once via parseThinking(), reused
by both the temperature gate and the builder wiring.
- Clamp max_tokens above the thinking budget even when an explicit max_tokens is set, so
max_tokens <= budget_tokens can no longer reach Anthropic and 400.
- Rename the headroom test to reflect what it asserts.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(online-rules): harden Anthropic judge thinking/max_tokens parsing
Second round of baz-reviewer feedback on the adaptive-thinking judge fix:
- Default unknown model names back to true in supportsSamplingParams so registry-only
Anthropic models keep temperature support; adaptive models remain explicitly opted out.
- Treat thinking as enabled only for an explicit non-blank type other than "disabled", so
an empty/blank thinking block no longer suppresses temperature or shapes max_tokens.
- Forward thinking.budget_tokens only when thinking is enabled, so a budget-only (no type)
block can't reach Anthropic as a partial config and 400.
- Widen to long before adding headroom in resolveMaxTokens so an extreme budget can't
overflow max_tokens to a negative int.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(online-rules): assert default max_tokens in Anthropic disabled-thinking case
Harden dropsBudgetWhenThinkingDisabled so a regression that changes max_tokens
(not just the thinking budget) is caught.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 79aaa97 commit c6f6cd6
3 files changed
Lines changed: 377 additions & 4 deletions
File tree
- apps/opik-backend/src
- main/java/com/comet/opik/infrastructure/llm/antropic
- test/java/com/comet/opik/infrastructure/llm/antropic
Lines changed: 90 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
69 | 81 | | |
70 | 82 | | |
71 | 83 | | |
72 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
73 | 162 | | |
74 | 163 | | |
75 | 164 | | |
| |||
apps/opik-backend/src/main/java/com/comet/opik/infrastructure/llm/antropic/AnthropicModelName.java
Lines changed: 25 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | | - | |
19 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | | - | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
27 | 49 | | |
28 | 50 | | |
29 | 51 | | |
| |||
0 commit comments