fix(compaction): lower default timeout from 900s to 180s, preserve explicit config (#91361)

Merged via squash.

Prepared head SHA: ac545967f9
Co-authored-by: wangmiao0668000666 <290215524+wangmiao0668000666@users.noreply.github.com>
Co-authored-by: velvet-shark <126378+velvet-shark@users.noreply.github.com>
Reviewed-by: @velvet-shark
This commit is contained in:
wangmiao0668000666
2026-06-10 20:51:54 +08:00
committed by GitHub
parent 050c0813b3
commit bb6e47729c
6 changed files with 14 additions and 6 deletions

View File

@@ -634,7 +634,7 @@ Periodic heartbeat runs.
compaction: {
mode: "safeguard", // default | safeguard
provider: "my-provider", // id of a registered compaction provider plugin (optional)
timeoutSeconds: 900,
timeoutSeconds: 180,
reserveTokensFloor: 24000,
keepRecentTokens: 50000,
identifierPolicy: "strict", // strict | off | custom
@@ -661,7 +661,7 @@ Periodic heartbeat runs.
- `mode`: `default` or `safeguard` (chunked summarization for long histories). See [Compaction](/concepts/compaction).
- `provider`: id of a registered compaction provider plugin. When set, the provider's `summarize()` is called instead of built-in LLM summarization. Falls back to built-in on failure. Setting a provider forces `mode: "safeguard"`. See [Compaction](/concepts/compaction).
- `timeoutSeconds`: maximum seconds allowed for a single compaction operation before OpenClaw aborts it. Default: `900`.
- `timeoutSeconds`: maximum seconds allowed for a single compaction operation before OpenClaw aborts it. Default: `180`.
- `keepRecentTokens`: agent cut-point budget for keeping the most recent transcript tail verbatim. Manual `/compact` honors this when explicitly set; otherwise manual compaction is a hard checkpoint.
- `identifierPolicy`: `strict` (default), `off`, or `custom`. `strict` prepends built-in opaque identifier retention guidance during compaction summarization.
- `identifierInstructions`: optional custom identifier-preservation text used when `identifierPolicy=custom`.

View File

@@ -125,6 +125,14 @@ describe("resolveCompactionTimeoutMs", () => {
});
it("converts timeoutSeconds to milliseconds", () => {
expect(
resolveCompactionTimeoutMs({
agents: { defaults: { compaction: { timeoutSeconds: 120 } } },
}),
).toBe(120_000);
});
it("preserves explicit timeoutSeconds above 600", () => {
expect(
resolveCompactionTimeoutMs({
agents: { defaults: { compaction: { timeoutSeconds: 1800 } } },

View File

@@ -6,7 +6,7 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";
import type { CompactResult, ContextEngine } from "../../context-engine/types.js";
import { withTimeout } from "../../node-host/with-timeout.js";
export const EMBEDDED_COMPACTION_TIMEOUT_MS = 900_000;
export const EMBEDDED_COMPACTION_TIMEOUT_MS = 180_000;
function createAbortError(signal: AbortSignal): Error {
const reason = "reason" in signal ? signal.reason : undefined;

View File

@@ -20,7 +20,7 @@ export function resolveEmbeddedAttemptSessionWriteLockOptions(params: {
env?: NodeJS.ProcessEnv;
}): { timeoutMs: number; staleMs: number; maxHoldMs: number } {
// Bound embedded-attempt lock holds to the compaction window, not the full run timeout.
// With defaults this permits roughly 900s compaction time plus the shared 120s
// With defaults this permits roughly 180s compaction time plus the shared 120s
// timeout grace before the watchdog releases a stuck live-process lock.
return resolveSessionWriteLockOptions(params.config, {
env: params.env,

View File

@@ -1494,7 +1494,7 @@ export const FIELD_HELP: Record<string, string> = {
"agents.defaults.compaction.postCompactionSections":
'Opt-in AGENTS.md H2/H3 section names re-injected after compaction so the agent reruns critical startup guidance. Leave unset or set [] to disable reinjection. Explicitly set ["Session Startup", "Red Lines"] to enable the legacy default pair with fallback to older "Every Session"/"Safety" headings. Enabling this can duplicate project context already present in the compaction summary.',
"agents.defaults.compaction.timeoutSeconds":
"Maximum time in seconds allowed for a single compaction operation before it is aborted (default: 900). Increase this for very large sessions that need more time to summarize, or decrease it to fail faster on unresponsive models.",
"Maximum time in seconds allowed for a single compaction operation before it is aborted (default: 180). Increase this for very large sessions that need more time to summarize, or decrease it to fail faster on unresponsive models.",
"agents.defaults.compaction.model":
"Optional provider/model override used only for compaction summarization. Set this when you want compaction to run on a different model than the session default, and leave it unset to keep using the primary agent model.",
"agents.defaults.compaction.truncateAfterCompaction":

View File

@@ -541,7 +541,7 @@ export type AgentCompactionConfig = {
* When set, compaction uses this model instead of the agent's primary model.
* Falls back to the primary model when unset. */
model?: string;
/** Maximum time in seconds for a single compaction operation (default: 900). */
/** Maximum time in seconds for a single compaction operation (default: 180). */
timeoutSeconds?: number;
/**
* Id of a registered compaction provider plugin.