mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-08 10:45:52 +00:00
fix(agent): align subagent result session key with main agent for mid-turn injection
When mid-turn message injection (PR #2985) was introduced, the pending queue routing uses the effective session key to match incoming messages against active sessions. Subagent results, however, use channel="system" which produces a session key of "system:feishu:ou_..." instead of the main agent's "feishu:ou_...", causing the result to bypass the pending queue and be dispatched as a competing independent task. Fix: set session_key_override to the original channel:chat_id so _effective_session_key returns the correct key and the subagent result gets routed into the main agent's pending queue.
This commit is contained in:
parent
79821a571f
commit
2193a64c80
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user