fix(inbox): add delegate_result exclusion to _is_self_echo_row
Some checks failed
Harness Replays / detect-changes (pull_request) Waiting to run
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 26s
CI / Detect changes (pull_request) Successful in 34s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 44s
E2E API Smoke Test / detect-changes (pull_request) Successful in 37s
E2E Staging SaaS (full lifecycle) / E2E Staging SaaS (pull_request) Has been skipped
E2E Chat / detect-changes (pull_request) Successful in 38s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 35s
publish-runtime-autobump / bump-and-tag (pull_request) Has been skipped
Handlers Postgres Integration / detect-changes (pull_request) Successful in 30s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 38s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 49s
E2E Staging SaaS (full lifecycle) / pr-validate (pull_request) Successful in 1m44s
publish-runtime-autobump / pr-validate (pull_request) Successful in 1m24s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m58s
qa-review / approved (pull_request) Failing after 45s
gate-check-v3 / gate-check (pull_request) Successful in 1m4s
security-review / approved (pull_request) Failing after 52s
sop-tier-check / tier-check (pull_request) Successful in 34s
Ops Scripts Tests / Ops scripts (unittest) (pull_request) Successful in 2m7s
CI / Python Lint & Test (pull_request) Successful in 9m25s
CI / Canvas (Next.js) (pull_request) Failing after 11m37s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Failing after 12m3s
CI / Platform (Go) (pull_request) Failing after 21m3s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 23s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 4m3s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 7m14s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 7m24s
E2E Chat / E2E Chat (pull_request) Failing after 11m37s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
Harness Replays / Harness Replays (pull_request) Has been cancelled

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:
Molecule AI · core-be 2026-05-16 13:31:30 +00:00
parent deeff950be
commit af25019900
2 changed files with 21 additions and 1 deletions

View File

@ -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:

View File

@ -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