Skip to content

fix: skip media-only messages from summarization pipeline#130

Open
semiok wants to merge 1 commit intoMartian-Engineering:mainfrom
semiok:fix/skip-media-only-summarization
Open

fix: skip media-only messages from summarization pipeline#130
semiok wants to merge 1 commit intoMartian-Engineering:mainfrom
semiok:fix/skip-media-only-summarization

Conversation

@semiok
Copy link
Contributor

@semiok semiok commented Mar 19, 2026

Summary

Messages containing only media attachments (e.g., an image with no accompanying text) produce near-empty source text (~28 tokens of MEDIA:/... file path metadata) that cannot be meaningfully compressed by the summarizer. These messages waste an API call every compaction cycle and can produce garbage summaries.

  • Add isMediaOnlyContent() helper that strips MEDIA:/ file path references and checks if remaining text is below 50 characters
  • Filter media-only messages before building the concatenated text for summarization in leafPass()
  • If an entire chunk is media-only, skip the leaf pass entirely (return null) with a warning log
  • File ID extraction and source message linking still use the full messageContents array — no metadata is lost

Observed instance (from issue #124)

sum_66d17b5e39bd7460 (34 tokens): a media-only message (MEDIA:/...png + timestamp) with only 84 chars of text_content hit the fallback path and produced a garbage summary.

Test plan

  • Send image-only messages, verify they are skipped during compaction
  • Send image + text messages, verify they are still summarized normally
  • Verify file IDs from media-only messages are still preserved in summary metadata
  • Check logs for skipping leaf chunk: all N messages are media-only when applicable

Closes #124

🤖 Generated with Claude Code

Messages containing only media attachments (no meaningful text) produce
near-empty source text that wastes summarizer API calls every compaction
cycle. Filter out messages with fewer than 50 characters of actual text
content after stripping MEDIA:/ file path references.

Closes Martian-Engineering#124

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Skip media-only messages from summarization pipeline

1 participant