Skip to content

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

@alexeymorozua

Description

@alexeymorozua

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions