xiaozuoassistant 0.1.71 → 0.1.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -286,6 +286,11 @@ export class ShortTermMemory {
|
|
|
286
286
|
}
|
|
287
287
|
async createRun(sessionId, userContent, runId) {
|
|
288
288
|
await this.ensureReady();
|
|
289
|
+
// Check if session exists, try reload if not
|
|
290
|
+
if (!this.sessions.has(sessionId)) {
|
|
291
|
+
console.log(`[ShortTermMemory:${this.instanceId}] Session ${sessionId} not found for createRun, reloading...`);
|
|
292
|
+
await this.loadSessionsFromDisk();
|
|
293
|
+
}
|
|
289
294
|
if (!this.sessions.has(sessionId))
|
|
290
295
|
throw new Error('Session not found');
|
|
291
296
|
const now = Date.now();
|
|
@@ -355,9 +360,17 @@ export class ShortTermMemory {
|
|
|
355
360
|
}
|
|
356
361
|
async addMessage(sessionId, message) {
|
|
357
362
|
await this.ensureReady();
|
|
358
|
-
|
|
359
|
-
|
|
363
|
+
let sessionMeta = this.sessions.get(sessionId);
|
|
364
|
+
// 如果内存中没有,尝试重载
|
|
365
|
+
if (!sessionMeta) {
|
|
366
|
+
console.log(`[ShortTermMemory:${this.instanceId}] Session ${sessionId} not found in memory for addMessage, reloading...`);
|
|
367
|
+
await this.loadSessionsFromDisk();
|
|
368
|
+
sessionMeta = this.sessions.get(sessionId);
|
|
369
|
+
}
|
|
370
|
+
if (!sessionMeta) {
|
|
371
|
+
console.error(`[ShortTermMemory:${this.instanceId}] Session ${sessionId} not found even after reload.`);
|
|
360
372
|
throw new Error(`Session ${sessionId} not found`);
|
|
373
|
+
}
|
|
361
374
|
const msg = { ...message };
|
|
362
375
|
if (!msg.timestamp)
|
|
363
376
|
msg.timestamp = Date.now();
|
package/package.json
CHANGED