fix: reduce redundant envelope formatting for iMessage and Signal #1080
+20
−8
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
Cleans up message envelope formatting to reduce noise and improve readability for the agent. Previously, envelopes contained redundant information that cluttered the context window without adding value.
Problem
Messages were being formatted with unnecessary repetition:
DM envelopes showed the sender twice:
The
id:suffix is redundant when it matches the normalized sender.Group envelopes doubled the channel name:
"iMessage" appeared twice because
fromLabelwas set to "iMessage Group" while the channel was already "iMessage".Sender info appeared twice in group messages:
The
[from:]suffix detection didn't recognize senders appearing after the]bracket, so it added a redundant suffix even when the sender was already shown as a prefix.Solution
iMessage & Signal monitors:
id:suffix when the raw sender differs from the normalized sender (e.g., email vs phone normalization)Sender meta detection:
(^|\n)sender:to(^|\n|\]\s*)sender:to detect sender prefix after envelope header bracketsResult
Clean, non-redundant formatting:
[iMessage +1234567890 2026-01-17T07:24Z] Test[iMessage Group id:2 2026-01-17T07:23Z] +1234567890: TestTest plan
[from:]suffix not added when sender already prefixed