GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(session): store turn summaries as names and counts, compute patches on request by lihaokun · Pull Request #57 · lihaokun/opencode

Conversation

@lihaokun

@lihaokun lihaokun commented Oct 11, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Owner

Base branch: dev. The default branch main only takes promotion PRs from dev.

Issue for this PR

No issue of ours; found while diagnosing an earlyoom kill (opencode at 47 GB RSS) and a 52 GB opencode-dev.db. The same defect is open upstream as anomalyco#43551, anomalyco#42748, anomalyco#48641, anomalyco#46833, anomalyco#50089 and anomalyco#48616; three upstream fixes (anomalyco#48245, anomalyco#49715, anomalyco#50106) were closed unmerged. The clock-ordering problem met during review is tracked separately as #56.

Type of change

  • Bug fix

What does this PR do?

Every turn, SessionSummary.summarize diffed the two workspace snapshots and stored the full-context patch of every changed file in the user message's summary.diffs. The durable message.updated event copied the whole message on each write. On a session where the agents regenerated ~1,400 tracked log files per compile, one turn's summary was 1,264 files / 244 MB; the message row was 249 MB, two of them were rewritten in the four minutes before the kill, and event.data held 41 GB of message.updated.1 rows. The model never sees this field; it is UI metadata.

Summaries now store names and counts. Snapshot.diffStat runs git diff --name-status and --numstat and nothing else: no file content enters the process. summarize stores {file, additions, deletions, status}, writes the turn's aggregate into the session-level summary, and publishes the list on session.diff (previously an empty array, so the TUI sidebar's "Modified Files" was always empty). File names are unquoted so stored rows, the event and the endpoint agree.

Patches are computed on request. GET /session/:id/diff recomputes diffFull from the turn's step-start/step-finish snapshot hashes when a client asks. Files over 1 MB on either side get counts only; once a response's patches reach 8 MB the rest get counts only; if cat-file --batch-check cannot report sizes, every file gets counts only. Without a messageID the endpoint returns the latest turn's stored list, which is what the TUI asks on opening a session. Messages that still carry stored patches keep serving them. Snapshot objects are pruned after 7 days, so a turn older than that shows names and counts only — the documented trade-off (Claude Code keeps 100 checkpoints / 30 days; ZCode records only the agent's own edits; neither stores workspace-wide patches).

Writes are bounded. The processor schedules one summary per step and releases them together; they are now coalesced per message (one running, at most one waiting) and a result equal to the stored one is not written again, while a turn that changed nothing still writes once so the counts reset. A git failure during comparison is a Snapshot.DiffError that writes nothing, instead of an empty list that would read as "nothing changed".

FileDiff.patch was already optional in the schema: no schema or SDK change, no TUI change. Desktop app and cli export already guard a missing patch.

Design, upstream comparison (table), review record and the three test layers: docs/fixes/session-fix-summary-diff-size.md.

README (second commit, folded in from #58). The fork notice at the top of README.md becomes a positioning section: an independent branch that no longer submits changes upstream and merges upstream updates selectively; the Agent management tools and TUI surface; the session-layer stability work with its fix documents; the branch and release model; the development workflow. Feature and stability differences only. Translated READMEs untouched.

How did you verify your code works?

  • Basic/edge: test/session/summary.test.ts (10 cases: large file never enters the message and the message stays under 2 KB; patches recomputed on request with the per-file cap; legacy stored patches served; latest turn without a message id; a quiet turn resets counts and clears the list; six concurrent summaries write once; quoted file names; no snapshots) and test/snapshot/snapshot.test.ts (+3: diffStat vs diffFull, per-file cap, per-response cap).
  • Random (seeded, cross-checked against git numstat): 12 random change sets (diffStat equals diffFull minus patch; patch withheld iff over cap; patch +/- line counts equal numstat), 8 random turns (stored equals diffStat, message size bounded by file count, aggregate correct, diff() does not write back, idempotent), 6 random multi-turn sessions (latest turn vs named turn).
  • Independent review (doc + diff, then code): 5 findings, 4 fixed, 1 accepted; recorded in the doc.
  • Regression: test/session, test/snapshot, test/server — 942 pass; the 14 httpapi-sdk.test.ts failures reproduce on unmodified dev (local 503/health), 2 concurrency timeouts pass alone. bun typecheck clean.
  • The random multi-turn test flaked under load until its clock was replaced with a counter: this machine's clock steps backwards (journald "Time jumped backwards"), which also makes ascending ids and message order go backwards in product code — ascending ids and message order go backwards when the system clock steps back #56.

Checklist

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lihaokun
fix(session): store turn summaries as names and counts, compute patch…
6a3b64c
…es on request

Each turn's summary embedded the full-context patch of every file that
changed in the workspace, and the durable message.updated event copied it
on every write. One turn that regenerated a thousand tracked logs produced
a 249 MB user message; the process reached 47 GB and was killed, and the
event table grew to 44 GB. Upstream carries the same code and six open
issues for it; three fixes there were closed unmerged.

The summary now stores file names, line counts and status from git
numstat; nothing is read into memory. The diff endpoint computes patches
from the turn's snapshot hashes when asked, with a per-file and a
per-response size limit. Summaries scheduled for the same message are
coalesced and written once; a result equal to what is stored is not
written again, while a turn that changed nothing still writes once to
reset the session's counts. Session-level counts and the session.diff
event now carry the turn's file list. A git failure during comparison is
an error that writes nothing, not an empty change set. Stored file names
are unquoted, matching the endpoint.

Design, upstream comparison, review record and test layers are in
docs/fixes/session-fix-summary-diff-size.md.
@github-actions github-actions Bot added the needs:issue label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented Oct 11, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lihaokun lihaokun mentioned this pull request Oct 11, 2026
docs: position the fork in the README #58
Closed
3 tasks done
@lihaokun
docs: position the fork in the README
13074b0
The fork notice becomes a section: what the fork is, that it no longer
submits changes upstream and merges upstream updates selectively, the
Agent management tools and TUI surface that replace the task tool, the
session-layer stability work with its fix documents, the branch and
release model, and the development workflow. Feature and stability
differences only; the upstream README follows unchanged.
@lihaokun
lihaokun merged commit 8b94e1b into dev Oct 11, 2026
14 checks passed

Uh oh!

There was an error while loading. Please reload this page.

This was referenced Oct 12, 2026
大型日志合并后 snapshot/diff 摘要膨胀,OpenCode RSS 达 43 GiB 被 earlyoom 强杀 #52
Closed
升级到 #57 之后旧库仍带全文 patch,长会话每步解析导致内存锯齿;需要一次性迁移或清理命令 #61
Closed
chore: promote dev to main as v1.18.31-fmv2.1 #64
Merged
上游工作流绑定 Blacksmith 运行器,在 fork 里永远排队:停用不适用的工作流 #68
Closed
撤回时若该轮快照已被清理,会把那一轮改过的文件直接删除(数据丢失) #70
Open
评估:迁移到上游 opencode v2 的代价与决策 #71
Open
lihaokun added a commit that referenced this pull request Oct 14, 2026
@lihaokun
chore: promote dev to main as v1.18.31-fmv2.1 (#64)
e81af70
Promotes release-fmv2.1, cut from dev at d9d7de3: #48, #43, #53, #54, #55, #57, #59, #63.
@lihaokun
lihaokun deleted the slim-summary branch October 14, 2026 16:56
@lihaokun lihaokun mentioned this pull request Nov 25, 2026
opencode 长时存活进程 GC 死亡螺旋导致 TUI 无响应 #16
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

needs:issue

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@lihaokun
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.