Skip to content

preserve_reasoning treats OPENAI_BASE_URL as a first-party OpenAI destination #4594

Open

Description

@MysticalMount

Description

pkg/model/provider/openai decides whether a destination is first-party OpenAI in Client.firstPartyOpenAIDestination, which reads ModelConfig.BaseURL. openai.NewClient resolves the effective endpoint differently — base_url, then OPENAI_BASE_URL, then https://api.openai.com/v1 — and stores that result on the embedded config (base.Config.BaseURL). The OpenAI Go SDK also honours OPENAI_BASE_URL on its own.

A model config that names no base_url but points the environment at a local server is therefore classified as first-party OpenAI.

Expected Behavior

provider_opts.preserve_reasoning should not replay encrypted OpenAI reasoning items to an endpoint that is not OpenAI. The first-party determination should consider the endpoint requests actually go to, the way reasoning replay now does in #4485 (Client.effectiveBaseURL).

Actual Behavior

With provider: openai, no base_url, and OPENAI_BASE_URL=http://localhost:8080/v1:

  • firstPartyOpenAIDestination() returns true, so preservesResponseState() is on and reasoning items captured from OpenAI are replayed to the local server.
  • shouldMergeConsecutiveMessages has the same blind spot — it also reads the config field — though that one only affects consecutive-message merging.

Reaching it takes an explicit preserve_reasoning: true, so the blast radius is narrow, but the effect is the opposite of what firstPartyResponses' own comment intends ("Opaque state must not leak to a different vendor's compatible endpoint").

Steps to Reproduce

  1. Configure provider: openai with provider_opts: {preserve_reasoning: true} and no base_url.
  2. Export OPENAI_BASE_URL=http://localhost:8080/v1 against llama.cpp or vLLM.
  3. Run a turn that captures reasoning items, then inspect the next request body.

Additional context

Found while fixing #4363 in #4485. That PR deliberately leaves this path alone: it predates the PR, belongs to the Responses mechanism rather than Chat Completions, and changing it there would widen a review that is already about a different default. Happy to follow up with a PR.

Activity

  1. added theissue type on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/providers/openaiFor features/issues/fixes related to the usage of OpenAI models

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions