Skip to content

fix: retain file changes across conversation compaction - #123467

Merged
steipete merged 1 commit into
mainfrom
steipete/fileops-provenance
Aug 14, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/fileops-provenance

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where file identities could disappear from compacted conversation history when coding tools used accepted path aliases, namespaced tool names, or apply_patch. After compaction, the surviving <read-files> and <modified-files> blocks could therefore omit files the agent had actually read or changed.

Why This Change Was Made

File-operation extraction now normalizes the open-ended namespace prefix, selects the first string path from path, file_path, or filePath, and consumes the structured apply_patch result summary instead of parsing patch text. Added files are recorded as writes, modified files as edits, and deleted files are intentionally omitted because they no longer exist for a continuation to inspect. Nearby accumulator and summary formatting logic was consolidated so production code shrinks by four lines.

User Impact

Agents retain accurate read and modified file context across ordinary compaction, branch summaries, and repeated compactions, including MCP-projected tools and multi-file patches. Unknown tools remain ignored.

Evidence

  • Pre-fix: node scripts/run-vitest.mjs packages/agent-core/src/harness/compaction/utils.test.ts failed exactly the path-alias, namespaced-name, and apply_patch provenance cases (3 failed, 14 passed).
  • Post-fix: node scripts/run-vitest.mjs packages/agent-core/src/harness/compaction/utils.test.ts (17 passed).
  • pnpm tsgo passed.
  • pnpm tsgo:core:test passed.
  • Structured autoreview reported no accepted/actionable findings.
  • Production numstat: +60/-64 (net -4); tests: +128/-1.

@clawsweeper

clawsweeper Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 14, 2026 04:45
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 14, 2026
@steipete
steipete merged commit 9122db3 into main Aug 14, 2026
187 checks passed
@steipete
steipete deleted the steipete/fileops-provenance branch August 14, 2026 04:59
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 15, 2026
steipete added a commit that referenced this pull request Oct 15, 2026
* refactor(packages): consolidate protocol and stream ownership

Use one tuple-preserving ordered literal-union constructor without changing
Gateway protocol JSON, exported shapes, or static inference. Share Anthropic
request, refusal, reducer, compaction and terminal ownership while preserving
the SDK/fetch adapters and their error profiles. Reuse the existing abort race.

Reuse prepared compaction details and table widths, trust typed internal file
metadata inputs, and leave the Agent loop as the sole message-snapshot owner.
Replace the primitive-only session-options deep clone with a shallow copy.
Remove write-only transport scratch indices and duplicate outer cleanup; reuse
prepared Markdown token projections. Route Completions context budgeting through
the shared calibrated CJK estimator, correcting underestimated rare/halfwidth
and supplementary input. Add request-budget regression cases.

Best-effort tradeoffs accepted:
- Malformed internal assistant/tool-name values violating AgentMessage can
  throw instead of being silently omitted. The guards came from extractions
  #85341/#123467, with no cited human malformed-message incident. External
  tool arguments and patch-result metadata remain validated.
- An impossible table column/width mismatch no longer gets a custom error.
  The removed throw came from strict-index ratchet #104577, not an actual-use
  report; columns and widths still come from the same ordered allocation.

No Phase E standalone session-memory backend, security authority, public
protocol/config/SDK contract, schema, dependency or durability change.

* test(plugins): make cancellation ownership fixture deterministic

Hold the Anthropic fixture's second pull on its existing cleanup gate so the
custom cancellation work is actually admitted before testing its ownership.
An upstream fetch abort may otherwise error the wrapper before cancel runs,
making the test demand settlement of work that was never accepted.

Keep every origin-context, drainage, lifetime and reuse assertion unchanged.
No production behavior, timeout, retry or skip changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…aw#172991)

* refactor(packages): consolidate protocol and stream ownership

Use one tuple-preserving ordered literal-union constructor without changing
Gateway protocol JSON, exported shapes, or static inference. Share Anthropic
request, refusal, reducer, compaction and terminal ownership while preserving
the SDK/fetch adapters and their error profiles. Reuse the existing abort race.

Reuse prepared compaction details and table widths, trust typed internal file
metadata inputs, and leave the Agent loop as the sole message-snapshot owner.
Replace the primitive-only session-options deep clone with a shallow copy.
Remove write-only transport scratch indices and duplicate outer cleanup; reuse
prepared Markdown token projections. Route Completions context budgeting through
the shared calibrated CJK estimator, correcting underestimated rare/halfwidth
and supplementary input. Add request-budget regression cases.

Best-effort tradeoffs accepted:
- Malformed internal assistant/tool-name values violating AgentMessage can
  throw instead of being silently omitted. The guards came from extractions
  openclaw#85341/openclaw#123467, with no cited human malformed-message incident. External
  tool arguments and patch-result metadata remain validated.
- An impossible table column/width mismatch no longer gets a custom error.
  The removed throw came from strict-index ratchet openclaw#104577, not an actual-use
  report; columns and widths still come from the same ordered allocation.

No Phase E standalone session-memory backend, security authority, public
protocol/config/SDK contract, schema, dependency or durability change.

* test(plugins): make cancellation ownership fixture deterministic

Hold the Anthropic fixture's second pull on its existing cleanup gate so the
custom cancellation work is actually admitted before testing its ownership.
An upstream fetch abort may otherwise error the wrapper before cancel runs,
making the test demand settlement of work that was never accepted.

Keep every origin-context, drainage, lifetime and reuse assertion unchanged.
No production behavior, timeout, retry or skip changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant