ensure thread.history_mode is immutable#30261
Merged
Merged
Conversation
| self.observe_items_with_update(items, ThreadMetadataPatch::default()) | ||
| let mut update = self.observe_items_with_update(items, ThreadMetadataPatch::default())?; | ||
| // Later SessionMeta lines do not redefine the canonical history_mode. | ||
| update.history_mode = Some(canonical_history_mode_from_rollout_items(items)); |
Contributor
There was a problem hiding this comment.
seems possibly slightly inefficient to re-scan the items to rederive the old history mode, vs just omitting history mode from the ThreadMetadataPatch? But minor
Collaborator
Author
There was a problem hiding this comment.
actually, much cleaner to omit it from ThreadMetadataPatch entirely. updated
wiltzius-openai
approved these changes
Jun 26, 2026
wiltzius-openai
left a comment
Contributor
There was a problem hiding this comment.
this avoid the metadata sync rewriting the value; do we also need to forbid it in the app server APIs that can mutate metadata (or was it never exposed)?
Collaborator
Author
yeah, we only allow |
anp-oai
approved these changes
Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR makes
thread.history_modeimmutable after the thread's canonical firstSessionMetahas been written. Later same-threadSessionMetalines are compatibility metadata writes, not a new thread definition.Without this, an older binary could append a
SessionMetathat omitshistory_mode; when a newer binary replays it, serde defaults that missing field tolegacyand SQLite could downgrade a paginated thread.Why
history_modeis the persisted thread storage contract. Paginated-thread fail-closed behavior and SQLite memory filtering depend on it staying aligned with canonical rollout metadata, especially when multiple Codex binary versions can touch the same local rollout.What changed
history_modefrom laterSessionMetaitems.history_modefromThreadMetadataPatch, so mutable metadata sync and app-server metadata updates cannot rewrite it.history_modefrom the rollout's canonical firstSessionMetainstead of from a mutable patch.history_modeinstead of metadata patches.CreateThreadParamsinitializer with the newhistory_modefield; Bazel CI caught this after the parent history-mode PR landed.Validation
just fmtjust test -p codex-thread-storejust test -p codex-state session_meta_does_not_set_model_or_reasoning_effort