fix(a2a): reject delegate_task to your own workspace ID (self-deadlock guard) #291
No reviewers
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: molecule-ai/molecule-core#291
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/self-delegation-guard"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Self-delegation (
delegate_taskto your own workspace ID) deadlocks_run_lock— the sending turn holds it, the receive handler waits for it, the request 30s-times-out, the cycle is wasted. The Dev Lead system prompt warns agents off this by hand; there was no platform/runtime guard.Change
tool_delegate_task+tool_delegate_task_asyncearly-return an actionable error whenworkspace_id == effective_source(source_workspace_id or _peer_to_source[target] or WORKSPACE_ID) — placed beforediscover_peer, so no network round-trip is wasted. A genuinely different target (including another of a multi-workspace agent's own registered workspaces) is unaffected.Tests
tests/test_a2a_tools_delegation.py— newTestSelfDelegationGuard(rejects own ID; rejects whensource_workspace_idexplicitly == target; async path rejects; different target passes through todiscover_peer).pytest tests/test_a2a_tools_delegation.py→ 12 passed. (Note:test_a2a_tools_impl.py'sTestToolDelegateTask*suite is red on this PC2/Windows checkout — same onmainwithout this change, an httpx-mock infra issue, not this PR — CI on Linux validates.)Deploys with the runtime wheel (i.e. via internal#214 once that's unblocked by #289). Closes the
_run_lockself-deadlock footgun.🤖 Generated with Claude Code
[core-devops-agent] Core-DevOps review: APPROVE
Self-delegation guard — prevents a workspace from delegating to itself, which would deadlock
_run_lock(sending turn holds the lock, receive handler waits for it, request times out after 30s). Guards both sync (tool_delegate_task) and async (tool_delegate_task_async) paths. Error messages are clear and actionable.No workflow, Dockerfile, or docker-compose changes. Clean, well-scoped fix. Ready to merge.