Repository navigation
Guard the condense swap against memory appended during the summary - #79
Merged
Merged
Conversation
Condensing reads memory.md, waits on a summary call that can take minutes, then renames the rebuilt file over the original. Anything an agent appended in between was overwritten by the rename and lost. The swap now re-reads memory.md as raw bytes just before the rename and compares it with the snapshot the summary was built from: - bytes appended after the snapshot are carried onto the new file verbatim, re-checking up to three rounds while the file keeps growing; - any other change aborts with source-changed (the next pass retries from the new file), and a missing or unreadable file aborts with source-check-failed; - a source that is not valid UTF-8 is refused before the summary call (source-encoding-invalid), since a lossy decode would corrupt it; - the temp file is removed on every failure path, and a successful swap logs carriedBytes. The not-smaller back-off on the autonomous loop is unchanged. Ported from upstream PR HarnessMD#842 (commits 9a560db, 6143a40, ef78130).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Condensing could lose memory appended while the summary call was running: the rebuilt file was renamed over the original without checking whether the original had changed.
Ported from upstream HarnessMD#842 (commits 9a560db test, 6143a40 fix, ef78130 tidy), squashed into one commit. One conflict was resolved: this fork's not-smaller back-off in the autonomous loop is kept, and only the read changes to raw bytes.
Fix
source-changed, a missing or unreadable file aborts withsource-check-failed, and a non-UTF-8 source is refused before the LLM call.carriedBytes.Evidence
Before
After
Typecheck is clean. Tested on macOS. No UI change.