← Back to PRs

#13026: matrix: optionally include media metadata in message.read

by yamoroc open 2026-02-10 02:13 View on GitHub →
channel: matrix cli agents size: M
## 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