fix: skip memory flush on read-only workspace

This commit is contained in:
Peter Steinberger
2026-01-12 06:33:14 +00:00
parent 1ffb0fe787
commit 5b44825cb3
7 changed files with 317 additions and 3 deletions

View File

@@ -15,6 +15,10 @@ import {
isCompactionFailureError,
isContextOverflowError,
} from "../../agents/pi-embedded-helpers.js";
import {
resolveSandboxConfigForAgent,
resolveSandboxRuntimeStatus,
} from "../../agents/sandbox.js";
import { hasNonzeroUsage, type NormalizedUsage } from "../../agents/usage.js";
import type { ClawdbotConfig } from "../../config/config.js";
import {
@@ -343,8 +347,16 @@ export async function runReplyAgent(params: {
}
const memoryFlushSettings = resolveMemoryFlushSettings(cfg);
const memoryFlushWritable = (() => {
if (!sessionKey) return true;
const runtime = resolveSandboxRuntimeStatus({ cfg, sessionKey });
if (!runtime.sandboxed) return true;
const sandboxCfg = resolveSandboxConfigForAgent(cfg, runtime.agentId);
return sandboxCfg.workspaceAccess === "rw";
})();
const shouldFlushMemory =
memoryFlushSettings &&
memoryFlushWritable &&
!isHeartbeat &&
!isCliProvider(followupRun.run.provider, cfg) &&
shouldRunMemoryFlush({