Issue #601 — Sub-agent sessions cause gateway blocking
Problem
When a sub-agent session (sessionKey contains :subagent:, e.g., agent:main:channel:123:subagent:def456) runs a before_prompt_build hook, the gateway thread is blocked because:
auto-recall → LanceDB I/O (embedding + rerank)
reflection-injector → LanceDB I/O (loadAgentReflectionSlices)
These run sequentially on the same thread. While the sub-agent is doing I/O, all user sessions wait.
Solution
Skip expensive before_prompt_build hooks for sub-agent sessions — they already inherit full context from the parent agent.
PR
PR #613 — #613
與 PR #516 的關係:為什麼不重疊?
| PR |
修改目標 |
Issue |
| #516 |
isInvalidAgentIdFormat() agent ID 驗證邏輯 |
#492 |
| #613 |
before_prompt_build hooks 新增 subagent skip guard |
#601 |
兩者完全獨立:
Issue #601 — Sub-agent sessions cause gateway blocking
Problem
When a sub-agent session (sessionKey contains
:subagent:, e.g.,agent:main:channel:123:subagent:def456) runs abefore_prompt_buildhook, the gateway thread is blocked because:auto-recall→ LanceDB I/O (embedding + rerank)reflection-injector→ LanceDB I/O (loadAgentReflectionSlices)These run sequentially on the same thread. While the sub-agent is doing I/O, all user sessions wait.
Solution
Skip expensive
before_prompt_buildhooks for sub-agent sessions — they already inherit full context from the parent agent.PR
PR #613 — #613
與 PR #516 的關係:為什麼不重疊?
isInvalidAgentIdFormat()agent ID 驗證邏輯before_prompt_buildhooks 新增 subagent skip guard兩者完全獨立:
isInvalidAgentIdFormat()函式(處理 agent ID 格式驗證)before_prompt_buildhooks 內的 guard(處理 subagent session 跳過邏輯)