Skip to content

Your lightweight open-source personal agent.

fix(agent): align subagent result session key with main agent for mid-turn injection

chengyongru2193a64c8020
diff --git a/nanobot/agent/subagent.py b/nanobot/agent/subagent.py
index 388a634c7..58daafb63 100644
--- a/nanobot/agent/subagent.py
+++ b/nanobot/agent/subagent.py
@@ -240,12 +240,16 @@ class SubagentManager:
result=result,
)
- # Inject as system message to trigger main agent
+ # Inject as system message to trigger main agent.
+ # Use session_key_override to align with the main agent's session key
+ # so the result is routed to the pending queue (mid-turn injection)
+ # instead of being dispatched as a competing independent task.
msg = InboundMessage(
channel="system",
sender_id="subagent",
chat_id=f"{origin['channel']}:{origin['chat_id']}",
content=announce_content,
+ session_key_override=f"{origin['channel']}:{origin['chat_id']}",
metadata={
"injected_event": "subagent_result",
"subagent_task_id": task_id,