TaskFlow
DashboardFreewriteWhiteboardsProjectsCRMTasksNotificationsSettingsAgent TowerAPI Docs
OpenClaw Docs
?

User

Member

Caricamento in corso...

Home
Progetti
Task
Notifiche
CRM

    OpenClaw

    Documentation Mirror

    Documentation Overview

    Docs

    Auth credential semantics
    Scheduled tasks
    Hooks
    Automation & tasks
    Standing orders
    Task flow
    Background tasks
    BlueBubbles
    Broadcast groups
    Channel routing
    Discord
    Feishu
    Google Chat
    Group messages
    Groups
    iMessage
    Chat channels
    IRC
    LINE
    Channel location parsing
    Matrix
    Matrix migration
    Matrix push rules for quiet previews
    Mattermost
    Microsoft Teams
    Nextcloud Talk
    Nostr
    Pairing
    QA channel
    QQ bot
    Signal
    Slack
    Synology Chat
    Telegram
    Tlon
    Channel troubleshooting
    Twitch
    WeChat
    WhatsApp
    Yuanbao
    Zalo
    Zalo personal
    CI pipeline
    ACP
    Agent
    Agents
    Approvals
    Backup
    Browser
    Channels
    Clawbot
    `openclaw commitments`
    Completion
    Config
    Configure
    Cron
    Daemon
    Dashboard
    Devices
    Directory
    DNS
    Docs
    Doctor
    Flows (redirect)
    Gateway
    Health
    Hooks
    CLI reference
    Inference CLI
    Logs
    MCP
    Memory
    Message
    Migrate
    Models
    Node
    Nodes
    Onboard
    Pairing
    Plugins
    Proxy
    QR
    Reset
    Sandbox CLI
    Secrets
    Security
    Sessions
    Setup
    Skills
    Status
    System
    `openclaw tasks`
    TUI
    Uninstall
    Update
    Voicecall
    Webhooks
    Wiki
    Active memory
    Agent runtime
    Agent loop
    Agent runtimes
    Agent workspace
    Gateway architecture
    Channel docking
    Inferred commitments
    Compaction
    Context
    Context engine
    Delegate architecture
    Dreaming
    Experimental features
    Features
    Markdown formatting
    Memory overview
    Builtin memory engine
    Honcho memory
    QMD memory engine
    Memory search
    Messages
    Model failover
    Model providers
    Models CLI
    Multi-agent routing
    OAuth
    OpenClaw App SDK
    Presence
    QA overview
    Matrix QA
    Command queue
    Steering queue
    Retry policy
    Session management
    Session pruning
    Session tools
    SOUL.md personality guide
    Streaming and chunking
    System prompt
    Timezones
    TypeBox
    Typing indicators
    Usage tracking
    Date and time
    Node + tsx crash
    Diagnostics flags
    Authentication
    Background exec and process tool
    Bonjour discovery
    Bridge protocol
    CLI backends
    Configuration — agents
    Configuration — channels
    Configuration — tools and custom providers
    Configuration
    Configuration examples
    Configuration reference
    Diagnostics export
    Discovery and transports
    Doctor
    Gateway lock
    Health checks
    Heartbeat
    Gateway runbook
    Local models
    Gateway logging
    Multiple gateways
    Network model
    OpenAI chat completions
    OpenResponses API
    OpenShell
    OpenTelemetry export
    Gateway-owned pairing
    Prometheus metrics
    Gateway protocol
    Remote access
    Remote gateway setup
    Sandbox vs tool policy vs elevated
    Sandboxing
    Secrets management
    Secrets apply plan contract
    Security audit checks
    Security
    Tailscale
    Tools invoke API
    Troubleshooting
    Trusted proxy auth
    Debugging
    Environment variables
    FAQ
    FAQ: first-run setup
    FAQ: models and auth
    GPT-5.5 / Codex agentic parity
    GPT-5.5 / Codex parity maintainer notes
    Help
    Scripts
    Testing
    Testing: live suites
    General troubleshooting
    OpenClaw
    Ansible
    Azure
    Bun (experimental)
    ClawDock
    Release channels
    DigitalOcean
    Docker
    Docker VM runtime
    exe.dev
    Fly.io
    GCP
    Hetzner
    Hostinger
    Install
    Installer internals
    Kubernetes
    macOS VMs
    Migration guide
    Migrating from Claude
    Migrating from Hermes
    Nix
    Node.js
    Northflank
    Oracle Cloud
    Podman
    Railway
    Raspberry Pi
    Render
    Uninstall
    Updating
    Logging
    Network
    Audio and voice notes
    Camera capture
    Image and media support
    Nodes
    Location command
    Media understanding
    Talk mode
    Node troubleshooting
    Voice wake
    Pi integration architecture
    Pi development workflow
    Android app
    Platforms
    iOS app
    Linux app
    Gateway on macOS
    Canvas
    Gateway lifecycle
    macOS dev setup
    Health checks (macOS)
    Menu bar icon
    macOS logging
    Menu bar
    Peekaboo bridge
    macOS permissions
    Remote control
    macOS signing
    Skills (macOS)
    Voice overlay
    Voice wake (macOS)
    WebChat (macOS)
    macOS IPC
    macOS app
    Windows
    Plugin internals
    Plugin architecture internals
    Building plugins
    Plugin bundles
    Codex Computer Use
    Codex harness
    Community plugins
    Plugin compatibility
    Google Meet plugin
    Plugin hooks
    Plugin manifest
    Memory LanceDB
    Memory wiki
    Message presentation
    Agent harness plugins
    Building channel plugins
    Channel turn kernel
    Plugin entry points
    Plugin SDK migration
    Plugin SDK overview
    Building provider plugins
    Plugin runtime helpers
    Plugin setup and config
    Plugin SDK subpaths
    Plugin testing
    Skill workshop plugin
    Voice call plugin
    Webhooks plugin
    Zalo personal plugin
    OpenProse
    Alibaba Model Studio
    Anthropic
    Arcee AI
    Azure Speech
    Amazon Bedrock
    Amazon Bedrock Mantle
    Chutes
    Claude Max API proxy
    Cloudflare AI gateway
    ComfyUI
    Deepgram
    Deepinfra
    DeepSeek
    ElevenLabs
    Fal
    Fireworks
    GitHub Copilot
    GLM (Zhipu)
    Google (Gemini)
    Gradium
    Groq
    Hugging Face (inference)
    Provider directory
    Inferrs
    Inworld
    Kilocode
    LiteLLM
    LM Studio
    MiniMax
    Mistral
    Model provider quickstart
    Moonshot AI
    NVIDIA
    Ollama
    OpenAI
    OpenCode
    OpenCode Go
    OpenRouter
    Perplexity
    Qianfan
    Qwen
    Runway
    SGLang
    StepFun
    Synthetic
    Tencent Cloud (TokenHub)
    Together AI
    Venice AI
    Vercel AI gateway
    vLLM
    Volcengine (Doubao)
    Vydra
    xAI
    Xiaomi MiMo
    Z.AI
    Default AGENTS.md
    Release policy
    API usage and costs
    Credits
    Device model database
    Full release validation
    Memory configuration reference
    OpenClaw App SDK API design
    Prompt caching
    Rich output protocol
    RPC adapters
    SecretRef credential surface
    Session management deep dive
    AGENTS.md template
    BOOT.md template
    BOOTSTRAP.md template
    HEARTBEAT.md template
    IDENTITY template
    SOUL.md template
    TOOLS.md template
    USER template
    Tests
    Token use and costs
    Transcript hygiene
    Onboarding reference
    Contributing to the threat model
    Threat model (MITRE ATLAS)
    Formal verification (security models)
    Network proxy
    Agent bootstrapping
    Docs directory
    Getting started
    Docs hubs
    OpenClaw lore
    Onboarding (macOS app)
    Onboarding overview
    Personal assistant setup
    Setup
    Showcase
    Onboarding (CLI)
    CLI automation
    CLI setup reference
    ACP agents
    ACP agents — setup
    Agent send
    apply_patch tool
    Brave search
    Browser (OpenClaw-managed)
    Browser control API
    Browser troubleshooting
    Browser login
    WSL2 + Windows + remote Chrome CDP troubleshooting
    BTW side questions
    ClawHub
    Code execution
    Creating skills
    Diffs
    DuckDuckGo search
    Elevated mode
    Exa search
    Exec tool
    Exec approvals
    Exec approvals — advanced
    Firecrawl
    Gemini search
    Grok search
    Image generation
    Tools and plugins
    Kimi search
    LLM task
    Lobster
    Tool-loop detection
    Media overview
    MiniMax search
    Multi-agent sandbox and tools
    Music generation
    Ollama web search
    PDF tool
    Perplexity search
    Plugins
    Reactions
    SearXNG search
    Skills
    Skills config
    Slash commands
    Sub-agents
    Tavily
    Thinking levels
    Tokenjuice
    Trajectory bundles
    Text-to-speech
    Video generation
    Web search
    Web fetch
    Linux server
    Control UI
    Dashboard
    Web
    TUI
    WebChat

    OpenAPI Specs

    openapi
    TaskFlow
    docs/openclaw
    Original Docs

    Real-time Synchronized Documentation

    Last sync: 01/05/2026 07:01:55

    Note: This content is mirrored from docs.openclaw.ai and is subject to their terms and conditions.

    OpenClaw Docs

    v2.4.0 Production

    Last synced: Today, 22:00

    Technical reference for the OpenClaw framework. Real-time synchronization with the official documentation engine.

    Use this file to discover all available pages before exploring further.

    Session management deep dive

    OpenClaw manages sessions end-to-end across these areas:

    • Session routing (how inbound messages map to a
      text
      sessionKey
      )
    • Session store (
      text
      sessions.json
      ) and what it tracks
    • Transcript persistence (
      text
      *.jsonl
      ) and its structure
    • Transcript hygiene (provider-specific fixups before runs)
    • Context limits (context window vs tracked tokens)
    • Compaction (manual and auto-compaction) and where to hook pre-compaction work
    • Silent housekeeping (memory writes that should not produce user-visible output)

    If you want a higher-level overview first, start with:

    • Session management
    • Compaction
    • Memory overview
    • Memory search
    • Session pruning
    • Transcript hygiene

    Source of truth: the Gateway

    OpenClaw is designed around a single Gateway process that owns session state.

    • UIs (macOS app, web Control UI, TUI) should query the Gateway for session lists and token counts.
    • In remote mode, session files are on the remote host; “checking your local Mac files” won’t reflect what the Gateway is using.

    Two persistence layers

    OpenClaw persists sessions in two layers:

    1. Session store (

      text
      sessions.json
      )

      • Key/value map:
        text
        sessionKey -> SessionEntry
      • Small, mutable, safe to edit (or delete entries)
      • Tracks session metadata (current session id, last activity, toggles, token counters, etc.)
    2. Transcript (

      text
      <sessionId>.jsonl
      )

      • Append-only transcript with tree structure (entries have
        text
        id
        +
        text
        parentId
        )
      • Stores the actual conversation + tool calls + compaction summaries
      • Used to rebuild the model context for future turns
      • Large pre-compaction debug checkpoints are skipped once the active transcript exceeds the checkpoint size cap, avoiding a second giant
        text
        .checkpoint.*.jsonl
        copy.

    On-disk locations

    Per agent, on the Gateway host:

    • Store:
      text
      ~/.openclaw/agents/<agentId>/sessions/sessions.json
    • Transcripts:
      text
      ~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl
      • Telegram topic sessions:
        text
        .../<sessionId>-topic-<threadId>.jsonl

    OpenClaw resolves these via

    text
    src/config/sessions.ts
    .


    Store maintenance and disk controls

    Session persistence has automatic maintenance controls (

    text
    session.maintenance
    ) for
    text
    sessions.json
    , transcript artifacts, and trajectory sidecars:

    • text
      mode
      :
      text
      warn
      (default) or
      text
      enforce
    • text
      pruneAfter
      : stale-entry age cutoff (default
      text
      30d
      )
    • text
      maxEntries
      : cap entries in
      text
      sessions.json
      (default
      text
      500
      )
    • text
      resetArchiveRetention
      : retention for
      text
      *.reset.<timestamp>
      transcript archives (default: same as
      text
      pruneAfter
      ;
      text
      false
      disables cleanup)
    • text
      maxDiskBytes
      : optional sessions-directory budget
    • text
      highWaterBytes
      : optional target after cleanup (default
      text
      80%
      of
      text
      maxDiskBytes
      )

    Normal Gateway writes batch

    text
    maxEntries
    cleanup for production-sized caps, so a store may briefly exceed the configured cap before the next high-water cleanup rewrites it back down.
    text
    openclaw sessions cleanup --enforce
    still applies the configured cap immediately.

    OpenClaw no longer creates automatic

    text
    sessions.json.bak.*
    rotation backups during Gateway writes. The legacy
    text
    session.maintenance.rotateBytes
    key is ignored and
    text
    openclaw doctor --fix
    removes it from older configs.

    Enforcement order for disk budget cleanup (

    text
    mode: "enforce"
    ):

    1. Remove oldest archived, orphan transcript, or orphan trajectory artifacts first.
    2. If still above the target, evict oldest session entries and their transcript/trajectory files.
    3. Keep going until usage is at or below
      text
      highWaterBytes
      .

    In

    text
    mode: "warn"
    , OpenClaw reports potential evictions but does not mutate the store/files.

    Run maintenance on demand:

    bash
    openclaw sessions cleanup --dry-run openclaw sessions cleanup --enforce

    Cron sessions and run logs

    Isolated cron runs also create session entries/transcripts, and they have dedicated retention controls:

    • text
      cron.sessionRetention
      (default
      text
      24h
      ) prunes old isolated cron run sessions from the session store (
      text
      false
      disables).
    • text
      cron.runLog.maxBytes
      +
      text
      cron.runLog.keepLines
      prune
      text
      ~/.openclaw/cron/runs/<jobId>.jsonl
      files (defaults:
      text
      2_000_000
      bytes and
      text
      2000
      lines).

    When cron force-creates a new isolated run session, it sanitizes the previous

    text
    cron:<jobId>
    session entry before writing the new row. It carries safe preferences such as thinking/fast/verbose settings, labels, and explicit user-selected model/auth overrides. It drops ambient conversation context such as channel/group routing, send or queue policy, elevation, origin, and ACP runtime binding so a fresh isolated run cannot inherit stale delivery or runtime authority from an older run.


    Session keys (
    text
    sessionKey
    )

    A

    text
    sessionKey
    identifies which conversation bucket you’re in (routing + isolation).

    Common patterns:

    • Main/direct chat (per agent):
      text
      agent:<agentId>:<mainKey>
      (default
      text
      main
      )
    • Group:
      text
      agent:<agentId>:<channel>:group:<id>
    • Room/channel (Discord/Slack):
      text
      agent:<agentId>:<channel>:channel:<id>
      or
      text
      ...:room:<id>
    • Cron:
      text
      cron:<job.id>
    • Webhook:
      text
      hook:<uuid>
      (unless overridden)

    The canonical rules are documented at /concepts/session.


    Session ids (
    text
    sessionId
    )

    Each

    text
    sessionKey
    points at a current
    text
    sessionId
    (the transcript file that continues the conversation).

    Rules of thumb:

    • Reset (
      text
      /new
      ,
      text
      /reset
      ) creates a new
      text
      sessionId
      for that
      text
      sessionKey
      .
    • Daily reset (default 4:00 AM local time on the gateway host) creates a new
      text
      sessionId
      on the next message after the reset boundary.
    • Idle expiry (
      text
      session.reset.idleMinutes
      or legacy
      text
      session.idleMinutes
      ) creates a new
      text
      sessionId
      when a message arrives after the idle window. When daily + idle are both configured, whichever expires first wins.
    • System events (heartbeat, cron wakeups, exec notifications, gateway bookkeeping) may mutate the session row but do not extend daily/idle reset freshness. Reset rollover discards queued system-event notices for the previous session before the fresh prompt is built.
    • Thread parent fork guard (
      text
      session.parentForkMaxTokens
      , default
      text
      100000
      ) skips parent transcript forking when the parent session is already too large; the new thread starts fresh. Set
      text
      0
      to disable.

    Implementation detail: the decision happens in

    text
    initSessionState()
    in
    text
    src/auto-reply/reply/session.ts
    .


    Session store schema (
    text
    sessions.json
    )

    The store’s value type is

    text
    SessionEntry
    in
    text
    src/config/sessions.ts
    .

    Key fields (not exhaustive):

    • text
      sessionId
      : current transcript id (filename is derived from this unless
      text
      sessionFile
      is set)
    • text
      sessionStartedAt
      : start timestamp for the current
      text
      sessionId
      ; daily reset freshness uses this. Legacy rows may derive it from the JSONL session header.
    • text
      lastInteractionAt
      : last real user/channel interaction timestamp; idle reset freshness uses this so heartbeat, cron, and exec events do not keep sessions alive. Legacy rows without this field fall back to the recovered session start time for idle freshness.
    • text
      updatedAt
      : last store-row mutation timestamp, used for listing, pruning, and bookkeeping. It is not the authority for daily/idle reset freshness.
    • text
      sessionFile
      : optional explicit transcript path override
    • text
      chatType
      :
      text
      direct | group | room
      (helps UIs and send policy)
    • text
      provider
      ,
      text
      subject
      ,
      text
      room
      ,
      text
      space
      ,
      text
      displayName
      : metadata for group/channel labeling
    • Toggles:
      • text
        thinkingLevel
        ,
        text
        verboseLevel
        ,
        text
        reasoningLevel
        ,
        text
        elevatedLevel
      • text
        sendPolicy
        (per-session override)
    • Model selection:
      • text
        providerOverride
        ,
        text
        modelOverride
        ,
        text
        authProfileOverride
    • Token counters (best-effort / provider-dependent):
      • text
        inputTokens
        ,
        text
        outputTokens
        ,
        text
        totalTokens
        ,
        text
        contextTokens
    • text
      compactionCount
      : how often auto-compaction completed for this session key
    • text
      memoryFlushAt
      : timestamp for the last pre-compaction memory flush
    • text
      memoryFlushCompactionCount
      : compaction count when the last flush ran

    The store is safe to edit, but the Gateway is the authority: it may rewrite or rehydrate entries as sessions run.


    Transcript structure (
    text
    *.jsonl
    )

    Transcripts are managed by

    text
    @mariozechner/pi-coding-agent
    ’s
    text
    SessionManager
    .

    The file is JSONL:

    • First line: session header (
      text
      type: "session"
      , includes
      text
      id
      ,
      text
      cwd
      ,
      text
      timestamp
      , optional
      text
      parentSession
      )
    • Then: session entries with
      text
      id
      +
      text
      parentId
      (tree)

    Notable entry types:

    • text
      message
      : user/assistant/toolResult messages
    • text
      custom_message
      : extension-injected messages that do enter model context (can be hidden from UI)
    • text
      custom
      : extension state that does not enter model context
    • text
      compaction
      : persisted compaction summary with
      text
      firstKeptEntryId
      and
      text
      tokensBefore
    • text
      branch_summary
      : persisted summary when navigating a tree branch

    OpenClaw intentionally does not “fix up” transcripts; the Gateway uses

    text
    SessionManager
    to read/write them.


    Context windows vs tracked tokens

    Two different concepts matter:

    1. Model context window: hard cap per model (tokens visible to the model)
    2. Session store counters: rolling stats written into
      text
      sessions.json
      (used for /status and dashboards)

    If you’re tuning limits:

    • The context window comes from the model catalog (and can be overridden via config).
    • text
      contextTokens
      in the store is a runtime estimate/reporting value; don’t treat it as a strict guarantee.

    For more, see /token-use.


    Compaction: what it is

    Compaction summarizes older conversation into a persisted

    text
    compaction
    entry in the transcript and keeps recent messages intact.

    After compaction, future turns see:

    • The compaction summary
    • Messages after
      text
      firstKeptEntryId

    Compaction is persistent (unlike session pruning). See /concepts/session-pruning.

    Compaction chunk boundaries and tool pairing

    When OpenClaw splits a long transcript into compaction chunks, it keeps assistant tool calls paired with their matching

    text
    toolResult
    entries.

    • If the token-share split lands between a tool call and its result, OpenClaw shifts the boundary to the assistant tool-call message instead of separating the pair.
    • If a trailing tool-result block would otherwise push the chunk over target, OpenClaw preserves that pending tool block and keeps the unsummarized tail intact.
    • Aborted/error tool-call blocks do not hold a pending split open.

    When auto-compaction happens (Pi runtime)

    In the embedded Pi agent, auto-compaction triggers in two cases:

    1. Overflow recovery: the model returns a context overflow error (
      text
      request_too_large
      ,
      text
      context length exceeded
      ,
      text
      input exceeds the maximum number of tokens
      ,
      text
      input token count exceeds the maximum number of input tokens
      ,
      text
      input is too long for the model
      ,
      text
      ollama error: context length exceeded
      , and similar provider-shaped variants) → compact → retry.
    2. Threshold maintenance: after a successful turn, when:

    text
    contextTokens > contextWindow - reserveTokens

    Where:

    • text
      contextWindow
      is the model’s context window
    • text
      reserveTokens
      is headroom reserved for prompts + the next model output

    These are Pi runtime semantics (OpenClaw consumes the events, but Pi decides when to compact).

    OpenClaw can also trigger a preflight local compaction before opening the next run when

    text
    agents.defaults.compaction.maxActiveTranscriptBytes
    is set and the active transcript file reaches that size. This is a file-size guard for local reopen cost, not raw archival: OpenClaw still runs normal semantic compaction, and it requires
    text
    truncateAfterCompaction
    so the compacted summary can become a new successor transcript.

    For embedded Pi runs,

    text
    agents.defaults.compaction.midTurnPrecheck.enabled: true
    adds an opt-in tool-loop guard. After a tool result is appended and before the next model call, OpenClaw estimates the prompt pressure using the same preflight budget logic used at turn start. If the context no longer fits, the guard does not compact inside Pi's
    text
    transformContext
    hook. It raises a structured mid-turn precheck signal, stops the current prompt submission, and lets the outer run loop use the existing recovery path: truncate oversized tool results when that is enough, or trigger the configured compaction mode and retry. The option is disabled by default and works with both
    text
    default
    and
    text
    safeguard
    compaction modes, including provider-backed safeguard compaction. This is independent of
    text
    maxActiveTranscriptBytes
    : the byte-size guard runs before a turn opens, while mid-turn precheck runs later in the embedded Pi tool loop after new tool results have been appended.


    Compaction settings (
    text
    reserveTokens
    ,
    text
    keepRecentTokens
    )

    Pi’s compaction settings live in Pi settings:

    json5
    { compaction: { enabled: true, reserveTokens: 16384, keepRecentTokens: 20000, }, }

    OpenClaw also enforces a safety floor for embedded runs:

    • If
      text
      compaction.reserveTokens < reserveTokensFloor
      , OpenClaw bumps it.
    • Default floor is
      text
      20000
      tokens.
    • Set
      text
      agents.defaults.compaction.reserveTokensFloor: 0
      to disable the floor.
    • If it’s already higher, OpenClaw leaves it alone.
    • Manual
      text
      /compact
      honors an explicit
      text
      agents.defaults.compaction.keepRecentTokens
      and keeps Pi's recent-tail cut point. Without an explicit keep budget, manual compaction remains a hard checkpoint and rebuilt context starts from the new summary.
    • Set
      text
      agents.defaults.compaction.midTurnPrecheck.enabled: true
      to run the optional tool-loop precheck after new tool results and before the next model call. This is a trigger only; summary generation still uses the configured compaction path. It is independent of
      text
      maxActiveTranscriptBytes
      , which is a turn-start active-transcript byte-size guard.
    • Set
      text
      agents.defaults.compaction.maxActiveTranscriptBytes
      to a byte value or string such as
      text
      "20mb"
      to run local compaction before a turn when the active transcript gets large. This guard is active only when
      text
      truncateAfterCompaction
      is also enabled. Leave it unset or set
      text
      0
      to disable.
    • When
      text
      agents.defaults.compaction.truncateAfterCompaction
      is enabled, OpenClaw rotates the active transcript to a compacted successor JSONL after compaction. The old full transcript remains archived and linked from the compaction checkpoint instead of being rewritten in place.

    Why: leave enough headroom for multi-turn “housekeeping” (like memory writes) before compaction becomes unavoidable.

    Implementation:

    text
    ensurePiCompactionReserveTokens()
    in
    text
    src/agents/pi-settings.ts
    (called from
    text
    src/agents/pi-embedded-runner.ts
    ).


    Pluggable compaction providers

    Plugins can register a compaction provider via

    text
    registerCompactionProvider()
    on the plugin API. When
    text
    agents.defaults.compaction.provider
    is set to a registered provider id, the safeguard extension delegates summarization to that provider instead of the built-in
    text
    summarizeInStages
    pipeline.

    • text
      provider
      : id of a registered compaction provider plugin. Leave unset for default LLM summarization.
    • Setting a
      text
      provider
      forces
      text
      mode: "safeguard"
      .
    • Providers receive the same compaction instructions and identifier-preservation policy as the built-in path.
    • The safeguard still preserves recent-turn and split-turn suffix context after provider output.
    • Built-in safeguard summarization re-distills prior summaries with new messages instead of preserving the full previous summary verbatim.
    • Safeguard mode enables summary quality audits by default; set
      text
      qualityGuard.enabled: false
      to skip retry-on-malformed-output behavior.
    • If the provider fails or returns an empty result, OpenClaw falls back to built-in LLM summarization automatically.
    • Abort/timeout signals are re-thrown (not swallowed) to respect caller cancellation.

    Source:

    text
    src/plugins/compaction-provider.ts
    ,
    text
    src/agents/pi-hooks/compaction-safeguard.ts
    .


    User-visible surfaces

    You can observe compaction and session state via:

    • text
      /status
      (in any chat session)
    • text
      openclaw status
      (CLI)
    • text
      openclaw sessions
      /
      text
      sessions --json
    • Verbose mode:
      text
      🧹 Auto-compaction complete
      + compaction count

    Silent housekeeping (
    text
    NO_REPLY
    )

    OpenClaw supports “silent” turns for background tasks where the user should not see intermediate output.

    Convention:

    • The assistant starts its output with the exact silent token
      text
      NO_REPLY
      /
      text
      no_reply
      to indicate “do not deliver a reply to the user”.
    • OpenClaw strips/suppresses this in the delivery layer.
    • Exact silent-token suppression is case-insensitive, so
      text
      NO_REPLY
      and
      text
      no_reply
      both count when the whole payload is just the silent token.
    • This is for true background/no-delivery turns only; it is not a shortcut for ordinary actionable user requests.

    As of

    text
    2026.1.10
    , OpenClaw also suppresses draft/typing streaming when a partial chunk begins with
    text
    NO_REPLY
    , so silent operations don’t leak partial output mid-turn.


    Pre-compaction "memory flush" (implemented)

    Goal: before auto-compaction happens, run a silent agentic turn that writes durable state to disk (e.g.

    text
    memory/YYYY-MM-DD.md
    in the agent workspace) so compaction can’t erase critical context.

    OpenClaw uses the pre-threshold flush approach:

    1. Monitor session context usage.
    2. When it crosses a “soft threshold” (below Pi’s compaction threshold), run a silent “write memory now” directive to the agent.
    3. Use the exact silent token
      text
      NO_REPLY
      /
      text
      no_reply
      so the user sees nothing.

    Config (

    text
    agents.defaults.compaction.memoryFlush
    ):

    • text
      enabled
      (default:
      text
      true
      )
    • text
      model
      (optional exact provider/model override for the flush turn, for example
      text
      ollama/qwen3:8b
      )
    • text
      softThresholdTokens
      (default:
      text
      4000
      )
    • text
      prompt
      (user message for the flush turn)
    • text
      systemPrompt
      (extra system prompt appended for the flush turn)

    Notes:

    • The default prompt/system prompt include a
      text
      NO_REPLY
      hint to suppress delivery.
    • When
      text
      model
      is set, the flush turn uses that model without inheriting the active session fallback chain, so local-only housekeeping does not silently fall back to a paid conversation model.
    • The flush runs once per compaction cycle (tracked in
      text
      sessions.json
      ).
    • The flush runs only for embedded Pi sessions (CLI backends skip it).
    • The flush is skipped when the session workspace is read-only (
      text
      workspaceAccess: "ro"
      or
      text
      "none"
      ).
    • See Memory for the workspace file layout and write patterns.

    Pi also exposes a

    text
    session_before_compact
    hook in the extension API, but OpenClaw’s flush logic lives on the Gateway side today.


    Troubleshooting checklist

    • Session key wrong? Start with /concepts/session and confirm the
      text
      sessionKey
      in
      text
      /status
      .
    • Store vs transcript mismatch? Confirm the Gateway host and the store path from
      text
      openclaw status
      .
    • Compaction spam? Check:
      • model context window (too small)
      • compaction settings (
        text
        reserveTokens
        too high for the model window can cause earlier compaction)
      • tool-result bloat: enable/tune session pruning
    • Silent turns leaking? Confirm the reply starts with
      text
      NO_REPLY
      (case-insensitive exact token) and you’re on a build that includes the streaming suppression fix.

    Related

    • Session management
    • Session pruning
    • Context engine

    © 2024 TaskFlow Mirror

    Powered by TaskFlow Sync Engine