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>
This commit is contained in:
Jake
2026-02-13 04:41:43 +13:00
committed by GitHub
parent 6b1f485ce8
commit 4736fe7fde

View File

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