Skip to content

refactor(coderd/x/chatd)!: drop the provenance fallback for unstamped OpenAI reasoning - #31001

Closed
ibetitsmike wants to merge 1 commit into
mike/chatd-inline-provider-identityfrom
mike/chatd-retire-unstamped-reasoning
Closed

ibetitsmike wants to merge 1 commit into
mike/chatd-inline-provider-identityfrom
mike/chatd-retire-unstamped-reasoning

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

This PR breaks compatibility with old chat histories. It affects OpenAI reasoning parts that carry provider state (a reasoning item ID or encrypted content) but no provenance stamp. That is every such part written before #30298, which no release includes yet, so chats from released versions have them. The sanitizer used to borrow the row's model config as their provenance and replay them on that provider and model. Now OpenAI reasoning state counts as foreign unless its stamp matches the turn. The PR deletes unstampedReasoningProvenance, its two callers, and the shortcut that skipped native rows without parsing them. Coder Agents is experimental (coderd/x), and our rule for experimental persisted data is to drop the legacy shape outright and delete the helpers that existed only to parse it, instead of carrying a migration.

What old chats do now: on the next turn, turn preparation removes those parts from the prompt. The stored messages do not change, and the UI still shows them. An assistant row that held only such a part leaves the prompt. The model no longer sees that earlier reasoning, which is what already happens after a provider switch. Nothing fails, and no error appears. Plain reasoning text without provider state is still replayed. The encrypted-reasoning rejection fallback and the per-source epochs do not change.

Why it is safe

  • Current writers stamp every completed reasoning part (buildCommitStepMessages), and interrupted partial messages carry reasoning text without provider metadata. Reasoning now ignores its row's origin, so the origin map stores only the provider identity.
  • I mutated each behavior the rewritten tests guard and ran ./coderd/x/chatd/ with go test -overlay. The tests catch all 11 mutants: a stamp comparison that ignores model, credential or epoch; plain reasoning treated as state; unstamped state kept; a constant target credential; an epoch that is not restored or not bumped after a rejection; and a lost origin identity.
  • Deleted cases that covered only unstamped behavior: same instance with a different config keeps unstamped reasoning; unstamped reasoning from another model is dropped; unstamped reasoning follows its row origin; and the unstamped row in the earlier-epoch case. git grep unstampedReasoningProvenance finds nothing.

Review focus

Every assistant row in the history head is now parsed on each turn, because an unstamped part can appear in any row.

Validation

  • go test ./coderd/x/chatd/ -count=1 -p 4 -parallel 4: ok
  • go vet and golangci-lint run --fix=false ./coderd/x/chatd/...: clean; pre-commit hook: passed

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
  4. refactor(coderd/x/chatd): inline the model config provider identity #31000 inline the model config provider identity
  5. refactor(coderd/x/chatd)!: drop the provenance fallback for unstamped OpenAI reasoning #31001 drop the provenance fallback for unstamped OpenAI reasoning (this PR)
  6. refactor(coderd/x/chatd)!: drop the context-limit fallback for old compaction summaries #31002 drop the context-limit fallback for old compaction summaries
  7. refactor(coderd/x/chatd)!: retire the close_agent tool alias #31003 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-18T19:01:31.875529Z 41a8b8a 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. Swish!

Reviewed commit: 41a8b8a4fe

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

Copy link
Copy Markdown
Collaborator Author

Closing this PR. Mike chose to keep this fallback for now (decision D6). Every released version still writes OpenAI reasoning without the provenance stamp, because #30298 is in no release yet. Retiring the fallback now would stop existing chats from replaying their earlier reasoning. It can be retired after a release that includes #30298.

The rest of the deprecation stack continues as stack #31006: #30996, #30997, #30998, #31000 and #31005. #31005 carries the close_agent change from #31003. The branch stays in place.

Xum, an AI agent, closed this PR for @ibetitsmike.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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