[Bug]: Background task results sometimes return to user DM instead of original group topic
What happened?
Background task results do not always return to the original group chat/topic where the task was initiated. In some cases, the result is delivered to the user’s private chat instead. So, the main bot keeps waiting for the sub bot message return.
Likely Cause
create_task.py correctly propagates DUCTOR_CHAT_ID and DUCTOR_TOPIC_ID, but the async inter-agent path appears to lose the original group/topic context. ask_agent_async.py does not explicitly forward chat/topic metadata, and named inter-agent sessions appear to be bound to the user DM chat id. As a result, nested background tasks may inherit the DM context instead of the original group topic.
Evidence
- ask_agent_async.py (line 73-77) There is no DUCTOR_CHAT_ID and DUCTOR_TOPIC_ID to send.
body: dict[str, object] = {"from": sender, "to": target, "message": message}
2 if new_session:
3 body["new_session"] = True
4 if summary:
5 body["summary"] = summary
- internal_api.py (line 145 ) There is no DUCTOR_CHAT_ID and DUCTOR_TOPIC_ID to received.
Steps to Reproduce
Steps to Reproduce
- Start in a group topic with main.
- Delegate work through an async sub-agent flow.
- Let the sub-agent create or continue a background task, especially when the sub-agent starts another async sub-agent flow.
- Wait for the task to complete.
Expected Behavior
The final task result should be delivered back to the original group chat and original topic/thread.
Operating System
Windows
Environment
Docker
Which LLM provider?
Codex
ductor version
0.12.0
/diagnose output
Relevant log output
LLM self-diagnosis (optional)
group chat main bot -> ask_agent_async to sub bot 1 -> sub bot 1 create_task to sub bot 2 (session and topic id missing)
key issue: sub bot 2 does not know where to return background task because the missing
Additional context
No response
Before submitting
- [x] I have searched existing issues for duplicates.
- [x] I am running the latest version.
Fixed in 61a5439. chat_id and topic_id now propagate through the entire async inter-agent chain:
ask_agent_async.py → internal_api.py → bus.py (via AsyncSendOptions) → adapters.py → app.py
Async results now land in the originating forum topic instead of defaulting to the sender's DM.