Skip to content

fix: keep temperature 0 and forward top_p, top_k and stop_sequences from Claude requests - #149

Merged
lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/claude-sampling-zero
Oct 27, 2026
Merged

lich0821 merged 1 commit into
lich0821:masterfrom
pcbeingused333:fix/claude-sampling-zero

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

The Claude -> OpenAI and Claude -> Gemini request converters dropped sampling settings:

  • temperature: 0 was discarded (req.Temperature > 0), so a client asking for deterministic output got the upstream's default temperature instead. The request struct held a plain float64, which cannot tell 0 from "not sent".
  • top_p, top_k and stop_sequences were not part of ClaudeRequest, so they never reached the upstream.

ClaudeRequest.Temperature is now a *float64 and the struct gains TopP, TopK and StopSequences. The OpenAI converter forwards temperature, top_p and stop (OpenAIRequest gets TopP and Stop; OpenAI has no top_k), and the Gemini converter writes temperature, topP, topK and stopSequences into generationConfig. Anything the client did not send is still omitted. The Responses API converter is unchanged.

Tests: claude_sampling_test.go covers both converters with and without the parameters; the two "keeps" cases fail on master. go vet and go test ./internal/... pass. Not run against a live OpenAI or Gemini upstream.

This change was prepared with AI assistance (Claude Code).

…rom Claude requests

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@lich0821
lich0821 merged commit 7f7f508 into lich0821:master Oct 27, 2026
7 checks passed
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