Skip to content

fix(agent-runtime): keep file ops from the folded compaction tail - #1984

Merged
vastsa merged 1 commit into
vastsa:mainfrom
xpeng5278-web:fix/compaction-fileops-tail
Oct 29, 2026
Merged

vastsa merged 1 commit into
vastsa:mainfrom
xpeng5278-web:fix/compaction-fileops-tail

Conversation

@xpeng5278-web

Copy link
Copy Markdown
Contributor

Fixes #1983

What

codexShapedPreparation now copies pi's fileOps and records Read/Write/Edit calls from the retainedTail it folds into the summarized range (via the existing collectMessageFileOperations, now exported from pi-runtime-compaction-plan.ts). The sets pi returned are left untouched. The comment on prepareCompactionInput and the spec paragraph on checkpoint file lists are updated to match.

Why

The fold summarizes and drops the tail, but file ops were collected only for the pre-fold range, so files read or edited inside the keepRecentTokens window disappeared from the checkpoint's readFiles / modifiedFiles and from <read-files> / <modified-files> in the summary.

How tested

  • runtime.test.ts: records file operations from tool calls folded out of the retained tail (large keepRecentTokens; asserts fileOps and <modified-files> / details.modifiedFiles in the generated summary) fails on unmodified main (expected [] to deeply equal [ 'src/a.ts' ]) and passes with this change. does not duplicate file operations already collected before the fold covers the small-keepRecentTokens path.
  • packages/agent-runtime: full vitest 113 files / 1564 tests pass; tsc --noEmit clean; pnpm lint:biome and scripts/check-architecture.mjs pass.

Scope

runtime.ts (codexShapedPreparation), one export in pi-runtime-compaction-plan.ts, test, and one spec paragraph. No change to the cut point, retention, or summary prompt.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently confirmed #1983 by restoring main's runtime.ts while keeping the regression: folded Read src/a.ts is present in summarized messages but fileOps.read is empty. Restored candidate passes 370/370 runtime tests; full runtime suite passes 115 files / 1584 tests, shared/runtime builds and diff check pass. Reviewed collection against the actual folded range: copies existing sets, adds only retained-tail operations, preserves previous-checkpoint operations and de-duplicates paths; retention and persistence contracts remain unchanged. All six remote checks pass including Windows/Host and Electron E2E. Latest main 3684cc4 is ancestor, and PR integration tree equals tested head d30b4778408bf48c6c28576b91a448c0f336d937. Local verification covers production runtime preparation and generated summary with controlled model boundary; standalone local Electron/paid-provider E2E not run. Minimal root-cause fix ready to merge.

@vastsa
vastsa merged commit ec77831 into vastsa:main Oct 29, 2026
6 checks passed
kylinmac added a commit to kylinmac/mc-agent that referenced this pull request Oct 30, 2026
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.

[Bug] Compaction summary drops the most recently read/edited files from <read-files> / <modified-files>

2 participants