Skip to content

fix(memory): soft-delete orphaned messages with legacy-only tool content#2534

Merged
bug-ops merged 1 commit intomainfrom
fix-2529-orphaned-tool-pair-soft-delete
Mar 31, 2026
Merged

fix(memory): soft-delete orphaned messages with legacy-only tool content#2534
bug-ops merged 1 commit intomainfrom
fix-2529-orphaned-tool-pair-soft-delete

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 31, 2026

Summary

  • strip_mid_history_orphans only soft-deleted messages when content was empty. Messages retaining legacy bracket strings ([tool_use: ...], [tool_result: ...]) after part-stripping were never soft-deleted, causing the orphan WARN to repeat on every session restart.
  • Add has_meaningful_content() helper that strips all three tool bracket formats before deciding emptiness. Body-skip search uses PREFIXES-based lookup to avoid false negatives when tool output contains JSON arrays or code with [ characters.
  • Update three check sites in strip_mid_history_orphans and load_history.
  • Add 20 unit tests for has_meaningful_content and 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 passed
  • cargo nextest run -p zeph-core -E 'test(issue_2529)' — 3 passed
  • Full suite: 7604/7604 passed
  • cargo clippy --all-targets --features full --workspace -- -D warnings — clean

@github-actions github-actions bot added documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate bug Something isn't working labels Mar 31, 2026
…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
@github-actions github-actions bot added the size/XL Extra large PR (500+ lines) label Mar 31, 2026
@bug-ops bug-ops force-pushed the fix-2529-orphaned-tool-pair-soft-delete branch from 6e63fcf to 6689f50 Compare March 31, 2026 13:38
@bug-ops bug-ops enabled auto-merge (squash) March 31, 2026 13:38
@bug-ops bug-ops merged commit 1b202bb into main Mar 31, 2026
27 checks passed
@bug-ops bug-ops deleted the fix-2529-orphaned-tool-pair-soft-delete branch March 31, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(memory): orphaned tool-pair messages not soft-deleted when content field is non-empty

1 participant