feat: reset idle assistant sessions after one hour

When a conversation's assistant session has been idle longer than
runtime.acp.assistantSessionResetIdleMs (default 1h, 0 disables) and
its owner has no unfinished proposals, the next inbound message starts
a fresh session instead of resuming. Binding lastActiveAt is persisted
per turn so the decision survives restarts.
This commit is contained in:
zenord
2026-08-19 16:17:54 +08:00
parent 9c3139380d
commit bd96595ba8
7 changed files with 128 additions and 8 deletions
+5 -1
View File
@@ -14,6 +14,8 @@ export interface AssistantBinding {
botFingerprint: string;
createdAt: number;
updatedAt: number;
// Refreshed on every assistant turn; drives the idle reset of long-inactive sessions.
lastActiveAt?: number;
}
interface StoreData {
@@ -90,6 +92,7 @@ export class DurableSessionStore {
const binding = this.data.bindings[chatKey];
if (!binding) return;
binding.updatedAt = Date.now();
binding.lastActiveAt = binding.updatedAt;
await this.persist();
}
@@ -148,7 +151,8 @@ function parseStoreData(value: unknown): StoreData {
|| typeof binding.assistantWorkspace !== "string"
|| typeof binding.botFingerprint !== "string"
|| typeof binding.createdAt !== "number"
|| typeof binding.updatedAt !== "number") {
|| typeof binding.updatedAt !== "number"
|| (binding.lastActiveAt !== undefined && typeof binding.lastActiveAt !== "number")) {
throw new Error(`invalid state v3 binding '${chatKey}'`);
}
}