fix: complete metadata stripping for all channel sentinel patterns (#211)#310
Closed
fix: complete metadata stripping for all channel sentinel patterns (#211)#310
Conversation
…pture - Add 3 missing sentinel labels to stripEnvelopeMetadata regex - Expand shouldCapture fallback regex to cover all 6 sentinels - Make stripLeadingInboundMetadata handle non-leading metadata blocks Fixes #211 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
Author
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
Feishu channel metadata was leaking into stored memories because metadata stripping had three coverage gaps. The reporter provided Feishu samples confirming the leak.
Root cause
AUTO_CAPTURE_INBOUND_META_SENTINELSdefines 6 sentinel labels, but the three stripping functions only covered a subset:stripEnvelopeMetadatashouldCapturestripLeadingInboundMetadataFixes
stripEnvelopeMetadatainsrc/smart-extractor.ts): AddedThread starter,Forwarded message context, andChat history since last replyto the regex alternation.shouldCapturefallback inindex.ts): ExpandedmetadataPatternregex to cover all 6 sentinel labels, with a parenthetical pattern that handles both(untrusted metadata):and(untrusted, for context):forms.stripLeadingInboundMetadatainindex.ts): Rewrote to scan the entire text for sentinel + JSON blocks instead of only stripping from the beginning. Metadata appearing after user content is now removed.Test plan
strip-envelope-metadatatests passFixes #211
🤖 Generated with Claude Code