fix(openai-compat): drop top_k for active Claude thinking - #5767
smartershining wants to merge 1 commit into
Conversation
|
This pull request targeted The base branch has been automatically changed to |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23546faf49
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| switch strings.ToLower(strings.TrimSpace(gjson.GetBytes(source, "thinking.type").String())) { | ||
| case "enabled", "adaptive", "auto": | ||
| thinkingActive = true |
There was a problem hiding this comment.
Respect final thinking overrides before dropping top_k
When a Claude request initially enables thinking but a model suffix such as (none) or a payload override disables it, ApplyRequestThinking and the override stage produce a final non-thinking request, yet this switch still marks thinking active from the pre-override source and deletes top_k. This silently changes a valid sampling configuration even though the upstream-invalid combination no longer exists; determine activity from the finalized canonical/transformed body so the established suffix and override precedence is preserved.
AGENTS.md reference: AGENTS.md:L29-L29
Useful? React with 👍 / 👎.
Summary
Remove
top_kfrom OpenAI-compatible payloads when a Claude request has active thinking.Claude clients may send
top_ktogether with extended/adaptive thinking. After Claude-to-OpenAI translation and payload overrides, that combination can reach a Claude-backed compatibility upstream and be rejected with-4003 top_k must be unset when thinking is enabled/adaptive.This change runs after payload overrides and:
thinking.type=enabled|adaptive|autoand non-noneeffort fields as active thinking;top_k;top_kfor non-Claude, no-thinking, and explicit-nonerequests;Both streaming and non-streaming execution paths are covered.
Tests
go test -count=1 -run 'TestNormalizeOpenAICompatClaudeSampling|TestOpenAICompatExecutorUsesCompatibleClaudeTranslation|TestNormalizeClaudeSamplingForUpstream' ./internal/runtime/executorgo build -buildvcs=false -trimpath -o /tmp/cpa-pr2-build ./cmd/server