#13026: matrix: optionally include media metadata in message.read
channel: matrix
cli
agents
size: M
Cluster:
Matrix Media Handling Fixes
## Summary
- add an optional `includeMedia` flag to Matrix `message.read` actions
- when enabled, include media metadata (`mxcUrl`, `downloadUrl`, content type, size, duration, encrypted flag) in read results
- keep default behavior unchanged to preserve compatibility
- expose the new option through the message tool schema and CLI
- add unit tests for both legacy and includeMedia paths
## Why
`message.read` was returning only simplified fields (e.g. body/msgtype), which dropped media URLs needed for Matrix voice workflows. This patch keeps existing defaults while enabling explicit media retrieval when needed.
## Testing
- `pnpm vitest extensions/matrix/src/matrix/actions --run`
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds an optional `includeMedia` flag to Matrix `message.read`/`readMessages` so callers can request media-related metadata (mxc URL, downloadable URL via `mxcToHttp`, content type, size, duration, and an `encrypted` indicator derived from the selected URL source). The option is plumbed through the Matrix message action adapter (`extensions/matrix/src/actions.ts`), the Matrix tool-action handler (`extensions/matrix/src/tool-actions.ts`), and exposed in the global message tool schema and CLI (`src/agents/tools/message-tool.ts`, `src/cli/program/message/register.read-edit-delete.ts`).
Core behavior remains backward compatible by default: `summarizeMatrixRawEvent` only adds the `media` field when `includeMedia` is true, and tests cover both legacy and includeMedia paths, including the plaintext-vs-encrypted URL precedence logic.
<h3>Confidence Score: 4/5</h3>
- This PR appears safe to merge; changes are localized and maintain backward-compatible defaults.
- Review of the full diff shows the new `includeMedia` option is consistently threaded through adapter/tool-action layers into Matrix message summarization. Tests cover legacy behavior and media extraction (including encrypted-vs-plain URL selection), and there are no new callers that would break existing response consumers since `media` is optional. Unable to run tests in this environment due to missing Node/pnpm, so score is slightly reduced.
- extensions/matrix/src/matrix/actions/summary.ts (media extraction contract)
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
## AI-assisted disclosure
- [x] Mark as AI-assisted in the PR title or description
- [x] Note the degree of testing (lightly tested)
- [x] Include prompts or session logs if possible
- [x] Confirm you understand what the code does
**Testing degree:** Lightly tested (targeted Matrix action tests: `pnpm vitest extensions/matrix/src/matrix/actions --run`).
**Prompt/session log (summary):**
- "Add optional `includeMedia` support for Matrix `message.read` while preserving backward compatibility by default."
- "Thread the option through tool schema/CLI and add tests for legacy vs includeMedia paths."
**Confirmation:** I reviewed the final diff and understand the new optional media metadata behavior and compatibility impact.
Most Similar PRs
#10313: fix(matrix): fallback to authenticated media download (Matrix v1.11+)
by iter-next · 2026-02-06
75.9%
#13832: feat(matrix): add sessionScope and thread-scoped inbound sessions
by yamoroc · 2026-02-11
73.6%
#23333: fix(matrix): add accountId routing for multi-account message sending 🤖
by BadTurki · 2026-02-22
72.9%
#10721: fix for matrix media: destructure downloadContent return value in m...
by mklasen · 2026-02-06
72.8%
#8852: fix(matrix): Await mxcToHttp to properly detect authenticated media...
by emadomedher · 2026-02-04
72.4%
#14996: feat(matrix): pass asVoice flag through message tool and add wavefo...
by mauldus · 2026-02-12
72.1%
#14227: fix(matrix): pass asVoice to audioAsVoice for native voice messages
by tfm-neo-ai · 2026-02-11
72.1%
#19868: fix: prevent media token regex from matching markdown bold text
by sanketgautam · 2026-02-18
71.3%
#16940: fix(matrix): send voice messages as native voice bubbles
by zerone0x · 2026-02-15
71.0%
#19399: telegram: fix MEDIA false positives and partial final drop
by HOYALIM · 2026-02-17
70.6%