On this page

On this page

Gateway

Configuration — agent heartbeat, compaction, and streaming

agents.defaults.* keys that govern when an agent runs on its own, how its transcript is compacted and pruned, and how partial output reaches a chat.

agents.defaults.heartbeat

Heartbeat configuration has moved to ordinary automation jobs. Run openclaw doctor --fix to migrate supported agents.defaults.heartbeat and agents.entries.<id>.heartbeat settings before starting the upgraded Gateway. Doctor preserves the job's schedule, scratch, model policy, and delivery settings; edit or disable the resulting job in Automations instead of restoring this key.

Use each job's activeHours, idleOnly, payload.skipIfScratchEmpty, and delivery policies for monitoring. Fresh setup creates a disabled Proactive check for the ambient owner; reloads and restarts do not recreate deleted jobs. See Heartbeat migration and Monitoring policies.

agents.defaults.systemAgent

Selects the agent whose model and credentials own ambient OpenClaw system work: system-agent and Custodian consults, and the fallback owner whenever an ambient path omits agentId. That includes models.list, models.authStatus, skills.status, and doctor.memory.status, the default agent directory and workspace behind auth, model-catalog, and doctor resolution, outbound channel bootstrap and queued-delivery recovery, unscoped main-session routing, Talk relay ownership, and first-run onboarding:

json5
{  agents: {    defaults: {      systemAgent: { agentId: "ops" },    },  },}

An explicit request agentId always wins, followed by systemAgent.agentId, a legacy default owner when ownership is not explicit, and finally the sole configured agent. Retained migration provenance alone never designates an explicit fleet's runtime default. Delegated consults with a requesting agent keep that requester as their owner.

With agents.ownership: "explicit", this setting also supplies the recorded default for operations that support default-agent selection, including the agent-list badge, unbound channel routing, unscoped Gateway reads, openclaw sessions, openclaw hooks status, and TUI startup. Doctor records the migrated default here so these operations keep the same owner after restart. Explicit bindings, requests, and session-store owners take precedence. Use --agent <id> to select a different agent or openclaw sessions --all-agents to inspect the whole fleet. Operations that require explicit selection, such as openclaw models, keep that requirement.

An ownerless multi-agent fleet has no default badge. Set a configured id with openclaw config set agents.defaults.systemAgent.agentId <id>. A sole configured agent can still own unqualified Gateway session requests without a saved default designation. Ambient work without an owner fails with an actionable error, except queued-delivery recovery, which records the failing delivery and keeps draining the rest of the queue. Changing the runtime default does not relocate existing workspaces or legacy data. Upgrade-only ownership lives at agents.defaults.authInheritance.agentId for inherited credentials and agents.defaults.sessionStore.agentId for retired main session rows or unscoped rows in a fixed session.store.

agents.defaults.compaction

json5
{  agents: {    defaults: {      compaction: {        enabled: true, // compact before a request that would not fit (default: true)        keepRecentTokens: 20000,        timeoutSeconds: 180,        postIndexSync: "async", // off | async | await        maxActiveTranscriptBytes: "20mb", // Codex fresh-thread seed limit        notifyUser: true, // start/complete and memory-flush notices (default: false)        memoryFlush: {          enabled: true,          softThresholdTokens: 4000,          forceFlushTranscriptBytes: "2mb",        },      },    },  },}

Compaction replaces older history with one checkpoint that has fixed sections, a stated budget, and the user's own messages quoted verbatim. It runs on the session's own model. See Compaction.

  • enabled: when false, disables compaction before model requests. Overflow-recovery compaction and manual /compact remain available. Default: true.
  • keepRecentTokens: how much of the most recent conversation stays verbatim after the checkpoint. Default: 20000.
  • timeoutSeconds: how long a built-in compaction model request may go without progress. Each request start and each streamed output token refreshes the window, so a slow request that keeps streaming finishes while a silent one is aborted after one window. The complete compaction stops after 10 windows even if it keeps streaming. Plugin-owned compaction keeps one window unless the engine explicitly declares "onProgress" in info.acceptedHostParams and reports progress through the supplied callback. Default: 180.
  • postIndexSync: post-compaction session-memory reindex mode. Default: "async". Use "await" for strongest freshness, "async" for lower compaction latency, or "off" only when session-memory sync is handled elsewhere.
  • maxActiveTranscriptBytes: optional positive bytes or a size string such as "20mb". Bounds history seeds for runtimes that start a fresh thread from OpenClaw history, such as Codex app-server. Unset or 0 disables it.
  • notifyUser: when true, sends brief notices when compaction starts and completes, and when a pre-compaction memory flush is exhausted so the reply continues in a degraded state. Default: false. A degraded-checkpoint warning is always shown, regardless of this setting.
  • memoryFlush: silent agentic turn before compaction to store durable memories. It uses the active session model and its normal fallback chain. enabled defaults to true; softThresholdTokens (default 4000) runs the flush when context is that many tokens from the compaction threshold; forceFlushTranscriptBytes (default "2mb", 0 disables) forces it when the model-visible history reaches that size even if token counters are stale. File-arm providers require writable workspace access; tools-arm providers do not.

Custom summary construction belongs to a context engine. Use before_prompt_build when post-compaction context must be injected into later model prompts.

agents.defaults.contextPruning

Prunes old tool results from in-memory context before sending to the LLM. Does not modify session history on disk. Disabled by default; set mode: "cache-ttl" to enable.

json5
{  agents: {    defaults: {      contextPruning: {        mode: "cache-ttl", // off (default) | cache-ttl        ttl: "1h", // duration string; bare numbers are minutes (default 5m)        tools: { allow: [], deny: [] }, // tool names eligible for / excluded from pruning        hardClear: {          enabled: true, // false skips the hard-clear step          placeholder: "[Old tool result content cleared]",        },      },    },  },}
cache-ttl mode behavior
  • mode: "cache-ttl" enables pruning passes.
  • ttl sets how long a cache entry is considered fresh before a new pruning round can start. It is a duration string whose bare numbers are minutes; the built-in default is 5 minutes, and the bundled Anthropic plugin seeds 1h.
  • tools.allow and tools.deny scope which tool names are prunable.
  • hardClear.enabled: false skips the hard-clear step, and hardClear.placeholder replaces the default [Old tool result content cleared] text.
  • Pruning soft-trims oversized tool results first, then hard-clears older tool results if needed.

Soft-trim keeps beginning + end and inserts ... in the middle.

Hard-clear replaces the entire tool result with the placeholder.

Notes:

  • Image blocks are never trimmed/cleared.
  • Ratios are character-based (approximate), not exact token counts.
  • The most recent assistant messages are preserved.

See Session Pruning for behavior details.

agents.defaults.promptCacheKeepWarm

Keeps the prompt cache of an idle interactive session warm. Shortly before the provider's known cache lifetime ends, the Gateway sends one read-only prewarm request that reads the session's cached prefix and generates no output, so the next turn reads the cache instead of rewriting the whole prompt. On by default.

json5
{  agents: {    defaults: {      promptCacheKeepWarm: false, // default true    },  },}

See Prompt caching for which routes and sessions it covers and what each prewarm costs.

Block streaming

json5
{  agents: {    defaults: {      blockStreamingDefault: "off", // on | off      blockStreamingBreak: "text_end", // text_end | message_end      blockStreamingChunk: { minChars: 800, maxChars: 1200, breakPreference: "paragraph" },      blockStreamingCoalesce: { idleMs: 1000 },      humanDelay: { mode: "natural" }, // off (default) | natural | custom (use minMs/maxMs)    },  },}
  • Non-Telegram channels require explicit *.streaming.block.enabled: true to enable block replies. QQ Bot is the exception: it has no streaming.block keys and streams block replies unless channels.qqbot.streaming.mode is "off".
  • Channel overrides: channels.<channel>.streaming.block.coalesce (and per-account variants). Discord, Google Chat, Mattermost, MS Teams, Signal, and Slack default minChars: 1500 / idleMs: 1000.
  • blockStreamingChunk.breakPreference: preferred chunk boundary ("paragraph" | "newline" | "sentence").
  • humanDelay: randomized pause between block replies. Default: off. natural = 800-2500ms. custom uses minMs/maxMs (falls back to the natural range for any unset bound). Per-agent override: agents.entries.*.humanDelay.

See Streaming for behavior + chunking details.

Typing indicators

json5
{  agents: {    defaults: {      typingMode: "instant", // never | instant | thinking | message      typingIntervalSeconds: 6,    },  },}
  • Defaults: instant for direct chats/mentions, message for unmentioned group chats.
  • typingIntervalSeconds default: 6.
  • Per-agent override: agents.entries.*.typingMode.

See Typing Indicators.

Was this useful?