Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(coderd/x/chatd): read the OpenAI transport from the model - #27704

Merged
ibetitsmike merged 1 commit into
mainfrom
mike/codagt-874-transport-ownership
Aug 4, 2026
Merged

refactor(coderd/x/chatd): read the OpenAI transport from the model#27704
ibetitsmike merged 1 commit into
mainfrom
mike/codagt-874-transport-ownership

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #27703.

Provider option conversion, reasoning effort injection, and file part acceptance each recomputed the OpenAI wire format from (provider, modelID, override). They now read it from chatprovider.Model, so a decision cannot drift from the client it was built for.

ProviderOptionsFromChatConfig takes a Transport, ApplyReasoningEffort takes a Model, and AcceptsFilePartMediaType becomes a Model method. UsesResponsesAPI and UsesResponsesOptions are deleted. The override extraction is unexported and reachable only from ModelFromConfig, which now takes the model's ChatModelOpenAIConfig directly, removing the six scattered extractions at call sites.

That also resolves the computer-use mismatch. The computer-use model is a hardcoded default with no config row of its own: its client was built without an override while request preparation applied the chat model's. Preparation now reads the computer-use model's own transport, so the two agree without one model's client settings following a different model. Passing the chat model's openai_config into the computer-use client would have made them agree on the wrong value.

TestModelTransportConsumersAgree pins the invariant in one test: the HTTP path the client actually hits, the concrete provider option struct type, the type created by reasoning effort, and text/image file acceptance.

Mux prepared this PR on Mike's behalf.

@linear-code

linear-code Bot commented Jul 30, 2026

Copy link
Copy Markdown

CODAGT-874

ibetitsmike commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator Author

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 41114c9bb2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike marked this pull request as ready for review August 2, 2026 20:34
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from 41114c9 to 52526f5 Compare August 3, 2026 14:12
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 52526f56a3

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from 52526f5 to ab47d63 Compare August 3, 2026 14:35
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: ab47d63f4f

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from ab47d63 to b94cf5c Compare August 3, 2026 14:52
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: b94cf5ce51

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from b94cf5c to b30188d Compare August 3, 2026 15:10
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: b30188dff8

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from b30188d to 928159c Compare August 3, 2026 15:25
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 928159c3a2

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from 928159c to 78bbb7f Compare August 3, 2026 15:37
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 78bbb7f65b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from 78bbb7f to 366afbe Compare August 3, 2026 15:45
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 366afbeebf

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from 366afbe to 87ae792 Compare August 3, 2026 18:30
Base automatically changed from mike/codagt-874-model-wrapper to main August 4, 2026 07:46
ibetitsmike added a commit that referenced this pull request Aug 4, 2026
…del wrapper (#27703)

Stacked on #27683.

The OpenAI wire format is decided when the client is built, then thrown
away, so downstream sites recompute it from `(provider, modelID,
override)`. Any disagreement fails silently: the SDK type-asserts the
concrete provider options struct and discards every OpenAI option, and
text attachments are dropped because Responses natively accepts only
images and PDFs.

This adds `chatprovider.Model`, which pairs a fantasy client with the
transport resolved from that client's own identity. Its fields are
unexported and only the constructor sets the transport, deriving it from
the client, so no caller can pick a transport that disagrees with the
client it wraps. `chatopenai.Transport`'s zero value is invalid and
panics when read rather than defaulting to a wire format, following the
existing precedent for construction invariants.

`Model` is threaded through construction, the resolve paths, and the
four struct fields that store a model for later request preparation.
Terminal call sites keep taking `fantasy.LanguageModel` and receive
`LanguageModel()`, which avoids a new package edge from `chatloop` and
`chatadvisor` into `chatprovider`.

No decisions move yet. The consumers still recompute the transport, and
`UsesResponsesAPI` now delegates to `TransportFor` so the two agree by
construction. #27704 makes the consumers read it from the model.

> Mux prepared this PR on Mike's behalf.
Provider option conversion, reasoning effort injection, and file part
acceptance each recomputed the OpenAI wire format from (provider, modelID,
override). Read it from chatprovider.Model instead, so a decision cannot
drift from the client it was built for.

ProviderOptionsFromChatConfig now takes a Transport, ApplyReasoningEffort
takes a Model, and AcceptsFilePartMediaType becomes a Model method.
UsesResponsesAPI and UsesResponsesOptions are deleted, and the override
extraction is unexported and reachable only from ModelFromConfig, which now
takes the model's ChatModelOpenAIConfig directly. The six scattered
extractions at call sites are gone.

That also resolves the computer-use mismatch. The computer-use model is a
hardcoded default with no config of its own, and its client was built
without an override while preparation applied the chat model's. Preparation
now reads the computer-use model's own transport, so the two agree without
the chat model's client settings following a different model.
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-transport-ownership branch from 87ae792 to b62d8ea Compare August 4, 2026 07:47
@ibetitsmike
ibetitsmike merged commit 0e16e35 into main Aug 4, 2026
29 checks passed
@ibetitsmike
ibetitsmike deleted the mike/codagt-874-transport-ownership branch August 4, 2026 08:00
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants