mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 04:33:44 +00:00
fix: compaction safeguard extension not loading in production builds (openclaw#22349) thanks @Glucksberg
Verified: - pnpm build - pnpm check - pnpm test:macmini (local run had unrelated baseline failures; Tak approved proceed) Co-authored-by: Glucksberg <80581902+Glucksberg@users.noreply.github.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import os from "node:os";
|
||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||
import {
|
||||
createAgentSession,
|
||||
DefaultResourceLoader,
|
||||
estimateTokens,
|
||||
SessionManager,
|
||||
SettingsManager,
|
||||
@@ -60,7 +61,7 @@ import {
|
||||
compactWithSafetyTimeout,
|
||||
EMBEDDED_COMPACTION_TIMEOUT_MS,
|
||||
} from "./compaction-safety-timeout.js";
|
||||
import { buildEmbeddedExtensionPaths } from "./extensions.js";
|
||||
import { buildEmbeddedExtensionFactories } from "./extensions.js";
|
||||
import {
|
||||
logToolSchemasForGoogle,
|
||||
sanitizeSessionHistory,
|
||||
@@ -533,14 +534,27 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
settingsManager,
|
||||
cfg: params.config,
|
||||
});
|
||||
// Call for side effects (sets compaction/pruning runtime state)
|
||||
buildEmbeddedExtensionPaths({
|
||||
// Sets compaction/pruning runtime state and returns extension factories
|
||||
// that must be passed to the resource loader for the safeguard to be active.
|
||||
const extensionFactories = buildEmbeddedExtensionFactories({
|
||||
cfg: params.config,
|
||||
sessionManager,
|
||||
provider,
|
||||
modelId,
|
||||
model,
|
||||
});
|
||||
// Only create an explicit resource loader when there are extension factories
|
||||
// to register; otherwise let createAgentSession use its built-in default.
|
||||
let resourceLoader: DefaultResourceLoader | undefined;
|
||||
if (extensionFactories.length > 0) {
|
||||
resourceLoader = new DefaultResourceLoader({
|
||||
cwd: resolvedWorkspace,
|
||||
agentDir,
|
||||
settingsManager,
|
||||
extensionFactories,
|
||||
});
|
||||
await resourceLoader.reload();
|
||||
}
|
||||
|
||||
const { builtInTools, customTools } = splitSdkTools({
|
||||
tools,
|
||||
@@ -558,6 +572,7 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
customTools,
|
||||
sessionManager,
|
||||
settingsManager,
|
||||
resourceLoader,
|
||||
});
|
||||
applySystemPromptOverrideToSession(session, systemPromptOverride());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user