Handle leading mentions in Matrix messages
CI / checks (push) Skipped
CI / checks (pull_request) Successful in 1m24s

Clients put the addressee's name in front of a message that mentions
it ("Nisse Dev Testing: re-plan"), and the transport passed that text
on whole, so no command matched: the live run's re-plan was asked again,
and an addressed 'approve' would have counted as rejection feedback.

- A leading mention of the agent (an HTML pill, its user ID, or its
  display name followed by ':') is removed before commands are matched.
  The display name is learnt from the agent's own member event.
- A message whose leading mention is someone else is skipped: in a
  shared room it is addressed to another agent or person.
- Only the start counts; a mention later in the text is left alone.
- The transcript records the message as sent (InboundMessage.original).

The sender is unaffected: it still comes from the event's homeserver-set
sender field, never from the text.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
dongarandClaude Opus 5.5 committed 2026-09-29 15:59:27 +00:00
1 parent 9620404a2a
commit b0c5f48be4
5 files changed
+199 -8

No files matched your search

+8 -2
View File
@@ -314,7 +314,10 @@ class Orchestrator:
def _record(self, msg: InboundMessage) -> None:
self._store.append_event(
UserMessage(text=msg.text.strip(), source=f"transport:{msg.sender}")
UserMessage(
text=(msg.original or msg.text).strip(),
source=f"transport:{msg.sender}",
)
)
def _finish_stop(self, msg: InboundMessage) -> None:
@@ -356,7 +359,10 @@ class Orchestrator:
# turns see feedback and answers as conversation rather than as
# out-of-band parameters (A10).
self._store.append_event(
UserMessage(text=msg.text.strip(), source=f"transport:{msg.sender}")
UserMessage(
text=(msg.original or msg.text).strip(),
source=f"transport:{msg.sender}",
)
)
state = self._store.get_state()
current = state.state if state else IDLE