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

Skip to content

refactor(coderd/x/chatd): carry the resolved OpenAI transport on a model wrapper - #27703

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

refactor(coderd/x/chatd): carry the resolved OpenAI transport on a model wrapper#27703
ibetitsmike merged 1 commit into
mainfrom
mike/codagt-874-model-wrapper

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

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.

@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. Another round soon, please!

Reviewed commit: 6f8e920e4e

ℹ️ 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-model-wrapper branch from 6f8e920 to e39a87f 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. 🚀

Reviewed commit: e39a87ffc4

ℹ️ 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-model-wrapper branch from e39a87f to 135919a 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. 🚀

Reviewed commit: 135919a6e6

ℹ️ 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-model-wrapper branch from 135919a to 03e2109 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. Another round soon, please!

Reviewed commit: 03e2109b4e

ℹ️ 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-model-wrapper branch from 03e2109 to 09913d5 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. Nice work!

Reviewed commit: 09913d5c68

ℹ️ 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-model-wrapper branch from 09913d5 to 91a45b7 Compare August 3, 2026 15:25
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91a45b785d

ℹ️ 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".

Comment thread coderd/x/chatd/chatprovider/model.go
Comment thread coderd/x/chatd/chatprovider/model.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-model-wrapper branch from 91a45b7 to cc87ed6 Compare August 3, 2026 15:37
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc87ed6c48

ℹ️ 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".

Comment thread coderd/x/chatd/chatprovider/model.go
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-model-wrapper branch from cc87ed6 to 3fd9597 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. 🚀

Reviewed commit: 3fd9597e48

ℹ️ 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-model-wrapper branch from 3fd9597 to 90332b4 Compare August 3, 2026 18:30
@ibetitsmike
ibetitsmike requested a review from ThomasK33 August 4, 2026 06:58
Base automatically changed from mike/codagt-874-responses-api-toggle to main August 4, 2026 07:30
…del wrapper

The OpenAI wire format is decided when the client is built, then thrown
away, so four downstream sites recompute it from (provider, modelID,
override). Any disagreement fails silently: provider options are discarded
by an SDK type assertion, and text attachments are dropped.

Introduce chatprovider.Model, pairing a fantasy client with the transport
resolved from that client's own identity. Its fields are unexported, so no
other package can mint a Model whose transport disagrees with its client.
chatopenai.Transport's zero value is invalid and panics when read rather
than defaulting to a wire format, following chatdebug.WrapModel's precedent
for construction invariants.

Thread Model 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 to chatprovider.

No decisions move yet: the four consumers still recompute the transport.
UsesResponsesAPI now delegates to TransportFor so both agree by
construction.
@ibetitsmike
ibetitsmike force-pushed the mike/codagt-874-model-wrapper branch from 90332b4 to 05e2700 Compare August 4, 2026 07:33
@ibetitsmike
ibetitsmike merged commit b5c9e8e into main Aug 4, 2026
29 checks passed
@ibetitsmike
ibetitsmike deleted the mike/codagt-874-model-wrapper branch August 4, 2026 07:46
@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