Skip to content

fix(openai): treat OPENAI_BASE_URL as a custom endpoint - #4773

Merged
aheritier merged 1 commit into
docker:mainfrom
oyobbeb:fix/openai-base-url-env
Oct 31, 2026
Merged

aheritier merged 1 commit into
docker:mainfrom
oyobbeb:fix/openai-base-url-env

Conversation

@oyobbeb

@oyobbeb oyobbeb commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #4594

With provider: openai, no base_url and OPENAI_BASE_URL pointing at a local server, requests go to that server, but the endpoint checks only read base_url and treat the client as api.openai.com:

  • preserve_reasoning: true replays encrypted OpenAI reasoning items to the local server.
  • Explicit prompt-cache breakpoints are sent and consecutive system messages are not merged, which is the vLLM/Qwen case shouldMergeConsecutiveMessages exists for.

NewClient already resolves the endpoint (base_url, then OPENAI_BASE_URL, then the default) into BaseURL, and pricing reads it for the same reason. The three checks now use base_url when set and that resolved endpoint otherwise. With a gateway, BaseURL stays the default and base_url still decides, so nothing changes there. The chatgpt branch of firstPartyResponses is left alone, since its resolved BaseURL defaults to api.openai.com rather than the ChatGPT backend.

TestResponseStateOpenAIBaseURLEnv builds a client with OPENAI_BASE_URL set 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 and go 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.

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>
@oyobbeb
oyobbeb requested a review from a team as a code owner October 30, 2026 06:31
@aheritier aheritier added area/providers/openai For features/issues/fixes related to the usage of OpenAI models kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Oct 30, 2026

@aheritier aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 aheritier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@aheritier
aheritier added this pull request to the merge queue Oct 31, 2026
Merged via the queue into docker:main with commit c3c6e56 Oct 31, 2026
16 checks passed
trungutt pushed a commit to trungutt/docker-agent that referenced this pull request Nov 5, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers/openai For features/issues/fixes related to the usage of OpenAI models kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

preserve_reasoning treats OPENAI_BASE_URL as a first-party OpenAI destination

2 participants