Sub-agent task notifications route to main agent instead of originating sub-agent
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
- User is chatting with sub-agent
sonicin its private Telegram chat soniccreates a background task viapython3 tools/task_tools/create_task.py --name "My Task" "..."- Task runs and eventually completes or gets cancelled
- 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_portper agent inagents.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.
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.
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.