openclaw - 💡(How to fix) Fix /stop command should cancel pending debounce buffer [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#51046Fetched 2026-04-08 01:05:05
View on GitHub
Comments
2
Participants
3
Timeline
4
Reactions
0
Timeline (top)
commented ×2mentioned ×1subscribed ×1
RAW_BUFFERClick to expand / collapse

Problem

When a user sends /stop to abort the current agent run, queued messages still in the debounce buffer are not cancelled. After the debounce timer expires, the buffered messages flush and trigger a new agent run — making it appear as though /stop had no effect.

Steps to Reproduce

  1. Configure messages.inbound.debounceMs (e.g. 5000)
  2. Send a message that triggers a long-running agent task
  3. While the agent is processing, send additional messages (they enter the debounce buffer)
  4. Send /stop — the current run is aborted ✅
  5. Wait for the debounce timer to expire — the buffered messages flush and trigger a new agent run ❌

Expected Behavior

/stop should cancel/flush any pending debounce buffer entries for the same session, so that no new run is triggered after the abort.

Current Behavior

/stop calls clearSessionQueues() which clears:

  • followupQueue
  • commandLane
  • ❌ Does not clear the debounce pending buffer (per-channel debounce timers)

The debounce buffer is managed separately (e.g. telegram:${accountId}:${conversationKey}:${senderId}:${debounceLane}) and is not touched by clearSessionQueues.

Suggested Fix

In handleStopCommand, after calling clearSessionQueues, also cancel/clear any pending debounce entries for the target session. This could be done by:

  1. Exposing a cancelDebounce(key) function from the debounce module
  2. Calling it alongside clearSessionQueues in the stop handler

Environment

  • OpenClaw: 2026.3.13 (61d171a)
  • Channel: Telegram
  • messages.inbound.debounceMs: 5000

extent analysis

Fix Plan

To fix the issue, we need to clear the pending debounce buffer entries when the /stop command is received. Here are the steps:

  • Expose a cancelDebounce(key) function from the debounce module:
// debounce.js
function cancelDebounce(key) {
  // Cancel the debounce timer and remove the entry from the buffer
  clearTimeout(debounceTimers[key]);
  delete debounceTimers[key];
  delete debounceBuffer[key];
}
  • Call cancelDebounce alongside clearSessionQueues in the stop handler:
// handleStopCommand.js
function handleStopCommand(session) {
  clearSessionQueues(session);
  const debounceKey = `telegram:${session.accountId}:${session.conversationKey}:${session.senderId}:${session.debounceLane}`;
  cancelDebounce(debounceKey);
}
  • Ensure that the cancelDebounce function is properly exported and imported in the relevant modules.

Verification

To verify that the fix worked, follow these steps:

  1. Configure messages.inbound.debounceMs to a non-zero value (e.g. 5000).
  2. Send a message that triggers a long-running agent task.
  3. While the agent is processing, send additional messages to fill the debounce buffer.
  4. Send /stop to abort the current agent run.
  5. Wait for the debounce timer to expire and verify that no new agent run is triggered.

Extra Tips

  • Make sure to properly handle edge cases, such as when the debounce buffer is empty or when the /stop command is received multiple times in a row.
  • Consider adding logging or monitoring to track the number of cancelled debounce buffer entries to ensure that the fix is working as expected.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING