Skip to content

refactor(coderd)!: retire the V0 chat message content decoder - #30998

Draft
ibetitsmike wants to merge 1 commit into
mike/chatprompt-drop-legacy-codec-testsfrom
mike/chatprompt-retire-legacy-codec
Draft

ibetitsmike wants to merge 1 commit into
mike/chatprompt-drop-legacy-codec-testsfrom
mike/chatprompt-retire-legacy-codec

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

This PR breaks compatibility with chat messages stored in the legacy content format (chat_messages.content_version = 0). Messages written before v2.32 have it: migration 000434 (#23042) stamped every existing row with version 0, and nothing converts them later. The PR deletes the legacy decoder from chatprompt: ContentVersionV0, parseLegacyContent and its per-role parsers, the fantasy envelope detector isFantasyEnvelopeFormat, ExtractFileID, and the legacy tool-row type toolResultRaw. Coder Agents is experimental (coderd/x), so we drop legacy persisted shapes and the helpers that parse them outright instead of carrying a migration.

What happens to those messages: ParseContent now returns unsupported content version 0. Throwaway API tests on this head show the effect on a chat with version 0 rows:

  • GET /api/v2/chats/{chat}/messages returns 200, but the version 0 messages have no content.
  • A send to a waiting or errored chat, and an edit, first parse the last assistant message (for an edit, the last one before the edited message) to cancel its pending tool calls. If it is version 0, they return 500 (Failed to create chat message. or Failed to edit chat message., detail execute transaction: parse assistant message: unsupported content version 0). By code reading, promote does the same.
  • Otherwise they return 200, and an edit deletes the edited message and every later one. If a version 0 row remains before the new message, the turn fails in the worker (build chat prompt: unsupported content version 0) and the chat goes to error.
  • Recovery: editing the first user message deletes it and every later row, so a new turn runs; another send alone leaves the chat in error. Chats created through the API before v2.32 cannot recover this way: each starts with its system prompt stored as a version 0 row, which no edit deletes, so their users must start a new chat.

Chats with only version 1 rows do not change.

Why it is safe

  • New content is always written as CurrentContentVersion (1), and content_version is NOT NULL with no default, so no new row gets version 0.
  • The tests of the legacy format were removed in the layer below. Every mutant that main catches, out of the 17 listed in test(coderd): stamp chat message fixtures with the current content version #30996, is still caught on this head.
  • git grep for each removed symbol across the repository, including site/, enterprise/, cli/, docs/ and scripts/, finds nothing on this head. Before this PR, the only hit outside chatprompt.go was coderd/exp_chats_test.go, which now writes the version as a literal 0. That test checks that the SQL jsonb_typeof guard skips scalar JSON rows.

Review focus

Version 0 rows now take the existing unsupported content version branch of ParseContent; the PR adds no new error path.

Validation

  • go test ./coderd/x/chatd/... ./coderd/database/db2sdk/ -count=1 -p 4 -parallel 4: ok
  • go test ./coderd/ ./enterprise/coderd/ -run '(?i)chat|agent|mcp|skill' -count=1 -p 4 -parallel 4: ok
  • golangci-lint run --fix=false ./coderd/x/chatd/chatprompt/...: 0 issues; pre-commit hook: passed
  • Throwaway API tests (not committed) of GET, send and edit with version 0 rows: results above

Stack

This stack retires chatd compatibility paths for chat data that older Coder versions stored.

  1. test(coderd): stamp chat message fixtures with the current content version #30996 stamp chat message fixtures with the current content version
  2. test(coderd/x/chatd/chatprompt): drop tests of the legacy content codec #30997 drop tests of the legacy content codec
  3. refactor(coderd)!: retire the V0 chat message content decoder #30998 retire the V0 chat message content decoder (this PR)
  4. refactor(coderd/x/chatd): inline the model config provider identity #31000 inline the model config provider identity
  5. refactor(coderd/x/chatd)!: retire the close_agent tool alias #31005 retire the close_agent tool alias

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T18:48:28.901420Z 0b8dee0 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 0b8dee0a5b

ℹ️ 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 removed this pull request from stack #30999 October 18, 2026 19:27
@ibetitsmike
ibetitsmike added this pull request to stack #31006 October 18, 2026 19:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/breaking This label is applied to PRs to detect breaking changes as part of the release process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant