fix(core): skip native compaction windows that no longer decode by rekram1-node · Pull Request #57280 · anomalyco/opencode · GitHub
Skip to content

fix(core): skip native compaction windows that no longer decode - #57280

Merged
rekram1-node merged 1 commit into
v2.1from
tolerant-native-window
Oct 20, 2026
Merged

rekram1-node merged 1 commit into
v2.1from
tolerant-native-window

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

When history loaded a provider compaction whose native.messages didn't decode as @opencode/ai messages, the whole read failed with MessageDecodeError. That made the session unusable. Since #57241, a compaction hook's result.native is stored as-is, so one malformed plugin result could break a session for good.

Change

A window that doesn't decode is now treated like another model's window: it's skipped, and history falls back to the messages before it.

load history for model M
  latest compaction replayable on M?   (no native window, or same model AND window decodes)
    yes -> read from it, as before
    no  -> read from the compaction before it   (new: `latestCompaction(..., before)`)
  • decodeMessageRow no longer validates the window, so model-neutral readers such as store.context and the UI don't fail on it.
  • The window is checked only where it would be replayed (replayable). Replay already decoded it, so the cost is the same as the validation it replaces.

Verification

Package Command Result
core bun typecheck clean
core bun test 6660 pass, 8 fail (shell and test-environment tests, also failing on v2.1)
core native-compaction, runner, runner-message, compaction, projector, bus 354 pass

packages/core/test/session-native.test.ts "skips a malformed native window and replays the history before it" replaces the test that expected MessageDecodeError. With a malformed window stored between two prompts:

  • history replays both prompts;
  • store.context loads.

@rekram1-node
rekram1-node merged commit e71ef00 into v2.1 Oct 20, 2026
14 checks passed
@rekram1-node
rekram1-node deleted the tolerant-native-window branch October 20, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant