Repository navigation
fix(openai): treat OPENAI_BASE_URL as a custom endpoint - #4773
Conversation
The endpoint checks behind preserve_reasoning, explicit prompt-cache breakpoints and consecutive-message merging read only base_url, so a client pointed at a local server through OPENAI_BASE_URL was treated as api.openai.com. Use the endpoint NewClient resolved when base_url is unset. Fixes docker#4594 Signed-off-by: Yeongbin Jeong <oyobbeb@gmail.com>
aheritier
left a comment
There was a problem hiding this comment.
Reviewed all three changed files against #4594. No substantive code defect found. The endpoint checks now account for OPENAI_BASE_URL when base_url is absent, while preserving explicit endpoint precedence and existing gateway/ChatGPT handling. The added regression test exercises client construction, opaque-state replay rejection, and consecutive-system-message merging.
Validation: patch applicability check passed. Tests were not run locally against this exact head; the author's reported test/lint results were not independently verified.
CI operational status: BLOCKED. Both ci and codeql completed with action_required and no jobs. The head has no check runs or commit statuses, and the required gate is absent. CI must run successfully before approval. CI run: https://github.com/docker/docker-agent/actions/runs/41014599272. The PR is non-draft and conflict-free, but mergeable_state is blocked.
Issue context: Reviewed #4594 and the relevant history in #4363, #4365, #4485, and openai/openai-go#558, including accessible comments, reviews, and threads. Earlier replay-policy proposals were superseded; this change remains scoped to endpoint classification. No Jira references or material acceptance-context gaps found.
aheritier
left a comment
There was a problem hiding this comment.
Reviewed the endpoint handling and regression coverage against #4594. The resolved endpoint is used to protect custom endpoints while preserving explicit base_url precedence. No substantive defects found. Required CI passed; the race job was skipped.
NativeToolSearchEnabled only read base_url, so with OPENAI_BASE_URL pointing at another server hosted tool search stayed on while docker#4773 turned response replay off, which tool search needs to keep its loaded tools. Add Config.Endpoint() and use it in NativeToolSearchEnabled and the three checks from docker#4773. Signed-off-by: Yeongbin Jeong <oyobbeb@gmail.com>
Fixes #4594
With
provider: openai, nobase_urlandOPENAI_BASE_URLpointing at a local server, requests go to that server, but the endpoint checks only readbase_urland treat the client as api.openai.com:preserve_reasoning: truereplays encrypted OpenAI reasoning items to the local server.shouldMergeConsecutiveMessagesexists for.NewClientalready resolves the endpoint (base_url, thenOPENAI_BASE_URL, then the default) intoBaseURL, and pricing reads it for the same reason. The three checks now usebase_urlwhen set and that resolved endpoint otherwise. With a gateway,BaseURLstays the default andbase_urlstill decides, so nothing changes there. Thechatgptbranch offirstPartyResponsesis left alone, since its resolvedBaseURLdefaults to api.openai.com rather than the ChatGPT backend.TestResponseStateOpenAIBaseURLEnvbuilds a client withOPENAI_BASE_URLset and checks that reasoning items aren't replayed and that the system messages are merged. Both checks fail on main.go test ./pkg/model/..., golangci-lint andgo run ./lint .pass.@MysticalMount offered a follow-up in the issue and I didn't see one yet, so here it is. Happy to close this if you already have a branch.