Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tyler6204
Copy link
Member

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:

  1. DM envelopes showed the sender twice:

    [iMessage +1234567890 id:+1234567890 2026-01-17T07:24Z] Test
    

    The id: suffix is redundant when it matches the normalized sender.

  2. Group envelopes doubled the channel name:

    [iMessage iMessage Group id:2 2026-01-17T07:23Z] +1234567890: Test
    

    "iMessage" appeared twice because fromLabel was set to "iMessage Group" while the channel was already "iMessage".

  3. Sender info appeared twice in group messages:

    [iMessage Group id:2 ...] +1234567890: Test
    [from: +1234567890]
    

    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:

  • Only append id: suffix when the raw sender differs from the normalized sender (e.g., email vs phone normalization)
  • Use just "Group" instead of "iMessage Group" / "Signal Group" since the channel name is already in the envelope

Sender meta detection:

  • Updated regex from (^|\n)sender: to (^|\n|\]\s*)sender: to detect sender prefix after envelope header brackets

Result

Clean, non-redundant formatting:

  • DM: [iMessage +1234567890 2026-01-17T07:24Z] Test
  • Group: [iMessage Group id:2 2026-01-17T07:23Z] +1234567890: Test

Test plan

  • Tested iMessage DM formatting
  • Tested iMessage group formatting
  • Tested Signal group formatting
  • Verified [from:] suffix not added when sender already prefixed
  • Unit tests updated and passing

@steipete steipete self-assigned this Jan 17, 2026
steipete added a commit that referenced this pull request Jan 17, 2026
@steipete
Copy link
Contributor

Landed on main after rebasing onto latest main, added clarifying comments + changelog entry, and ran pnpm lint/build/test.

Commits:

Thanks @tyler6204!

@steipete steipete closed this Jan 17, 2026
TSavo pushed a commit to TSavo/clawdbot that referenced this pull request Jan 18, 2026
rsneh pushed a commit to rsneh/clawdbot that referenced this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants