@@ -2659,30 +2659,30 @@ func TestApplyCloaking_PreservesConfiguredStrictModeAndSensitiveWordsWhenModeOmi
26592659 }
26602660}
26612661
2662- func TestNormalizeClaudeSamplingForThinking_AdaptiveCoercesTemperatureToOne (t * testing.T ) {
2662+ func TestNormalizeClaudeSamplingForUpstream_RemovesTemperature (t * testing.T ) {
26632663 payload := []byte (`{"temperature":0,"thinking":{"type":"adaptive"},"output_config":{"effort":"max"}}` )
2664- out := normalizeClaudeSamplingForThinking (payload )
2664+ out := normalizeClaudeSamplingForUpstream (payload )
26652665
2666- if got := gjson .GetBytes (out , "temperature" ).Float (); got != 1 {
2667- t .Fatalf ("temperature = %v, want 1" , got )
2666+ if gjson .GetBytes (out , "temperature" ).Exists () {
2667+ t .Fatalf ("temperature should be removed" )
26682668 }
26692669}
26702670
2671- func TestNormalizeClaudeSamplingForThinking_EnabledCoercesTemperatureToOne (t * testing.T ) {
2671+ func TestNormalizeClaudeSamplingForUpstream_RemovesTemperatureWithThinkingEnabled (t * testing.T ) {
26722672 payload := []byte (`{"temperature":0.2,"thinking":{"type":"enabled","budget_tokens":2048}}` )
2673- out := normalizeClaudeSamplingForThinking (payload )
2673+ out := normalizeClaudeSamplingForUpstream (payload )
26742674
2675- if got := gjson .GetBytes (out , "temperature" ).Float (); got != 1 {
2676- t .Fatalf ("temperature = %v, want 1" , got )
2675+ if gjson .GetBytes (out , "temperature" ).Exists () {
2676+ t .Fatalf ("temperature should be removed" )
26772677 }
26782678}
26792679
2680- func TestNormalizeClaudeSamplingForThinking_RemovesTopPAndTopK (t * testing.T ) {
2680+ func TestNormalizeClaudeSamplingForUpstream_RemovesTopPAndTopKForThinking (t * testing.T ) {
26812681 payload := []byte (`{"temperature":0.2,"top_p":0.9,"top_k":40,"thinking":{"type":"adaptive"}}` )
2682- out := normalizeClaudeSamplingForThinking (payload )
2682+ out := normalizeClaudeSamplingForUpstream (payload )
26832683
2684- if got := gjson .GetBytes (out , "temperature" ).Float (); got != 1 {
2685- t .Fatalf ("temperature = %v, want 1" , got )
2684+ if gjson .GetBytes (out , "temperature" ).Exists () {
2685+ t .Fatalf ("temperature should be removed" )
26862686 }
26872687 if gjson .GetBytes (out , "top_p" ).Exists () {
26882688 t .Fatalf ("top_p should be removed when thinking is active" )
@@ -2692,12 +2692,12 @@ func TestNormalizeClaudeSamplingForThinking_RemovesTopPAndTopK(t *testing.T) {
26922692 }
26932693}
26942694
2695- func TestNormalizeClaudeSamplingForThinking_NoThinkingLeavesTemperatureAlone (t * testing.T ) {
2695+ func TestNormalizeClaudeSamplingForUpstream_NoThinkingRemovesOnlyTemperature (t * testing.T ) {
26962696 payload := []byte (`{"temperature":0,"top_p":0.9,"top_k":40,"messages":[{"role":"user","content":"hi"}]}` )
2697- out := normalizeClaudeSamplingForThinking (payload )
2697+ out := normalizeClaudeSamplingForUpstream (payload )
26982698
2699- if got := gjson .GetBytes (out , "temperature" ).Float (); got != 0 {
2700- t .Fatalf ("temperature = %v, want 0" , got )
2699+ if gjson .GetBytes (out , "temperature" ).Exists () {
2700+ t .Fatalf ("temperature should be removed" )
27012701 }
27022702 if got := gjson .GetBytes (out , "top_p" ).Float (); got != 0.9 {
27032703 t .Fatalf ("top_p = %v, want 0.9" , got )
@@ -2707,16 +2707,16 @@ func TestNormalizeClaudeSamplingForThinking_NoThinkingLeavesTemperatureAlone(t *
27072707 }
27082708}
27092709
2710- func TestNormalizeClaudeSamplingForThinking_AfterForcedToolChoiceKeepsOriginalTemperature (t * testing.T ) {
2710+ func TestNormalizeClaudeSamplingForUpstream_AfterForcedToolChoiceRemovesTemperature (t * testing.T ) {
27112711 payload := []byte (`{"temperature":0,"thinking":{"type":"adaptive"},"output_config":{"effort":"max"},"tool_choice":{"type":"any"}}` )
27122712 out := disableThinkingIfToolChoiceForced (payload )
2713- out = normalizeClaudeSamplingForThinking (out )
2713+ out = normalizeClaudeSamplingForUpstream (out )
27142714
27152715 if gjson .GetBytes (out , "thinking" ).Exists () {
27162716 t .Fatalf ("thinking should be removed when tool_choice forces tool use" )
27172717 }
2718- if got := gjson .GetBytes (out , "temperature" ).Float (); got != 0 {
2719- t .Fatalf ("temperature = %v, want 0" , got )
2718+ if gjson .GetBytes (out , "temperature" ).Exists () {
2719+ t .Fatalf ("temperature should be removed" )
27202720 }
27212721}
27222722
0 commit comments