feat(matrix): add optional AgentFirstModule metadata support#23815
feat(matrix): add optional AgentFirstModule metadata support#23815nepenth wants to merge 22 commits into
Conversation
40062e8 to
5584503
Compare
9d55a3c to
b8a722e
Compare
fa06076 to
3f9cf63
Compare
History cleanupRebased and cleaned commit history for reviewability.
|
34f8545 to
18f395e
Compare
v2026.5.16 refreshRebased this Matrix PR stack onto current upstream main after the v2026.5.16 / v0.14.0 release. Notes:
|
Draft optional enhancementThis PR is intentionally marked draft while the core Matrix stack (#18505, #18506, #18507) is reviewed first. It is optional and should not be treated as required for the standard Matrix gateway functionality. Depends on
Scope
Non-goal |
45c6b64 to
7851604
Compare
5a3daea to
3db09ec
Compare
3db09ec to
bff674c
Compare
|
Retiring this PR from the active Matrix stack for now. The custom Synapse/AgentFirst metadata integration adds non-standard homeserver-side coupling and increases review surface for the core Matrix work. We are keeping the upstreamable Hermes Matrix stack focused on the foundation, native Matrix tools/interactions, and media/E2EE/diagnostics PRs, and can reassess AgentFirst/Synapse metadata later if we pursue a cleaner upstream Synapse/MSC path. |
Summary
This is PR 4 in the Matrix gateway parity series and should be reviewed after
#18505, #18506, and #18507.
It adds optional support for structured Matrix agent metadata emitted by the
companion Synapse module
AgentFirstModule.The integration is intentionally optional. Standard Matrix homeservers do not
emit this metadata, and the Matrix adapter falls back to existing behavior when
the fields are absent.
Why
The first three Matrix PRs add the foundation, native Matrix tools/interactions,
and Matrix rendering/media/E2EE/diagnostics hardening.
This PR adds the optional enhancement layer for deployments that want richer
agent-native Matrix behavior from their homeserver:
Changes
Matrix adapter
unsigned.MessageEvent.agent.SessionSource.Session context
SessionSource.agent_metadata.SessionSource.apply_agent_metadata().session_scope=roomby clearing synthetic thread scope for the turn.room_identityonly when the metadata room ID matches the actual Matrix room ID.Agent UI helpers
gateway/agent_ui.pywith small rendering helpers for approval request and tool status payloads.Docs/tests
Security / Compatibility
Validation
Passed locally:
python -m py_compile \ gateway/platforms/matrix.py \ gateway/session.py \ gateway/platforms/base.py \ gateway/agent_ui.py scripts/run_tests.sh \ tests/gateway/test_matrix_agentfirst_metadata.py \ tests/gateway/test_matrix.py \ tests/gateway/test_matrix_project_context_isolation.py \ tests/gateway/test_matrix_exec_approval.py \ tests/tools/test_matrix_tools.py \ -q -o 'addopts=' git diff --checkResult:
Stack
Builds on:
This PR should be reviewed after the first three Matrix PRs.