From 2d0ca1d4cef259b3db21282b6a1a365252586a4d Mon Sep 17 00:00:00 2001 From: DBT Date: Thu, 26 Feb 2026 02:20:51 +0000 Subject: [PATCH] session alignment: force single main session and openclaw-style agents/main/sessions path --- pkg/agent/loop.go | 3 ++- pkg/nodes/registry_server.go | 23 ++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index e88f987..bd3e72e 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -75,7 +75,7 @@ func NewAgentLoop(cfg *config.Config, msgBus *bus.MessageBus, provider providers workspace := cfg.WorkspacePath() os.MkdirAll(workspace, 0755) - sessionsManager := session.NewSessionManager(filepath.Join(filepath.Dir(cfg.WorkspacePath()), "sessions")) + sessionsManager := session.NewSessionManager(filepath.Join(filepath.Dir(cfg.WorkspacePath()), "agents", "main", "sessions")) toolsRegistry := tools.NewToolRegistry() processManager := tools.NewProcessManager(workspace) @@ -442,6 +442,7 @@ func (al *AgentLoop) GetSessionHistory(sessionKey string) []providers.Message { } func (al *AgentLoop) processMessage(ctx context.Context, msg bus.InboundMessage) (string, error) { + msg.SessionKey = "main" unlock := al.lockSessionRun(msg.SessionKey) defer unlock() // Add message preview to log diff --git a/pkg/nodes/registry_server.go b/pkg/nodes/registry_server.go index ba262ed..5fc92a3 100644 --- a/pkg/nodes/registry_server.go +++ b/pkg/nodes/registry_server.go @@ -881,30 +881,11 @@ func (s *RegistryServer) handleWebUISessions(w http.ResponseWriter, r *http.Requ http.Error(w, "method not allowed", http.StatusMethodNotAllowed) return } - sessionsDir := filepath.Join(filepath.Dir(strings.TrimSpace(s.workspacePath)), "sessions") - entries, err := os.ReadDir(sessionsDir) - if err != nil { - if os.IsNotExist(err) { - _ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "sessions": []interface{}{}}) - return - } - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } + _ = os.MkdirAll(filepath.Join(filepath.Dir(strings.TrimSpace(s.workspacePath)), "agents", "main", "sessions"), 0755) type item struct { Key string `json:"key"` } - out := make([]item, 0, len(entries)) - for _, e := range entries { - if e.IsDir() { - continue - } - name := e.Name() - if strings.HasSuffix(name, ".json") { - out = append(out, item{Key: strings.TrimSuffix(name, ".json")}) - } - } - _ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "sessions": out}) + _ = json.NewEncoder(w).Encode(map[string]interface{}{"ok": true, "sessions": []item{{Key: "main"}}}) } func (s *RegistryServer) handleWebUIMemory(w http.ResponseWriter, r *http.Request) {