fix: wait for in-flight LLM requests in Close()

Add activeRequests.Wait() at the start of Close() so graceful shutdown
waits for any running llmWorkerNormal to finish before releasing
resources (sessions, MCP, stats).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dj-oyu 2026-03-20 20:21:04 +09:00
parent 39b4b475e9
commit c15f9dd7a6

View file

@ -619,6 +619,9 @@ func (al *AgentLoop) Stop() {
// and dirty session data). Should be called during graceful shutdown.
func (al *AgentLoop) Close() {
// Wait for in-flight LLM requests to finish before releasing resources.
al.activeRequests.Wait()
al.closeExt()
mcpManager := al.mcp.takeManager()