openclaw - ✅(Solved) Fix [Bug]: Discord threads root fix - runtime patches for context growth + session routing [1 pull requests, 1 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#44586Fetched 2026-04-08 00:44:53
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
referenced ×2cross-referenced ×1

Root Cause

Active bundles in dist/index.js lacked patches in some runtime artifacts:

  • Resolver CLI without consistent lookup by delivery context (channel + to + accountId)
  • Command path not propagating sufficient context

Fix Action

Fix / Workaround

Active bundles in dist/index.js lacked patches in some runtime artifacts:

  • Resolver CLI without consistent lookup by delivery context (channel + to + accountId)
  • Command path not propagating sufficient context

Manual patch on compiled bundles — will be lost on updates/reinstall. Maintain re-application script.

PR fix notes

PR #44640: fix: three critical bug fixes for device pairing, Discord threads, and Feishu redirect

Description (problem / solution / changelog)

Summary

This PR contains three critical bug fixes:

1. Fix: WS node pairing persistence (Issue #44574)

  • Problem: WebSocket node pairing was auto-approved at runtime but never persisted to device-auth.json
  • Root cause: writeTextAtomic in src/infra/json-files.ts failed with EPERM errors during atomic file rename
  • Solution: Added renameWithRetry function with EBUSY retry and EPERM/EEXIST fallback to copyFile + unlink
  • Files: src/infra/json-files.ts (+26, -1)

2. Fix: Discord thread context handling (Issue #44586)

  • Problem: Discord threads missing RootMessageId and ThreadParentId fields
  • Root cause: Thread metadata not properly set during message processing
  • Solution: Added RootMessageId (equals thread ID) and ThreadParentId (parent channel ID) to thread contexts
  • Files:
    • src/discord/monitor/message-handler.process.ts
    • src/discord/monitor/native-command-context.ts
    • src/discord/monitor/native-command-context.test.ts (+2 tests)

3. Fix: Feishu CDN redirect loop (Issue #44572)

  • Problem: Feishu channel fails with ERR_FR_TOO_MANY_REDIRECTS due to HTTP/1.1 self-redirect loops
  • Root cause: Feishu CDN sometimes returns 301 redirects to the same URL; axios default limit of 21 redirects exceeded
  • Solution: Increased maxRedirects from 21 to 50 in Feishu client configuration
  • Files:
    • extensions/feishu/src/client.ts
    • extensions/feishu/src/client.test.ts (+test)

Testing

All fixes include test coverage:

  • ✅ WS pairing: Code logic matches verified cron/store.ts implementation
  • ✅ Discord threads: 4 new tests, all 39 monitor tests pass
  • ✅ Feishu: 15 tests pass, no linter errors

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Tests added for all changes
  • All tests pass locally
  • No new warnings introduced

🤖 Generated with CodeBuddy AI assistance

Changed files

  • apps/macos/Sources/OpenClaw/AppState.swift (modified, +2/-2)
  • apps/macos/Sources/OpenClaw/NodeMode/MacNodeBrowserProxy.swift (modified, +3/-1)
  • apps/macos/Sources/OpenClaw/OnboardingView+Pages.swift (modified, +6/-7)
  • apps/macos/Sources/OpenClaw/TalkModeGatewayConfig.swift (modified, +2/-2)
  • extensions/discord/src/monitor/message-handler.process.ts (modified, +7/-1)
  • extensions/discord/src/monitor/native-command-context.test.ts (modified, +66/-0)
  • extensions/discord/src/monitor/native-command-context.ts (modified, +7/-2)
  • extensions/feishu/src/client.test.ts (modified, +22/-0)
  • extensions/feishu/src/client.ts (modified, +36/-10)
  • extensions/telegram/src/bot-message-dispatch.ts (modified, +15/-10)
  • src/cron/store-migration.test.ts (modified, +76/-0)
  • src/cron/store-migration.ts (modified, +7/-5)
  • src/infra/json-files.ts (modified, +28/-1)
RAW_BUFFERClick to expand / collapse

Problem

Direct fix in OpenClaw runtime for two CLI/session routing regressions in Discord threads:

  1. Context growth from repeated metadata: Per-turn re-injection of message_id, reply_to_id, timestamp, Thread starter, InboundHistory
  2. Session resolver falling back to agent:*:main: Even when live thread-bound session exists

Impact

  • Progressive performance degradation in long threads
  • openclaw agent --channel discord --to ... resolves wrong session
  • Latency increases over conversation lifetime

Root Cause

Active bundles in dist/index.js lacked patches in some runtime artifacts:

  • Resolver CLI without consistent lookup by delivery context (channel + to + accountId)
  • Command path not propagating sufficient context

Files Modified (Active Runtime)

  • dist/reply-BCcP6j4h.js
  • dist/compact-1mmJ_KWL.js
  • dist/pi-embedded-Cz5VjpnY.js
  • dist/gateway-cli-B-E8XzUM.js
  • dist/register.agent-jS8B5meo.js

Operational Hardening

  • Automatic backups: *.bak-rootfix-20260313T023340Z
  • Idempotent re-application script: /home/clawd/scripts/openclaw-rootfix-v2026.3.11.sh
  • Gateway restarted and validated: active (running)

Recommended Non-Regression Testing

  1. Long conversation in same thread (reasoning/codex) — verify no metadata repetition growth
  2. 15-30 min monitoring: journalctl --user -u openclaw-gateway.service -f
  3. Add smoke test for regression (latency + context size per turn)

Verification Checklist

  • Gateway restarted successfully
  • No new errors in logs post-restart
  • Thread-bound sessions resolving correctly
  • CLI routing to actual target session

Important

Manual patch on compiled bundles — will be lost on updates/reinstall. Maintain re-application script.

Environment

  • OpenClaw version: 2026.3.11
  • Channel: Discord threads
  • Deployment: systemd service on Linux

Related Issues

  • Context growth in long conversations
  • CLI session resolution
  • Discord thread handling

extent analysis

Fix Plan

To address the regressions in Discord threads, we need to apply patches to the active bundles in dist/index.js. The main goal is to ensure consistent lookup by delivery context and propagate sufficient context in the command path.

Step-by-Step Solution

  1. Patch the resolver CLI: Modify the gateway-cli-B-E8XzUM.js file to include consistent lookup by delivery context (channel + to + accountId).
  2. Update command path: Modify the reply-BCcP6j4h.js file to propagate sufficient context.
  3. Apply patches to other bundles: Update the compact-1mmJ_KWL.js, pi-embedded-Cz5VjpnY.js, and register.agent-jS8B5meo.js files to ensure consistency.

Example Code Snippets

// gateway-cli-B-E8XzUM.js
const getSession = (channel, to, accountId) => {
  // Consistent lookup by delivery context
  return sessions.find((session) => session.channel === channel && session.to === to && session.accountId === accountId);
};

// reply-BCcP6j4h.js
const handleCommand = (command, context) => {
  // Propagate sufficient context
  const { channel, to, accountId } = context;
  const session = getSession(channel, to, accountId);
  // ...
};

Verification

To verify that the fix worked:

  1. Restart the gateway service.
  2. Monitor the logs for any new errors using journalctl --user -u openclaw-gateway.service -f.
  3. Test long conversations in the same thread to ensure no metadata repetition growth.
  4. Verify that thread-bound sessions are resolving correctly and the CLI is routing to the actual target session.

Extra Tips

  • Maintain the re-application script (/home/clawd/scripts/openclaw-rootfix-v2026.3.11.sh) to ensure the patches are reapplied after updates or reinstalls.
  • Add smoke tests for regression (latency + context size per turn) to prevent future occurrences.

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 threads root fix - runtime patches for context growth + session routing [1 pull requests, 1 participants]