forked from molecule-ai/molecule-core
fix(inbox): add delegate_result exclusion to _is_self_echo_row
RFC #2829 PR-2 regression fix: rows with method="delegate_result" are now excluded from the self-echo guard even when source_id matches our workspace_id. The platform may write a delegation-result row with our workspace_id as source_id (e.g. a self-delegation or edge case in the platform's result-writing path); such rows must reach the inbox so the runtime receives the delegation result. Fixes regression vs PR #1346 where this guard was present. Added test_is_self_echo_row_false_for_delegate_result regression pin. All 9 self-echo tests pass locally. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -453,10 +453,19 @@ def _is_self_echo_row(row: dict[str, Any], workspace_id: str) -> bool:
|
||||
``workspace_id`` must be non-empty — an empty-string workspace_id
|
||||
(single-workspace legacy path) can never match a UUID source_id, so
|
||||
the predicate is always False there, which is safe.
|
||||
|
||||
RFC #2829 PR-2 note: rows with method="delegate_result" are excluded
|
||||
from the self-echo guard even when source_id matches our workspace_id.
|
||||
The platform may write a delegation-result row with source_id set to
|
||||
our workspace_id (e.g. a self-delegation or edge case in the platform's
|
||||
result-writing path). Such rows must reach the inbox so that
|
||||
message_from_activity can surface them as peer_agent inbound and the
|
||||
runtime receives the delegation result. Silently filtering them as
|
||||
self-echo would break delegation result delivery.
|
||||
"""
|
||||
if not workspace_id:
|
||||
return False
|
||||
return row.get("source_id") == workspace_id
|
||||
return row.get("source_id") == workspace_id and row.get("method") != "delegate_result"
|
||||
|
||||
|
||||
def message_from_activity(row: dict[str, Any]) -> InboxMessage:
|
||||
|
||||
@@ -539,6 +539,17 @@ def test_is_self_echo_row_false_when_source_id_key_absent():
|
||||
assert inbox._is_self_echo_row(row, "ws-1") is False
|
||||
|
||||
|
||||
def test_is_self_echo_row_false_for_delegate_result():
|
||||
"""RFC #2829 PR-2 regression pin: a row with source_id matching our
|
||||
workspace_id but method=delegate_result must NOT be filtered as a
|
||||
self-echo. The platform may write a delegation-result row with our
|
||||
workspace_id as source_id; such rows must reach the inbox so the
|
||||
runtime receives the delegation result. Silently filtering them would
|
||||
break delegate_result delivery."""
|
||||
row = {"source_id": "ws-1", "method": "delegate_result"}
|
||||
assert inbox._is_self_echo_row(row, "ws-1") is False
|
||||
|
||||
|
||||
def test_poll_once_skips_self_echo_rows(state: inbox.InboxState):
|
||||
"""Internal #469 regression pin: a row with source_id matching our
|
||||
workspace_id must NOT land in the inbox queue — it is our own
|
||||
|
||||
Reference in New Issue
Block a user