Skip to content

fix(opencode): stop storing full patch text in session summary diffs - #40861

Open
KirillDeviatka wants to merge 4 commits into
anomalyco:devfrom
KirillDeviatka:bound-summary-diffs
Open

fix(opencode): stop storing full patch text in session summary diffs#40861
KirillDeviatka wants to merge 4 commits into
anomalyco:devfrom
KirillDeviatka:bound-summary-diffs

Conversation

@KirillDeviatka

@KirillDeviatka KirillDeviatka commented Aug 6, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #32005

Related: #17622, #20990 (and earlier attempts #32410 / #33892 that were auto-closed)

Type of change

  • Bug fix

What does this PR do?

SessionSummary.summarize() previously stored the full Snapshot.diffFull() result — including complete patch text — on user message.summary.diffs. That payload is written into an append-only message.updated.1 event log on every step-finish, so a multi-step turn that touches large files can grow the event table by multiple GB and OOM/Jetsam on reopen.

This change:

  1. Stores only lightweight metadata (file, status, additions, deletions) in durable summaries
  2. Drops common vendor/generated paths (e.g. node_modules/, .node-runtime/) from durable summaries
  3. Makes SessionSummary.diff() recompute full patches on demand from snapshots (with legacy stored-metadata fallback)

Complementary to open #40821 (scope summary to session-touched files). This PR focuses on payload size, not path scoping.

How did you verify your code works?

  • bun test test/session/summary-diffs.test.ts — PASS (strip patch; drop vendor/.node-runtime)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Related PRs Found:

  1. fix(session): scope changed file summary to session edits #40821 - fix(session): scope changed file summary to session edits

  2. fix(core): bound event log compaction #36710 - fix(core): bound event log compaction

    • Related to event log management and preventing unbounded growth, which connects to the issue of the event table growing too large.

Note: The PR description also references earlier attempts (#32410 and #33892 that were auto-closed) and the original issue #32005, which suggests this is a revisited fix for a known problem with session diff storage payload sizes.

@KirillDeviatka

Copy link
Copy Markdown
Author

Note on overlap with #40821: that PR scopes diffFull to session-touched paths (which files); this one strips durable patch text / vendor paths (how much is stored). Complementary, same summary.ts. Happy to rebase onto #40821 once it lands.

Persist only file/status/additions/deletions on the user message. Full
patches stay reconstructable via SessionSummary.diff()/computeDiff().
Also drop common vendor/.node-runtime paths from durable summaries.

Fixes anomalyco#32005

Co-authored-by: Cursor <cursoragent@cursor.com>
KirillDeviatka and others added 3 commits August 7, 2026 08:20
Add size-bound, Windows path, and no-patch cases for compactSummaryDiffs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@KirillDeviatka

Copy link
Copy Markdown
Author

Local verification after updating onto latest dev (CI workflows still awaiting maintainer approval for first-time contributor runs):

bun test test/session/summary-diffs.test.ts   # 5 pass
bun test test/session/{summary-diffs,session,revert-compact}.test.ts  # 18+ pass previously; summary-diffs expanded
bun run typecheck   # packages/opencode — pass

Expanded summary-diffs tests now cover patch stripping, vendor/.node-runtime/dist deny, Windows separators, and a size regression asserting compacted payload stays << full-patch JSON.

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.

event table bloat from message.updated.1 causes OOM when loading old sessions

1 participant