ductor icon indicating copy to clipboard operation
ductor copied to clipboard

Sub-agent task notifications route to main agent instead of originating sub-agent

Open alexeymorozua opened this issue 8 months ago • 2 comments

Problem

When a sub-agent (e.g. sonic) creates a background task via create_task.py, the task completion/cancellation notification is delivered to the main agent's chat instead of the sub-agent's chat where the conversation is happening.

Steps to Reproduce

  1. User is chatting with sub-agent sonic in its private Telegram chat
  2. sonic creates a background task via python3 tools/task_tools/create_task.py --name "My Task" "..."
  3. Task runs and eventually completes or gets cancelled
  4. Notification arrives in main agent's General topic (or main agent's DM), not in sonic's chat

Root Cause

From the logs:

Task submitted id=c44b3935 name='Regenerate 32 tracks UA+RU' parent=main

All sub-agents share the main agent's task hub. When a sub-agent creates a task, the framework assigns parent=main, so all delivery goes through the main agent's bot — regardless of which sub-agent originated the task.

create_task.py already reads DUCTOR_CHAT_ID and DUCTOR_TOPIC_ID env vars, but since delivery happens via the main bot, the message still appears in the main agent's context, not the sub-agent's.

Expected Behavior

Task completion/cancellation notification should be delivered via the originating sub-agent's bot to the chat where the task was created.

So if the user is chatting with sonic (chat_id = user's Telegram ID via Sonic's bot), the notification should arrive in that same sonic chat.

Environment

  • Ductor with 5 sub-agents (clowder, watchfaces, corewatchface, rescue, sonic)
  • Sub-agents share the main task hub (no separate interagent_port per agent in agents.json)
  • Transport: Telegram

Suggested Fix

Consider supporting parent=sonic in the task hub, so that when a sub-agent creates a task, the hub knows to deliver the result via that sub-agent's bot and chat context.

Alternatively, allow passing a bot_token or agent_name parameter to the task creation API to override delivery routing.

alexeymorozua avatar Mar 15 '26 14:03 alexeymorozua

Fixed in v0.16.0 (commit 3c2fa71). TaskResult now carries the originating sub-agent identity through the MessageBus adapter — when a sub-agent launches a task, the completion notice routes back to that sub-agent, not the main agent. Integration tests lock the isolation so this doesn't regress. The existing parent_agent field already carried the right semantics; the bug was further down in the per-agent handler wiring.

PleasePrompto avatar Apr 21 '26 10:04 PleasePrompto

Fixed in v0.16.0 (commit 3c2fa71).

TaskResult now carries the originating sub-agent identity through the MessageBus adapter. When a sub-agent launches a task, the completion notice routes back to that sub-agent, not the main agent. Added integration tests that lock down the isolation so this doesn't regress. The existing parent_agent field on TaskResult already carried the right semantics — the bug was further down in the per-agent handler wiring.

PleasePrompto avatar Apr 21 '26 10:04 PleasePrompto