From 4736fe7fde4492fe2095966842835d3a959c68bd Mon Sep 17 00:00:00 2001 From: Jake Date: Fri, 13 Feb 2026 04:41:43 +1300 Subject: [PATCH] fix: fix(boot): use ephemeral session per boot to prevent stale context (openclaw#11764) thanks @mcinteerj Verified: - pnpm build - pnpm check - pnpm test Co-authored-by: mcinteerj <3613653+mcinteerj@users.noreply.github.com> --- src/gateway/boot.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gateway/boot.ts b/src/gateway/boot.ts index d02e81fd275..bc95c2ab6c5 100644 --- a/src/gateway/boot.ts +++ b/src/gateway/boot.ts @@ -1,3 +1,4 @@ +import crypto from "node:crypto"; import fs from "node:fs/promises"; import path from "node:path"; import type { CliDeps } from "../cli/deps.js"; @@ -8,6 +9,13 @@ import { resolveMainSessionKey } from "../config/sessions/main-session.js"; import { createSubsystemLogger } from "../logging/subsystem.js"; import { type RuntimeEnv, defaultRuntime } from "../runtime.js"; +function generateBootSessionId(): string { + const now = new Date(); + const ts = now.toISOString().replace(/[:.]/g, "-").replace("T", "_").replace("Z", ""); + const suffix = crypto.randomUUID().slice(0, 8); + return `boot-${ts}-${suffix}`; +} + const log = createSubsystemLogger("gateway/boot"); const BOOT_FILENAME = "BOOT.md"; @@ -75,12 +83,14 @@ export async function runBootOnce(params: { const sessionKey = resolveMainSessionKey(params.cfg); const message = buildBootPrompt(result.content ?? ""); + const sessionId = generateBootSessionId(); try { await agentCommand( { message, sessionKey, + sessionId, deliver: false, }, bootRuntime,