Conversation
… (issue #2057) PR #2053 added MemorySourceHint to suppress false-positive injection detection for memory retrieval in the context assembly path (assembly.rs). However, the tool_execution path for memory_search was not covered. Memory_search returns recalled conversation turns from semantic memory (SQLite/Qdrant). Without proper classification, benign recalled content (e.g., user discussing "system prompt") triggered injection false positives → Qdrant embedding was skipped for the entire turn. This fix: 1. Adds memory_search detection in sanitize_tool_output() (tool_execution/mod.rs) 2. Classifies it as ContentSourceKind::MemoryRetrieval with ConversationHistory hint 3. This enables the MemorySourceHint suppression logic (sanitizer/lib.rs:321-328) 4. Aligns tool_execution path with assembly.rs:698 (context assembly path) Defense-in-depth remains: truncation, control char stripping, delimiter escaping, and spotlighting with <external-data> wrapper all remain active. Only injection pattern regex detection is suppressed (which was the source of false positives). Tested: 6093 unit tests pass (+3 new), zero regressions.
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
This PR fixes GitHub issue #2057:
memory_searchtool output was not covered by theMemorySourceHintfalse-positive suppression added in PR #2053.Root Cause
PR #2053 fixed false-positive injection detection in the context assembly path (
assembly.rs), but the tool execution path (tool_execution/mod.rs) formemory_searchwas missed.When users recalled memory containing phrases like "system prompt", the sanitizer incorrectly flagged it as a potential injection pattern →
Qdrant embedding was skippedfor the entire turn → semantic recall quality degraded over time.Fix
tool_name == "memory_search"insanitize_tool_output()ContentSourceKind::MemoryRetrievalwithMemorySourceHint::ConversationHistorysanitizer/lib.rs:321-328assembly.rs:698(context assembly path already uses the same classification)Defense-in-Depth
All structural defenses remain active:
</external-data>cannot break out)<external-data>wrapper (ExternalUntrusted trust level)Only injection pattern regex detection is suppressed (the source of the false positives).
Validation
Files Changed
crates/zeph-core/src/agent/tool_execution/mod.rs— add memory_search branch (7 lines)crates/zeph-core/src/agent/tool_execution/tests.rs— add 3 regression tests (45 lines)CHANGELOG.md— add entry to[Unreleased]Fixed sectionCloses #2057.