openclaw - ✅(Solved) Fix [Bug] Discord `/new` slash command times out — preflight compaction holds WRITE lock past InteractionEventListener 30s deadline [1 pull requests, 1 comments, 2 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#74227Fetched 2026-04-30 06:27:04
View on GitHub
Comments
1
Participants
2
Timeline
12
Reactions
2
Timeline (top)
referenced ×8cross-referenced ×2closed ×1commented ×1

When a user invokes /new (or /reset) via Discord's slash command UI, the InteractionEventListener times out at 30 seconds because runPreflightCompactionIfNeeded holds a session WRITE lock for up to COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS (60s), plus the actual compaction work.

Discord's InteractionEventListener has a 30s timeout — after which Discord shows "The application did not respond" to the user and the command is abandoned. The session reset never completes.


Root Cause

  1. Discord slash command /new arrives as a followup run via createFollowupRunner
  2. createFollowupRunner calls runPreflightCompactionIfNeeded (agent-runner-memory.ts)
  3. When session tokens > ~104K (MiniMax M2 128K context − 20K reserve − 4K soft floor), preflight compaction fires
  4. shouldRunPreflightCompaction acquires a WRITE lock on the session file and runs compaction (60–360s)
  5. Discord's InteractionEventListener times out at 30s → "The application did not respond"
  6. The reset command never reaches commands-core.ts reset hooks

Fix Action

Fix / Workaround

  • Severity: High — prevents session reset from completing on Discord
  • Affected versions: All versions since preflight compaction was introduced (post-#40295 fix)
  • Workaround: None for Discord users; CLI users are unaffected because CLI has no InteractionEventListener timeout

PR fix notes

PR #74390: fix(agents): skip preflight compaction for /new and /reset commands (#74227)

Description (problem / solution / changelog)

Root cause

runPreflightCompactionIfNeeded acquires a WRITE lock (60–360 s) before every followup run. When the next prompt is /new or /reset, compaction is wasted work: those commands clear the session entirely via their own dedicated reset hooks. On Discord, the InteractionEventListener hard-times-out at 30 s, so the slot command reports failure to the user even though the reset succeeds.

Fix

Add a prompt.startsWith("/new") || prompt.startsWith("/reset") early-return guard alongside the existing isHeartbeat and isCli bypasses in runPreflightCompactionIfNeeded. The bypass is purely at the preflight stage — the session is still cleared normally by the downstream reset path.

Scope guard: mid-prompt mentions of /new or /reset (e.g. "explain what /new does") do NOT match startsWith and continue through normal compaction.

Tests

src/agents/preflight-compaction.test.ts — 4 new cases:

  • /new skips compaction
  • /reset skips compaction
  • /new (leading space) does NOT skip
  • explain /reset does NOT skip

Fixes #74227. Thanks @slideshow-dingo.

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/auto-reply/reply/agent-runner-memory.test.ts (modified, +155/-0)
  • src/auto-reply/reply/agent-runner-memory.ts (modified, +9/-1)

Code Example

// Existing:
if (params.isHeartbeat || isCli) return entry;

// Add:
const isResetCommand = params.followupRun.prompt?.match(/^\/(new|reset)(?:\s|$)/);
if (isResetCommand) return entry;
RAW_BUFFERClick to expand / collapse

Bug Report

Title: /new Discord slash command times out due to preflight compaction WRITE lock holding session for 60–360s


Description

When a user invokes /new (or /reset) via Discord's slash command UI, the InteractionEventListener times out at 30 seconds because runPreflightCompactionIfNeeded holds a session WRITE lock for up to COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS (60s), plus the actual compaction work.

Discord's InteractionEventListener has a 30s timeout — after which Discord shows "The application did not respond" to the user and the command is abandoned. The session reset never completes.


Root Cause

  1. Discord slash command /new arrives as a followup run via createFollowupRunner
  2. createFollowupRunner calls runPreflightCompactionIfNeeded (agent-runner-memory.ts)
  3. When session tokens > ~104K (MiniMax M2 128K context − 20K reserve − 4K soft floor), preflight compaction fires
  4. shouldRunPreflightCompaction acquires a WRITE lock on the session file and runs compaction (60–360s)
  5. Discord's InteractionEventListener times out at 30s → "The application did not respond"
  6. The reset command never reaches commands-core.ts reset hooks

Existing Bypasses (Not Applied to Reset Commands)

runPreflightCompactionIfNeeded already skips compaction for:

  • isHeartbeat — returns early at line ~328
  • isCli — returns early at line ~328

Reset commands (/new, /reset, /acp) are not bypassed, even though they go through their own dedicated reset hooks in commands-core.ts and don't need compaction (they clear the session entirely).


Proposed Fix

In agent-runner-memory.ts around line 328, add reset-command detection alongside the existing isHeartbeat/isCli bypass:

// Existing:
if (params.isHeartbeat || isCli) return entry;

// Add:
const isResetCommand = params.followupRun.prompt?.match(/^\/(new|reset)(?:\s|$)/);
if (isResetCommand) return entry;

The pattern ^\/(new|reset)(?:\s|$) is already used in commands-core.ts line 162 for the same purpose.


Impact

  • Severity: High — prevents session reset from completing on Discord
  • Affected versions: All versions since preflight compaction was introduced (post-#40295 fix)
  • Workaround: None for Discord users; CLI users are unaffected because CLI has no InteractionEventListener timeout

Evidence

  • Discord InteractionEventListener timeout: DISCORD_SLOW_LISTENER_THRESHOLD_MS = 30s (Carbon package)
  • Compaction aggregate timeout: COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS = 60s (attempt.ts line 2945)
  • Compaction actual wall time can reach 360s (6 minutes) per openclaw-gateway-eq-slow-restart.sh
  • Reset command pattern: ^\/(new|reset)(?:\s|$) (commands-core.ts line 162)
  • Bypass pattern used elsewhere: shouldBypassConfiguredAcpEnsure in extensions/discord/src/monitor/native-command.ts line 235

extent analysis

TL;DR

Add a reset-command detection bypass in agent-runner-memory.ts to prevent preflight compaction from holding a WRITE lock and causing timeouts for Discord slash commands.

Guidance

  • Identify the runPreflightCompactionIfNeeded function in agent-runner-memory.ts and add a check for reset commands (/new, /reset) to bypass compaction.
  • Verify that the bypass pattern ^\/(new|reset)(?:\s|$) is correctly implemented to match the reset commands.
  • Test the updated code to ensure that the Discord InteractionEventListener no longer times out for reset commands.
  • Review the COMPACTION_RETRY_AGGREGATE_TIMEOUT_MS value to determine if it can be adjusted to prevent future timeouts.

Example

const isResetCommand = params.followupRun.prompt?.match(/^\/(new|reset)(?:\s|$)/);
if (isResetCommand) return entry;

Notes

The proposed fix assumes that the reset commands do not require preflight compaction, as they clear the session entirely. However, further testing may be necessary to ensure that this bypass does not introduce any unintended consequences.

Recommendation

Apply the workaround by adding the reset-command detection bypass in agent-runner-memory.ts, as it directly addresses the root cause of the issue and prevents timeouts for Discord slash commands.

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

openclaw - ✅(Solved) Fix [Bug] Discord `/new` slash command times out — preflight compaction holds WRITE lock past InteractionEventListener 30s deadline [1 pull requests, 1 comments, 2 participants]