feat: remove chat chain mode - #26980
Conversation
Docs preview📖 View docs preview for |
…repareMessages hook
|
/coder-agents-review |
|
Chat: Review posted | View chat Review history
deep-review v0.9.0 | Round 1 | Last posted: Round 1, 7 findings (2 P3, 2 Nit, 3 Note), COMMENT. Review Finding inventoryFindings
Contested and acknowledged(none) Round logRound 1Panel (15 reviewers). 0 P0, 0 P1, 0 P2, 2 P3, 2 Nit, 3 Note posted. 5 dropped (comment verbosity subsumed by pattern note). Reviewed against 121107f..e38f363. About deep-reviewCRF = Coder Review Finding (P0-P4, Nit, Note)
|
|
Smoke-tested in workspace. |
There was a problem hiding this comment.
Pull request overview
Removes OpenAI Responses “chain mode” from chatd so every follow-up turn replays full history rather than relying on previous_response_id, simplifying retry and error-classification logic and avoiding provider chain-state loss edge cases.
Changes:
- Deletes chain-mode activation/detection code and related tests, plus chain-broken classification and retry bookkeeping.
- Removes
chain_brokenmetric label and stops persistingchat_messages.provider_response_id(column retained for rollback). - Cleans up dead chatloop hooks and stale chain-mode comments, regenerating DB/metrics artifacts accordingly.
Reviewed changes
Copilot reviewed 34 out of 37 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/metricsdocgen/generated_metrics | Updates generated metric label set for coderd_chatd_stream_retries_total. |
| docs/admin/integrations/prometheus.md | Updates Prometheus docs for removed chain_broken label. |
| coderd/x/chatd/message_conversion.go | Stops mapping step ProviderResponseID into DB message conversion. |
| coderd/x/chatd/message_conversion_test.go | Updates tests to remove ProviderResponseID expectations and rename test. |
| coderd/x/chatd/integration_responses_test.go | Removes chain-mode-specific integration tests and request recorder fields. |
| coderd/x/chatd/generation.go | Removes chain-mode-disabled retry state and chain_broken logging; drops ProviderResponseID propagation. |
| coderd/x/chatd/generation_preparer.go | Removes chain-mode activation and prompt filtering in generation preparation. |
| coderd/x/chatd/context_prompt.go | Updates sentinel-path comment now that chain-mode tests are gone. |
| coderd/x/chatd/chattest/openai.go | Removes previous_response_id decoding from OpenAI test request struct. |
| coderd/x/chatd/chatstate/messages.go | Removes ProviderResponseID from chatstate insert parameter assembly. |
| coderd/x/chatd/chatopenai/responses.go | Deletes chain-mode implementation for OpenAI Responses. |
| coderd/x/chatd/chatopenai/responses_test.go | Deletes chain-mode unit tests for OpenAI Responses. |
| coderd/x/chatd/chatloop/metrics.go | Removes chain_broken label and related formatting in stream retry metric. |
| coderd/x/chatd/chatloop/metrics_test.go | Updates metric tests for new label set and removes chain-broken case. |
| coderd/x/chatd/chatloop/chatloop.go | Removes persisted ProviderResponseID capture and deletes unused RunOptions hooks (PrepareMessages, DisableChainMode, ReloadMessages). |
| coderd/x/chatd/chaterror/classify.go | Removes chain-broken classification and the ChainBroken field from ClassifiedError. |
| coderd/x/chatd/chaterror/classify_test.go | Deletes tests covering chain-broken classification propagation. |
| coderd/x/chatd/chatdebug/service_test.go | Removes ProviderResponseID field seeding in debug service tests. |
| coderd/x/chatd/chatd.go | Stops writing ProviderResponseID on chat message insert params; updates related comments and structs. |
| coderd/x/chatd/chatd_test.go | Removes chain-mode-dependent assertions and switches to full-replay expectations. |
| coderd/x/chatd/chatd_retry_test.go | Updates retry logging/metric assertions to remove chain_broken. |
| coderd/x/chatd/chatd_helpers_test.go | Introduces shared active-server test helpers previously housed in chain-mode test file. |
| coderd/x/chatd/chatd_chainmode_test.go | Deletes chain-mode active-server tests. |
| coderd/x/chatd/chatadvisor/runtime.go | Updates provider-options cloning/reset comments and removes PreviousResponseID reset logic. |
| coderd/x/chatd/chatadvisor/runner.go | Updates advisor runner comment to match new provider-options reset behavior. |
| coderd/x/chatd/chatadvisor/runner_test.go | Updates advisor tests to validate Store isolation instead of PreviousResponseID behavior. |
| coderd/x/chatd/attempt.go | Removes ProviderResponseID from step durable data struct. |
| coderd/database/queries/chats.sql | Removes provider_response_id from CreateChatMessages insert and deletes the clear query. |
| coderd/database/queries.sql.go | Regenerates sqlc output reflecting removed insert arg and deleted clear query. |
| coderd/database/querier.go | Removes the clear query from the querier interface. |
| coderd/database/querier_test.go | Updates tests to use new InsertChatMessages params without ProviderResponseID. |
| coderd/database/dbmock/dbmock.go | Regenerates mocks to remove ClearChatMessageProviderResponseIDsByChatID. |
| coderd/database/dbmetrics/querymetrics.go | Removes query-metrics wrapper for the deleted clear query. |
| coderd/database/dbgen/dbgen.go | Stops passing ProviderResponseID into message inserts when seeding chat messages. |
| coderd/database/dbgen/dbgen_test.go | Updates generator test to remove ProviderResponseID assertions. |
| coderd/database/dbauthz/dbauthz.go | Removes dbauthz wrapper for the deleted clear query. |
| coderd/database/dbauthz/dbauthz_test.go | Removes authz method test coverage for the deleted clear query. |
Files not reviewed (3)
- coderd/database/dbmetrics/querymetrics.go: Generated file
- coderd/database/dbmock/dbmock.go: Generated file
- coderd/database/querier.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Removes OpenAI Responses "chain mode" from chatd. Chain mode sent
previous_response_idon follow-up turns instead of replaying full history, saving input tokens on long chats. Referencing stored responses was not observed to work consistently: the provider would periodically report a stored response ID as unknown (most likely pruned after a retention period; zero-data-retention orgs and API key rotation are other suspects), and each new provider error format broke the chain-broken classifier that drove recovery. Every turn now replays full input, accepting larger requests on long chats in exchange for a recovery-free path.Closes CODAGT-445.
Changes
chatopenai/responses.go(chain detection, activation, prompt filtering, response ID extraction) and its tests.ChainBrokenclassification inchaterrorand the chatloop retry bookkeeping that disabled chain mode mid-generation.chain_brokenlabel from thecoderd_chatd_stream_retries_totalmetric.chat_messages.provider_response_id; delete the deadClearChatMessageProviderResponseIDsByChatIDquery. The column stays on disk for rollback safety; dropping it is a follow-up migration.ReloadMessages,DisableChainMode,PrepareMessages), the deadAgentChatContextSentinelPathconstant, and stale chain-mode comments.Not touched: the aibridge
provider_response_idcolumns (unrelated feature), theStoreprovider option, which now only controls provider-side response retention (whether to keep it at all is a follow-up), and thego.modfantasy fork (carries 13 other changes; only its replay-safety item related to chain mode, and that logic still protects full replay).Follow-ups
chat_messages.provider_response_idafter a release cycle: CODAGT-748.Storeoption now that it has no in-product consumer.coder/fantasynow that no consumer sendsprevious_response_id.Implementation plan
Executed in three phases on this branch:
test(coderd/x/chatd): drop chain mode test coverage): deleted chain-mode tests:chatopenai/responses_test.go, sixTestActiveServer_ChainBroken*tests,TestClassify_ChainBroken*,TestAdvisorChainMode_SnapshotKeepsFullHistory,TestOpenAIResponsesChainMode*.chatd_chainmode_test.gowas renamed tochatd_helpers_test.gobecause it housed shared helpers used by ~20 other test sites.feat(coderd/x/chatd): remove chain mode): deletedchatopenai/responses.goentirely; the chain activation block ingeneration_preparer.go;ChainModeDisabledplumbing and thechain_brokenlog field ingeneration.go;ChainBrokenandchainBrokenClassificationinchaterror; thechain_brokenmetric label;PersistedStep.ProviderResponseIDin chatloop; thePreviousResponseIDreset in chatadvisor (Store=false behavior kept);ProviderResponseIDfrom internal step structs, chatstate params, and theCreateChatMessagesINSERT; the deadClearChatMessageProviderResponseIDsByChatIDquery with its dbauthz wrapper; regenerated DB and metrics artifacts viamake gen.chore(coderd/x/chatd): drop dead ReloadMessages hook and stale chain comments): removed the orphanedReloadMessageschatloop hook and reworded three stale chain-mode comments.Deliberately skipped: shrinking the
RecordStreamRetrysignature (theClassifiedErrorparam enforces that callers classify errors viachaterror.Classifybefore recording), merging the chatadvisor clone/reset helpers (the clone is required for correctness: the reset mutates the options map in place), and any change togeneration_preparer.go'spromptRowsfetch (verified still multi-purpose).Verification:
make build,make gen(no diff on re-run),make fmt,make lint, andgo test ./coderd/x/chatd/... ./coderd/database/dbauthz/...all pass locally with postgres.🤖 Generated by Coder Agents on behalf of @johnstcn.