mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user