-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Bug
When a task is executed, thread_id is not passed to AgentRequest in hub.py:_run(). As a result, DUCTOR_TOPIC_ID is never set in the task's CLI environment. This causes two problems:
- Sub-tasks created by a task lose the topic context — they route to the base group chat (General/topic 1) instead of the originating topic.
- create_task.py inside a task reads
os.environ.get("DUCTOR_TOPIC_ID", "")and gets empty string, so notopic_idis passed in the sub-task creation request.
Root Cause
In ductor_bot/tasks/hub.py, the _run() method builds AgentRequest without thread_id:
request = AgentRequest(
prompt=prompt,
chat_id=entry.chat_id, # ✅ passed
# thread_id missing ❌
...
)entry.thread_id exists and is used correctly for result delivery (lines 459, 485, 516), but is never injected into the subprocess environment via AgentRequest.
In executor.py, DUCTOR_TOPIC_ID is only set when config.topic_id is present — so tasks always run without it.
Fix
Pass thread_id to AgentRequest in _run():
request = AgentRequest(
prompt=prompt,
chat_id=entry.chat_id,
thread_id=entry.thread_id, # add this
...
)Reproduction
- User sends a message to group topic (e.g. Media, thread_id=1498)
- Agent creates a background task from that topic
- The task creates a sub-task via
create_task.py - Sub-task result is delivered to General (thread_id=1) instead of Media (thread_id=1498)
Environment
- Multi-agent Ductor setup with Telegram forum group topics
- Confirmed by inspecting hub.py source and matching against real log behavior
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels