From b2a620185f175c5cbf59e5893cd63c2cd6dcc33f Mon Sep 17 00:00:00 2001 From: Markov Date: Mon, 23 Feb 2026 22:25:57 +0100 Subject: [PATCH] fix: stable session IDs for chat/task context persistence MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Chat messages use 'chat-{chat_id}' session → conversation history preserved - Task messages use 'task-{task_id}' session → task context preserved - Previously every message created a new random session (no memory) --- src/router.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/router.ts b/src/router.ts index 6ff75b9..93e6bd3 100644 --- a/src/router.ts +++ b/src/router.ts @@ -87,6 +87,7 @@ export class EventRouter { let collectedText = ''; for await (const msg of runAgent(prompt, { workDir: this.config.workDir, + sessionId: `task-${task.id}`, model: this.config.model, provider: this.config.provider, systemPrompt: this.config.prompt || undefined, @@ -155,9 +156,13 @@ export class EventRouter { this.log.info('│ MESSAGE from @%s: "%s"', authorSlug, content.slice(0, 200)); this.log.info('│ Context: %s | Mentioned: %s', taskId ? `task=${taskId}` : chatId ? `chat=${chatId}` : 'none', isMentioned); + // Stable session ID per chat/task context — preserves conversation history + const sessionId = chatId ? `chat-${chatId}` : taskId ? `task-${taskId}` : `msg-${Date.now()}`; + let collectedText = ''; for await (const msg of runAgent(content, { workDir: this.config.workDir, + sessionId, model: this.config.model, provider: this.config.provider, systemPrompt: this.config.prompt || undefined,