fix(cron): clear stale isolated session transcripts

This commit is contained in:
Vincent Koc
2026-04-12 11:22:35 +01:00
parent ef126f377b
commit c45230d2ed
4 changed files with 21 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ Docs: https://docs.openclaw.ai
- Infra/net: fix multipart FormData fields (including `model`) being silently dropped when a guarded runtime fetch body crosses a FormData implementation boundary, restoring OpenAI audio transcription requests that failed with HTTP 400. (#64349) Thanks @petr-sloup.
- Plugins/memory: restore cached memory capability public artifacts on plugin-registry cache hits so memory-backed artifact surfaces stay visible after warm loads. Thanks @sercada and @vincentkoc.
- Gateway/cron: preserve requested isolated-agent config across runtime reloads so subagent jobs and heartbeat overrides keep the right workspace and heartbeat settings when the hot-loaded snapshot is stale. Thanks @l0cka and @vincentkoc.
- Cron/isolated sessions: persist the right transcript path for each isolated run, including fresh session rollovers, so cron runs stop appending to stale session files. Thanks @samrusani and @vincentkoc.
## 2026.4.11

View File

@@ -70,6 +70,7 @@ export function createCronPromptExecutor(params: {
const sessionFile =
params.cronSession.sessionEntry.sessionFile?.trim() ||
resolveSessionTranscriptPath(params.cronSession.sessionEntry.sessionId, params.agentId);
// Fallback for callers that bypass prepareCronRunContext before persisting retries.
if (!params.cronSession.sessionEntry.sessionFile?.trim()) {
params.cronSession.sessionEntry.sessionFile = sessionFile;
}

View File

@@ -167,6 +167,24 @@ describe("resolveCronSession", () => {
expect(clearBootstrapSnapshot).toHaveBeenCalledWith("webhook:stable-key");
});
it("clears stale sessionFile when forceNew rolls to a fresh session", () => {
const result = resolveWithStoredEntry({
entry: {
sessionId: "existing-session-id-456",
updatedAt: NOW_MS - 1000,
sessionFile: "/tmp/stale-session.jsonl",
modelOverride: "sonnet-4",
},
fresh: true,
forceNew: true,
});
expect(result.sessionEntry.sessionId).not.toBe("existing-session-id-456");
expect(result.isNewSession).toBe(true);
expect(result.sessionEntry.sessionFile).toBeUndefined();
expect(result.sessionEntry.modelOverride).toBe("sonnet-4");
});
it("clears delivery routing metadata and deliveryContext when forceNew is true", () => {
const result = resolveWithStoredEntry({
entry: {

View File

@@ -83,6 +83,7 @@ export function resolveCronSession(params: {
lastAccountId: undefined,
lastThreadId: undefined,
deliveryContext: undefined,
sessionFile: undefined,
}),
};
return { storePath, store, sessionEntry, systemSent, isNewSession };