Skip to content

feat(agent): answer when the family says its name, not just @-mentions - #56

Merged
arthware-dev merged 1 commit into
mainfrom
feat/agent-name-trigger
Aug 2, 2026
Merged

feat(agent): answer when the family says its name, not just @-mentions#56
arthware-dev merged 1 commit into
mainfrom
feat/agent-name-trigger

Conversation

@arthware-dev

Copy link
Copy Markdown
Contributor

In a group room the agent only replied to an autocompleted Matrix pill, so "Stacky, what's on our list?" was dropped before it saw it. That is how everyone who does not know what a pill is talks to it.

Being addressed by the configured name now counts as a mention: at the start of a message or tacked on the end, case-insensitively, and after a greeting. A name mid-sentence does not, so the agent stays out of conversations about it. Replies are handled too, since Matrix puts the quoted message first in the body.

The name comes from AGENT_NAME, so renaming the agent makes it answer to the new name and stop answering to the old one, with no code change.

Implemented as a sitecustomize shim like the existing ones, with the patched symbol added to the PIN list so a nanobot upgrade that moves it fails the unit lane.

In a group room the agent only replied to an autocompleted Matrix pill,
so "Stacky, what's on our list?" was dropped before it saw it. That is
the way everyone who does not know what a pill is talks to it.

Being addressed by the configured name now counts as a mention: at the
start of a message, or tacked on the end, case-insensitively, and after
a greeting. A name in the middle of a sentence does not, so the agent
stays out of conversations about it. Replies are handled too, since
Matrix puts the quoted message first in the body.

The name comes from AGENT_NAME, so renaming the agent to "Kit" makes it
answer to "kit, whats on the list" with no code change.
@arthware-dev

Copy link
Copy Markdown
Contributor Author

Verified on the demo rig with the real container and real Matrix, not just the stub.

The shim is live against the installed nanobot:

$ docker exec stack-agent python -c "import nanobot.channels.matrix as m; print(m.MatrixChannel._is_bot_mentioned.__module__)"
sitecustomize

Two messages sent into a 3-member room as homer, seconds apart:

12:53  homer: what's on our list?
12:53  homer: Stacky, what's on our list?

Only one was picked up:

12:53:28 | INFO | Processing message from matrix:@homer:simpson: Stacky, what's on our list?

The unaddressed one produced no processing line at all. (The turn then fails on LLM transient error ... connection error — the rig's model endpoint is unreachable, upstream of this change.)

Red-checked both ways: the matcher spec caught a real bug on first run (\b after the name never matches when the name ends in punctuation, so a name like C++ would match nothing — now (?!\w)), and neutering the shim's import makes test_being_named_counts_as_a_mention fail rather than pass quietly.

Unit lane: 2182 passed, 8 skipped. ruff clean.

One deliberate tradeoff worth a reviewer's eye: a sentence opening with the name in third person reads as an address, so "Stacky got that wrong yesterday" gets a reply. Requiring punctuation after the name would fix that and would also drop "Stacky whats on our list", which is the likeliest thing anyone types. Documented in the module docstring.

@arthware-dev
arthware-dev merged commit 506be7a into main Aug 2, 2026
1 check passed
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.

1 participant