Repository navigation
fix: run queued messages on the chat's model when theirs is unavailable - #31632
Conversation
This comment has been minimized.
This comment has been minimized.
|
Chat: Review posted | View chat Review history
deep-review v0.13.0 | Round 1 | Last posted: Round 1, 7 findings (2 P2, 1 P3, 1 P4, 3 Nit), COMMENT. Review Finding inventoryFinding inventory: PR #31632Findings
Contested and acknowledgedRound logRound 1Netero first pass: 1 P2 (CRF-1), panel proceeded. Full panel (round 1): ging-go, ging-ts, ging-react, nami, ryosuke, melody (specialists); pariston, mafuuu (core); bisky, hisoka, gon, leorio (pool); zoro (wildcard). Multi-domain (Go + TS), 12 + wildcard. Result: 2 P2, 1 P3, 1 P4, 3 Nit posted; 4 dropped; 2 OOS; 3 Notes. Gon P2 on transitions.go:350 settled at P3 (comment ambiguity, no behavior defect). CI test-go-pg and test-go-pg-17 failed; logs unreadable (gh HTTP 401), local runs of affected packages pass. Reviewed against 3d0fd60..49c87f4. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
This PR makes queued-message promotion try the chat's last model before the organization default, and makes a queued edit with an untouched picker send the picker's model when the row's model is not selectable. Findings: 2 P2, 1 P3, 1 P4, 3 Nit.
CI jobs test-go-pg and test-go-pg-17 fail at 49c87f4. The review runner could not read their logs (GitHub API returned 401), and the chatstate, chatd, and coderd queue tests pass locally at this head, so whether the failures come from this diff is unverified. Read the failed test names in those logs before merging.
Out of scope (needs a ticket or explicit acceptance by a human):
coderd/x/chatd/chatd.go:884:resolveFallbackModelConfigID,resolveModelConfig(chatd.go:1931), andchatstate.resolveQueuedMessageModelConfigIDeach implement "use this model if available, else the default" with different rules (daemon vs owner authorization,IsNotAuthorizedErrorhandling,DeriveEffectiveChatModelConfigsvs anIsDefaultscan), so the same unavailable model can resolve to different models on the send, promotion, and generation paths.coderd/x/chatd/chat_mutations.go:397:EditMessagewithout a model passes the edited message's model toresolveFallbackModelConfigID, which skips the chat's last model, so an API client editing a message whose model is unavailable gets the organization default; the comment atchat_mutations.go:390says this path resolves "like a normal message send", which is no longer true.
Notes:
submitChatTurn.ts:378writes the picker's model into the row at save time. Without that change, the server would pick the chat's last model at promotion time. The two differ when the picker shows a user-selected model other than the chat's last model, or when the chat's last model changes between save and promotion.submitChatTurn.ts:378:modelOptionsexcludes models whose provider the user has no key for (utils/modelOptions.ts:258-263), so a row on such a model now saves with the picker's model, as a history edit does.transitions.go:360: every promotion path passes achatread before the transaction inserts messages (for exampleFinishInterruptioninserts partial messages beforeadvanceQueue), so the chat-model candidate is the value from before those inserts. The result is the same today because a turn runs only onchat.LastModelConfigIDor the default.
🤖 This review was automatically generated with Coder Agents.
| chat database.Chat, | ||
| queued database.ChatQueuedMessage, | ||
| ) (uuid.NullUUID, error) { | ||
| //nolint:gocritic // Queue promotion needs daemon access to deployment model configuration. |
There was a problem hiding this comment.
P2 [CRF-2] A queued row whose model was removed from the owner's model ACL still runs on the organization default and moves the chat off its model, because promotion checks candidates with dbauthz.AsChatd. (Pariston)
GetEnabledChatModelConfigByID under AsChatd returns the row's model B, so promotion keeps B; InsertChatMessages sets last_model_config_id to B (chats.sql:1020), then resolveModelConfig (chatd.go:1938-1961) reads B with the owner's authorization, gets a not-authorized error from the ACL check (dbauthz.go:4160-4166), and selects the default. That is the first row of the PR table (runs on A, chat moves to A) for the ACL case, while the frontend already treats B as unavailable because modelOptions is owner-filtered. This is inferred from the code and not run; a chatd test with an ACL-restricted row model, a chat on an available model, and an owner outside the ACL would confirm it. Check the candidates with the chat owner's model authorization, as resolveModelConfig does.
🤖
There was a problem hiding this comment.
Reproduced through the API on this branch and on main: a queued row on an ACL-removed model is kept by promotion, the turn runs on the default, and the chat moves to it. Same on main, so not caused by this PR. Tracked in CODAGT-1521 with the repro patch, together with the three fallback paths using different rules.
🤖 Posted using
/amend-reviewskill via Coder Agents.
|
In reply to CRF-12 (P3, Tracked in CODAGT-1521. In reply to CRF-13 (P3, Tracked in CODAGT-1521, including the comment at In reply to AMREM-1 (P3, Not caused by this PR:
|
…eued rows A queued row whose model is no longer available was promoted onto the organization default even when the chat ran on another available model, which also moved the chat to the default. Try the chat's last model before the default, the same order as a message sent without a model.
…le queued rows Saving a queued edit without touching the picker omitted the model, so a row whose model was no longer available kept it until promotion. Send the picker's model in that case, the rule history edits already use.
The fallback-to-default cases put the chat on the organization default, so promotion returned the chat's model and never reached the default lookup. Their chats now use an unavailable model of the same kind as the queued row, so the asserted model can only come from the default.
The doc comment read as if only the queued row's model was checked. The chat's last model is a NOT NULL column, so its candidate is always valid.
da2e103 to
853a70a
Compare
A queued message whose stored model is no longer available (model disabled, provider disabled, or model deleted) ran on the organization default, even when the chat was on another available model. The chat's last model then moved to the default, so the picker changed after the turn.
resolveQueuedMessageModelConfigID) now tries the queued row's model, then the chat's last model, then the organization default. This is the orderSendMessagealready uses for a message sent without a model.isUnavailableHistoricalModelID, the rule history edits use). An available row still keeps its model unless the user picks one during the edit.A = organization default, B = the unavailable model, C = the available model the chat last ran on.
model_config_idomitted, row keeps B, runs on AEditMessagewithout a model uses a separate resolver (resolveFallbackModelConfigIDwith the edited message's model,chat_mutations.go) that still skips the chat's last model. This PR leaves it as is; when the edited message's model is unavailable, the UI already sends the picker's model.coderd/x/chatd/ARCHITECTURE.mddescribes the new promotion order in "Organization-local model selection and fallback".Tests:
TestPromoteQueuedMessageResolvesOrganizationModel/disabled_model_falls_back_to_chat_model(chatstate). Before the fix it gets the default instead of the chat's model.AgentChatPage.test.tsx"saving a queued edit sends the picker's model when the row's model is no longer available", added to the existing queued-save table. Before the fix it getsmodel_config_id: undefined.Refs CODAGT-971