fix(memory): soft-delete orphaned messages with legacy-only tool content#2534
Merged
fix(memory): soft-delete orphaned messages with legacy-only tool content#2534
Conversation
…ent (#2529) strip_mid_history_orphans only soft-deleted messages when content was completely empty. Messages with legacy bracket strings (e.g. [tool_use: memory_save(...)]) in content were never soft-deleted, causing the orphan WARN to repeat on every session restart. Add has_meaningful_content() helper that strips [tool_use:], [tool_result:], and [tool output:] bracket markers before deciding whether content is meaningful. The body-skip search uses PREFIXES-based lookup to avoid false negatives when tool output contains JSON arrays or other bracket characters. Update the three emptiness-check sites in strip_mid_history_orphans and load_history. Add 20 unit tests and 3 integration tests covering the regression scenario, idempotency across sessions, and the mixed text+tool-tag preservation invariant. Closes #2529
6e63fcf to
6689f50
Compare
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.
Summary
strip_mid_history_orphansonly soft-deleted messages whencontentwas empty. Messages retaining legacy bracket strings ([tool_use: ...],[tool_result: ...]) after part-stripping were never soft-deleted, causing the orphanWARNto repeat on every session restart.has_meaningful_content()helper that strips all three tool bracket formats before deciding emptiness. Body-skip search usesPREFIXES-based lookup to avoid false negatives when tool output contains JSON arrays or code with[characters.strip_mid_history_orphansandload_history.has_meaningful_contentand 3 integration tests for the regression scenario, session idempotency, and mixed text+tool-tag preservation.Closes #2529
Test plan
cargo nextest run -p zeph-core -E 'test(meaningful_content)'— 20 passedcargo nextest run -p zeph-core -E 'test(issue_2529)'— 3 passedcargo clippy --all-targets --features full --workspace -- -D warnings— clean