mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 07:01:40 +03: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 fs from "node:fs/promises";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import type { CliDeps } from "../cli/deps.js";
|
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 { createSubsystemLogger } from "../logging/subsystem.js";
|
||||||
import { type RuntimeEnv, defaultRuntime } from "../runtime.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 log = createSubsystemLogger("gateway/boot");
|
||||||
const BOOT_FILENAME = "BOOT.md";
|
const BOOT_FILENAME = "BOOT.md";
|
||||||
|
|
||||||
@@ -75,12 +83,14 @@ export async function runBootOnce(params: {
|
|||||||
|
|
||||||
const sessionKey = resolveMainSessionKey(params.cfg);
|
const sessionKey = resolveMainSessionKey(params.cfg);
|
||||||
const message = buildBootPrompt(result.content ?? "");
|
const message = buildBootPrompt(result.content ?? "");
|
||||||
|
const sessionId = generateBootSessionId();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await agentCommand(
|
await agentCommand(
|
||||||
{
|
{
|
||||||
message,
|
message,
|
||||||
sessionKey,
|
sessionKey,
|
||||||
|
sessionId,
|
||||||
deliver: false,
|
deliver: false,
|
||||||
},
|
},
|
||||||
bootRuntime,
|
bootRuntime,
|
||||||
|
|||||||
Reference in New Issue
Block a user