Skip to content

[Bug]: Browser Tool Triggers Compaction Deadlock - Session Hangs Indefinitely #21621

@mubarakar95

Description

@mubarakar95

Summary

When using the browser tool (via Browser Relay Chrome extension), the session enters a deadlock state during post-response compaction. The compaction process gets stuck in a retry loop, creates a stale .lock file, and never completes. This causes the typing indicator to expire after 2 minutes, making the bot appear "offline" to users.

Steps to reproduce

  1. Start OpenClaw gateway with default configuration
  2. Install and configure Browser Relay Chrome extension
  3. Connect extension to gateway (localhost:18789)
  4. Send a message to the bot that triggers browser tool usage
  5. Bot responds successfully but then enters compaction
  6. Compaction gets stuck in retry loop
  7. After 2 minutes, typing TTL expires and bot appears "offline"
  • Node Version: 22.22.0
  • Model: Google Gemini 2.5 Flash
  • Context Window: 100,000 tokens
  • Channel: Telegram

Expected behavior

  • Compaction should complete within a few seconds
  • Session should remain responsive after browser tool usage
  • No stale lock files should remain

Actual behavior

  • Compaction enters retry loop and never completes
  • Session lock file (*.jsonl.lock) remains indefinitely
  • Bot becomes unresponsive (typing TTL expires)
  • User perceives bot as "offline"

OpenClaw version

2026.2.17

Operating system

macOS (darwin)

Install method

node

Logs, screenshots, and evidence

2026-02-19T20:09:10.775Z [agent] embedded run tool start: tool=browser
2026-02-19T20:09:10.809Z [agent] embedded run tool end: tool=browser
2026-02-19T20:09:12.027Z [agent] embedded run agent end: isError=false
2026-02-19T20:09:12.028Z [agent] embedded run compaction start
2026-02-19T20:09:13.411Z [agent] embedded run compaction retry  <-- STUCK HERE
2026-02-19T20:11:12.030Z typing TTL reached (2m); stopping typing indicator


Note: There is NO `embedded run done` log entry - the session never completes.

## Session Lock File

After the issue occurs, a stale lock file is present:

/Users/kameltakla/.openclaw/agents/main/sessions/<session-id>.jsonl.lock


This lock file prevents subsequent operations from proceeding.

Impact and severity

  1. Remove stale lock files:

    rm -f ~/.openclaw/agents/main/sessions/*.lock
  2. Restart gateway:

    pkill -f openclaw-gateway
    openclaw gateway run --bind loopback --port 18789
  3. Start a new session with /new before using browser features

Root Cause Analysis

The issue appears to be in the compaction logic when triggered after browser tool usage:

  1. Browser tool execution completes successfully
  2. Post-response compaction is triggered
  3. Compaction acquires a session lock
  4. Something in the browser tool context prevents compaction from completing
  5. Compaction enters retry loop but never succeeds
  6. Lock is never released
  7. Session is effectively deadlocked

Frequency

  • Reproducible: Yes, consistently when using browser tool
  • Frequency: 100% of browser tool invocations trigger this issue

Configuration

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "google/gemini-2.5-flash"
      },
      "contextTokens": 100000
    }
  },
  "tools": {
    "elevated": { "enabled": true },
    "fs": { "workspaceOnly": true },
    "exec": { "applyPatch": { "workspaceOnly": true } }
  },
  "gateway": {
    "port": 18789,
    "mode": "local",
    "bind": "loopback"
  }
}

Additional Context

  • The issue does NOT occur with other tools (read, write, web_search, etc.)
  • The issue occurs specifically after the browser tool completes its operation
  • The browser tool itself works correctly - the issue is in the post-tool compaction phase
  • Switching models (gemini-2.5-pro vs gemini-2.5-flash) does not resolve the issue
  • Increasing context window from 16,000 to 100,000 does not resolve the issue

Related Files

  • Session files: ~/.openclaw/agents/main/sessions/*.jsonl
  • Lock files: ~/.openclaw/agents/main/sessions/*.lock
  • Gateway logs: ~/.openclaw/logs/gateway.log
  • Agent logs: /tmp/openclaw/openclaw-YYYY-MM-DD.log

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions