fix: stable session IDs for chat/task context persistence

- 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)
This commit is contained in:
Markov 2026-02-23 22:25:57 +01:00
parent 7dd39f65f6
commit b2a620185f

View File

@ -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,