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:02:50

    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.

    Agent loop

    An agentic loop is the full “real” run of an agent: intake → context assembly → model inference → tool execution → streaming replies → persistence. It’s the authoritative path that turns a message into actions and a final reply, while keeping session state consistent.

    In OpenClaw, a loop is a single, serialized run per session that emits lifecycle and stream events as the model thinks, calls tools, and streams output. This doc explains how that authentic loop is wired end-to-end.

    Entry points

    • Gateway RPC:
      text
      agent
      and
      text
      agent.wait
      .
    • CLI:
      text
      agent
      command.

    How it works (high-level)

    1. text
      agent
      RPC validates params, resolves session (sessionKey/sessionId), persists session metadata, returns
      text
      { runId, acceptedAt }
      immediately.
    2. text
      agentCommand
      runs the agent:
      • resolves model + thinking/verbose/trace defaults
      • loads skills snapshot
      • calls
        text
        runEmbeddedPiAgent
        (pi-agent-core runtime)
      • emits lifecycle end/error if the embedded loop does not emit one
    3. text
      runEmbeddedPiAgent
      :
      • serializes runs via per-session + global queues
      • resolves model + auth profile and builds the pi session
      • subscribes to pi events and streams assistant/tool deltas
      • enforces timeout -> aborts run if exceeded
      • for Codex app-server turns, aborts an accepted turn that stops producing app-server progress before a terminal event
      • returns payloads + usage metadata
    4. text
      subscribeEmbeddedPiSession
      bridges pi-agent-core events to OpenClaw
      text
      agent
      stream:
      • tool events =>
        text
        stream: "tool"
      • assistant deltas =>
        text
        stream: "assistant"
      • lifecycle events =>
        text
        stream: "lifecycle"
        (
        text
        phase: "start" | "end" | "error"
        )
    5. text
      agent.wait
      uses
      text
      waitForAgentRun
      :
      • waits for lifecycle end/error for
        text
        runId
      • returns
        text
        { status: ok|error|timeout, startedAt, endedAt, error? }

    Queueing + concurrency

    • Runs are serialized per session key (session lane) and optionally through a global lane.
    • This prevents tool/session races and keeps session history consistent.
    • Messaging channels can choose queue modes (collect/steer/followup) that feed this lane system. See Command Queue.
    • Transcript writes are also protected by a session write lock on the session file. The lock is process-aware and file-based, so it catches writers that bypass the in-process queue or come from another process.
    • Session write locks are non-reentrant by default. If a helper intentionally nests acquisition of the same lock while preserving one logical writer, it must opt in explicitly with
      text
      allowReentrant: true
      .

    Session + workspace preparation

    • Workspace is resolved and created; sandboxed runs may redirect to a sandbox workspace root.
    • Skills are loaded (or reused from a snapshot) and injected into env and prompt.
    • Bootstrap/context files are resolved and injected into the system prompt report.
    • A session write lock is acquired;
      text
      SessionManager
      is opened and prepared before streaming. Any later transcript rewrite, compaction, or truncation path must take the same lock before opening or mutating the transcript file.

    Prompt assembly + system prompt

    • System prompt is built from OpenClaw’s base prompt, skills prompt, bootstrap context, and per-run overrides.
    • Model-specific limits and compaction reserve tokens are enforced.
    • See System prompt for what the model sees.

    Hook points (where you can intercept)

    OpenClaw has two hook systems:

    • Internal hooks (Gateway hooks): event-driven scripts for commands and lifecycle events.
    • Plugin hooks: extension points inside the agent/tool lifecycle and gateway pipeline.

    Internal hooks (Gateway hooks)

    • text
      agent:bootstrap
      : runs while building bootstrap files before the system prompt is finalized. Use this to add/remove bootstrap context files.
    • Command hooks:
      text
      /new
      ,
      text
      /reset
      ,
      text
      /stop
      , and other command events (see Hooks doc).

    See Hooks for setup and examples.

    Plugin hooks (agent + gateway lifecycle)

    These run inside the agent loop or gateway pipeline:

    • text
      before_model_resolve
      : runs pre-session (no
      text
      messages
      ) to deterministically override provider/model before model resolution.
    • text
      before_prompt_build
      : runs after session load (with
      text
      messages
      ) to inject
      text
      prependContext
      ,
      text
      systemPrompt
      ,
      text
      prependSystemContext
      , or
      text
      appendSystemContext
      before prompt submission. Use
      text
      prependContext
      for per-turn dynamic text and system-context fields for stable guidance that should sit in system prompt space.
    • text
      before_agent_start
      : legacy compatibility hook that may run in either phase; prefer the explicit hooks above.
    • text
      before_agent_reply
      : runs after inline actions and before the LLM call, letting a plugin claim the turn and return a synthetic reply or silence the turn entirely.
    • text
      agent_end
      : inspect the final message list and run metadata after completion.
    • text
      before_compaction
      /
      text
      after_compaction
      : observe or annotate compaction cycles.
    • text
      before_tool_call
      /
      text
      after_tool_call
      : intercept tool params/results.
    • text
      before_install
      : inspect built-in scan findings and optionally block skill or plugin installs.
    • text
      tool_result_persist
      : synchronously transform tool results before they are written to an OpenClaw-owned session transcript.
    • text
      message_received
      /
      text
      message_sending
      /
      text
      message_sent
      : inbound + outbound message hooks.
    • text
      session_start
      /
      text
      session_end
      : session lifecycle boundaries.
    • text
      gateway_start
      /
      text
      gateway_stop
      : gateway lifecycle events.

    Hook decision rules for outbound/tool guards:

    • text
      before_tool_call
      :
      text
      { block: true }
      is terminal and stops lower-priority handlers.
    • text
      before_tool_call
      :
      text
      { block: false }
      is a no-op and does not clear a prior block.
    • text
      before_install
      :
      text
      { block: true }
      is terminal and stops lower-priority handlers.
    • text
      before_install
      :
      text
      { block: false }
      is a no-op and does not clear a prior block.
    • text
      message_sending
      :
      text
      { cancel: true }
      is terminal and stops lower-priority handlers.
    • text
      message_sending
      :
      text
      { cancel: false }
      is a no-op and does not clear a prior cancel.

    See Plugin hooks for the hook API and registration details.

    Harnesses may adapt these hooks differently. The Codex app-server harness keeps OpenClaw plugin hooks as the compatibility contract for documented mirrored surfaces, while Codex native hooks remain a separate lower-level Codex mechanism.

    Streaming + partial replies

    • Assistant deltas are streamed from pi-agent-core and emitted as
      text
      assistant
      events.
    • Block streaming can emit partial replies either on
      text
      text_end
      or
      text
      message_end
      .
    • Reasoning streaming can be emitted as a separate stream or as block replies.
    • See Streaming for chunking and block reply behavior.

    Tool execution + messaging tools

    • Tool start/update/end events are emitted on the
      text
      tool
      stream.
    • Tool results are sanitized for size and image payloads before logging/emitting.
    • Messaging tool sends are tracked to suppress duplicate assistant confirmations.

    Reply shaping + suppression

    • Final payloads are assembled from:
      • assistant text (and optional reasoning)
      • inline tool summaries (when verbose + allowed)
      • assistant error text when the model errors
    • The exact silent token
      text
      NO_REPLY
      /
      text
      no_reply
      is filtered from outgoing payloads.
    • Messaging tool duplicates are removed from the final payload list.
    • If no renderable payloads remain and a tool errored, a fallback tool error reply is emitted (unless a messaging tool already sent a user-visible reply).

    Compaction + retries

    • Auto-compaction emits
      text
      compaction
      stream events and can trigger a retry.
    • On retry, in-memory buffers and tool summaries are reset to avoid duplicate output.
    • See Compaction for the compaction pipeline.

    Event streams (today)

    • text
      lifecycle
      : emitted by
      text
      subscribeEmbeddedPiSession
      (and as a fallback by
      text
      agentCommand
      )
    • text
      assistant
      : streamed deltas from pi-agent-core
    • text
      tool
      : streamed tool events from pi-agent-core

    Chat channel handling

    • Assistant deltas are buffered into chat
      text
      delta
      messages.
    • A chat
      text
      final
      is emitted on lifecycle end/error.

    Timeouts

    • text
      agent.wait
      default: 30s (just the wait).
      text
      timeoutMs
      param overrides.
    • Agent runtime:
      text
      agents.defaults.timeoutSeconds
      default 172800s (48 hours); enforced in
      text
      runEmbeddedPiAgent
      abort timer.
    • Cron runtime: isolated agent-turn
      text
      timeoutSeconds
      is owned by cron. The scheduler starts that timer when execution begins, aborts the underlying run at the configured deadline, then runs bounded cleanup before recording the timeout so a stale child session cannot keep the lane stuck.
    • Stuck-session recovery: with diagnostics enabled,
      text
      diagnostics.stuckSessionWarnMs
      detects long
      text
      processing
      sessions. Active embedded runs, active reply operations, and active session-lane tasks remain warning-only by default; if diagnostics show no active work for the session, the watchdog releases the affected session lane so queued startup work can drain.
    • Model idle timeout: OpenClaw aborts a model request when no response chunks arrive before the idle window.
      text
      models.providers.<id>.timeoutSeconds
      extends this idle watchdog for slow local/self-hosted providers; otherwise OpenClaw uses
      text
      agents.defaults.timeoutSeconds
      when configured, capped at 120s by default. Cron-triggered runs with no explicit model or agent timeout disable the idle watchdog and rely on the cron outer timeout.
    • Provider HTTP request timeout:
      text
      models.providers.<id>.timeoutSeconds
      applies to that provider's model HTTP fetches, including connect, headers, body, SDK request timeout, total guarded-fetch abort handling, and model stream idle watchdog. Use this for slow local/self-hosted providers such as Ollama before raising the whole agent runtime timeout.

    Where things can end early

    • Agent timeout (abort)
    • AbortSignal (cancel)
    • Gateway disconnect or RPC timeout
    • text
      agent.wait
      timeout (wait-only, does not stop agent)

    Related

    • Tools — available agent tools
    • Hooks — event-driven scripts triggered by agent lifecycle events
    • Compaction — how long conversations are summarized
    • Exec Approvals — approval gates for shell commands
    • Thinking — thinking/reasoning level configuration

    © 2024 TaskFlow Mirror

    Powered by TaskFlow Sync Engine