mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-13 12:14:40 +00:00
fix(ws): detach agent runs from HTTP request context
Agent runs were tied to the HTTP request context, so navigating away cancelled the LLM stream. Now uses context.WithoutCancel() to survive page navigation while preserving explicit chat.abort support.
This commit is contained in:
1 parent
78ffc57a8e
commit
b1b7bfbe69
1 file changed
+5
-2
@@ -122,8 +122,11 @@ func (m *ChatMethods) handleSend(ctx context.Context, client *gateway.Client, re
|
||||
sessionKey = sessions.SessionKey(params.AgentID, "ws-"+client.ID())
|
||||
}
|
||||
|
||||
// Inject user_id into context for downstream stores/tools
|
||||
runCtxBase := ctx
|
||||
// Detach from HTTP request context so agent runs survive page navigation/reconnect.
|
||||
// WithoutCancel preserves all context values (locale, user ID, etc.)
|
||||
// but HTTP request cancellation no longer propagates.
|
||||
// Explicit abort via chat.abort still works through the per-run cancel().
|
||||
runCtxBase := context.WithoutCancel(ctx)
|
||||
if userID != "" {
|
||||
runCtxBase = store.WithUserID(runCtxBase, userID)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user