Repository navigation
Conversation
…at heard it A message two of Rome's accounts hear is still recorded once, and now raises MessageSaid for each of them, so each account's settings decide its own wake. The Discord skip that stood in for this goes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
zoolsher
left a comment
There was a problem hiding this comment.
Design & Alternatives review: ✅ APPROVE
Problem: When two of Rome's accounts share a chat and someone writes a message, only the account whose adapter records it first decides the wake. The message is recorded once and messages.record() returns null for the second account, so no MessageSaid is raised for it. After #2481 moved the reply/bot/mention rules into the wake gate, account A's settings could silence a message that account B would have woken on, such as an ambient "anyone around?". #2481's Discord stand-in covered only messages addressed to the other account, and Feishu had no stand-in.
Goals: each account decides its own wake on its own settings and its own addressing; the message stays on record once; a redelivery wakes nothing; the message stays out of catch-up until every account has decided.
Non-goals: deciding which agent should answer an ambient message when both chats wake on every message (ZHA-229's first open point, which the author flags for a decision); surviving a restart between the two accounts hearing the message.
What the PR does: inbound-recording.ts keeps a 10-minute in-process map, lately, keyed by chat id and message key. It holds the RecordedMessage and the set of channels that heard it. When record() returns null, a channel not yet in the set gets its own MessageSaid on the same record, and a channel already in the set raises nothing. The hold works per raise: messagesSaid keys owed by event object, and TurnLinks.wakeUndecided keeps a count per message id. Each hook gets its own heard(channel, id) and its own session through ensureChannelChat, so A and B see their own addressing. The Discord-only addressesAnotherRomeAccount skip and its romeAccountIds wiring are removed.
Alternatives checked against the code:
- Do nothing, or keep #2481's stand-in and port it to Feishu. It still lets A's settings silence ambient messages for B. Each adapter would need its own "addressed to another Rome account" check, including a reply-reference fetch per message on Discord. This is the root cause the PR removes.
- A copy of the message per account, as already happens where
messageHolder()(connections/chat-adapter.ts) numbers messages per member account, withCopiesin turn-links.ts. It breaks the "recorded once" invariant for platforms whose message ids are global (Discord, Feishu), and every reader would need copy handling. Not a fit. - Persist which accounts heard a message: a small table keyed on message id and channel, with
INSERT OR IGNOREdeciding "first hearing for this account". The record could be re-read through the existingMessageRepository.idOf(chat, key)andbyIds. This works after a restart and needs no time window. It costs a migration, an additive schema step that is hard to undo, plus a write per hearing. The existingagent_turn_messages(message, session) links can't stand in for it, because a "no wake" decision writes no link. - The PR's in-memory map. It reuses the per-account hold that already exists and needs no schema change.
| Approach | Added complexity | Correctness / completeness | Blast radius | Reversibility | Maintenance | Effort |
|---|---|---|---|---|---|---|
| Do nothing / stand-in per adapter | Low per adapter, repeated N times | Partial: ambient still silenced; one heuristic per platform | Adapters | Easy | High (per-platform heuristics) | Low–Med |
| Copy per account | High (copy handling in every reader) | Breaks the "recorded once" invariant | Chats storage and all readers | Hard (data shape) | High | High |
| Persisted hearing table | Medium (migration + repo method) | Exact, works after a restart | Storage + recording | Additive schema, hard to undo | Low | Medium |
PR: in-process lately map |
Low (~40 lines in one module) | Exact within 10 min; after a restart the second account misses the message (no worse than today) | Only chats where two of Rome's accounts share message keys | Fully reversible, no schema or wire change | Low | Low |
Recommendation: the PR's approach is the best fit now. It moves the wake decision to the right place: one raise per account, decided by the hook, with no account deciding another's wake. It deletes a heuristic in one adapter instead of adding more, and it commits to nothing that is hard to undo. If missed wakes after a restart, or the catch-up race described in the finding, turn out to matter, alternative 3 is the next step. It would only replace the lately lookup, and the raise path would stay the same.
The double wake on ambient messages is a product decision, not a flaw in this design. Raising per account is what any later rule needs (say, ambient messages wake only one agent), and that rule would go in the wake gate, not in recording. A stale comment in recordOne ("a group message a second of Rome's accounts hears" raises nothing) now contradicts the new behaviour and should be updated.
Verdict: APPROVE — Raising MessageSaid once per account on top of the single record is the best fit. It reuses the per-account hold that already exists in TurnLinks and makes no schema or wire commitment, and its known gaps are documented and can be closed later without undoing it.
1 finding(s) — 0 posted as inline comments below; 1 listed in this table only (no matching diff line).
| Severity | Category | File | Title |
|---|---|---|---|
| P3 | design | packages/core/src/connections/inbound-recording.ts |
Second account's hold starts only when it hears, so catch-up can read the message in between |
Automated review by RomeOS Code Review · commit 2ef0859 · Full review history
There was a problem hiding this comment.
🔁 This review has been superseded. See the latest review.
… who said a shared message as each account knows them Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
zoolsher
left a comment
There was a problem hiding this comment.
Code Review: ✅ APPROVE
Goal: when two of Rome's accounts hear one group message, keep it on record once but raise MessageSaid once for each account. Each account's wake gate then decides on that account's own settings and addressing. This replaces #2481's Discord-only skip (addressesAnotherRomeAccount) and also covers Feishu.
Assessment: this is the right fix at the right layer. The change deletes an adapter heuristic and its wiring through index.ts, the integrations and the Discord adapter. In its place is a small in-process map, lately, with a 10-minute TTL, so there is no schema change. Restart behaviour is documented and tested.
What I traced:
inbound-recording.ts, read in full.tailsserializes recordings per place across accounts, so the second account'srecord()always runs after the first's raise.latelykeys are unique, because they are set only on a fresh record.forget()can stop at the first unexpired entry because Map insertion order matchesat.hearing/heard()are keyed by channel, so each raise hands over that account's own platform event andaddressing.
messages-said.ts.- Each raise is a distinct event object. That gives a separate
owedhold and a separatewakeUndecidedcount, andsendersresolves the sender per raise. speakerOfopens the session of the account that heard the message, andhandedKeyis per session, so the two decisions don't collide.
- Each raise is a distinct event object. That gives a separate
- Inbox hook (
channel-message/index.ts). A/stopwhoseaddressingis ambient is ignored, so a stop said to B can't stop A. The wake gate readsaddressedBy(message)from each account's own event, andinbox:message_handlertakeschannelUserIdfrom that account's delivery. - Discord
messageCreate.discordInboundTextdoesn't depend on which account hears the message, so sharing one record body is safe. The per-accountmode === "ignore"check still runs before recording. - Other subscribers. Only
messages-said.tslistens toMessageSaidin core, and only the Inbox hook usesmessagesSaid.
Earlier threads:
- P1, sender identity: fixed in 56f9077. The second raise now carries
saidByfrom its own delivery, and a test gives each account a different sender id. - P2, dedupe by account: fixed.
heareris now keyed by platform and account id, with a reconnect regression test. - The two P2s from @zoolsher (hold gap; replies and threads addressed to B waking A): both are answered convincingly. Two accounts in one chat is unsupported for now, and the PR description records the agreed behaviour. I'm not raising them again.
Not verified: I didn't run the test suite. An earlier review reported that the rstest dependencies are missing from the clone.
| Option | Complexity | Covers Feishu | Survives restart | Per-account decision |
|---|---|---|---|---|
| #2481 Discord skip (removed) | Adapter heuristic + cross-module wiring | No | n/a | Only for messages addressed to the other account |
This PR: in-process lately map, one raise per hearer |
~40 lines in one module | Yes | No (documented, tested) | Yes |
| Persist hearers in the schema | Migration + repository changes | Yes | Yes | Yes |
The in-process map is the right trade-off for a configuration that is unsupported for now.
Verdict: APPROVE — The per-account MessageSaid raise is a correct, simple fix at the right layer, and the earlier P1 and P2 findings are fixed in 56f9077. Only an optional comment fix is left.
1 finding(s) — 0 posted as inline comments below; 1 listed in this table only (no matching diff line).
| Severity | Category | File | Title |
|---|---|---|---|
| P3 | code-quality | packages/core/src/connections/inbound-recording.ts |
Two comments still say an on-record message raises nothing |
Automated review by RomeOS Code Review · commit 56f9077 · Full review history
zhangfand
left a comment
There was a problem hiding this comment.
Code Review: ✅ APPROVE
The change preserves single-message recording while allowing each receiving account to decide its own wake. Reviewed the recording, event, session, wake-hold, and Inbox paths alongside the added regression tests.
Tests could not start because node_modules and rstest are missing. The required submit_output tool was unavailable.
Verdict: APPROVE — No actionable regressions found in the per-account wake delivery changes.
No issues found. Code looks good!
Requested by zhangfan · project thread
Stacked on #2481. Merge it before #2481 reaches main, or together with it.
Why
When two of Rome's accounts are in one chat, a message is recorded once, and until now only the account that recorded it first decided its wake. #2481 moved the reply rule, the bot rule and mentions of others into the wake gate, so the first account's settings could keep a message quiet that the other account would wake on. Example: account A wakes only on a mention, B on every message, and someone writes "anyone around?". If A records it first, B never wakes. On main, A dropped the message in the connection, so B woke. #2481 covered only messages addressed to another account, and only on Discord.
Sketch
inbound-recording.tsstill records each message once. It now raisesMessageSaidonce for each account that hears it, with the same record, so each account's hook reads how the message addressed that account and decides on that account's settings.TurnLinks.wakeUndecided). If the first account decides before the second account's delivery arrives, the hold is already released, and a turn in the second account's session can read the message once as context and then wake on it. Accepted, since two of Rome's accounts in one chat is not supported for now.addressesAnotherRomeAccount,romeAccountIds) is removed.Behaviour changes
Invariants
Merge danger
Low to medium. Only chats with two of Rome's accounts change. An app hook that listens on both accounts' channels would now hear the message once per account; the Inbox hook decides each on its own account, which is the intent.
Evidence
pnpm preflightpassed.messages-said.test.ts: a message two accounts hear is recorded once and heard once for each, through each account's session, with each account's own sender; the second account's redelivery raises nothing, and neither does a redelivery to an account connected again on a new channel; the message is held out of catch-up until both decided; an account hearing it only after a restart raises nothing.ambientfor the first account andmention/replyfor the second where it is addressed.🤖 Generated with Claude Code