#Clawdbot stuck indexing Discord

1 messages Β· Page 1 of 1 (latest)

misty nebulaBOT
#

Ouch, that sounds frustrating. Let me help you untangle this:

The Discord token issue:
When you hit Discord's rate limits hard enough (which indexing a long history definitely can do), Discord sometimes invalidates the bot token as a protective measure. You'll need to:

  1. Go to the Discord Developer Portal
  2. Select your bot β†’ Bot section β†’ Reset Token
  3. Copy the new token and update your Clawdbot config (gateway config.apply or edit your config file directly)

The stuck Telegram session:
The "typing on/off" loop suggests a session that's caught in an infinite retry loop or waiting on something that'll never complete. Your options:

  1. Restart the gateway - cleanest fix. If you have shell access:
    sudo systemctl restart clawdbot
    
    Or send /restart if you have another working channel to reach it
#
  1. Kill the stuck session - if you can reach Clawdbot through any channel, you can use sessions_list to find the runaway session and potentially interrupt it

For next time:
Discord history indexing should be done with careful rate limiting - like 1 request per second with exponential backoff. The Discord skill should handle this, but a "long history" can still trip things up if it's hitting thousands of messages across many channels.


What access do you currently have to your Clawdbot instance? Can you SSH into the host, or is Discord/Telegram your only way in?

hard iron
#

I have it on a macOS system using npm install. How do I stop it from doing what it's stuck on?

misty nebulaBOT
#

Easy fix for macOS/npm setup:

Option 1: If it's running in a terminal window
Just hit Ctrl+C to kill it, then restart with npm start (or however you normally launch it)

Option 2: If it's running in the background

# Find the process
ps aux | grep -i clawdbot

# Or find node processes
ps aux | grep node

# Kill it (replace PID with the actual number)
kill PID
#
# If it won't die:
kill -9 PID

Option 3: Nuclear option

# Kill all node processes (careful if you have other node apps running)
killall node

Then just restart Clawdbot normally.


Once it's back up, the stuck session state should be cleared. If you want to retry the Discord indexing later, let me know and I can suggest a gentler approach that won't anger the rate limit gods 🐒

hard iron
#

No luck, the process keeps respawning by itself with different PIDs. Even restarting doesn't do anything.

misty nebulaBOT
#

Ah, something's supervising it and restarting it automatically. Let's figure out what:

Check for pm2 (common for Node apps):

pm2 list
pm2 stop all
# or
pm2 stop clawdbot

Check for launchd (macOS's built-in service manager):

# List any clawdbot-related launch agents
ls ~/Library/LaunchAgents/ | grep -i claw
ls /Library/LaunchAgents/ | grep -i claw
#
# If you find one, unload it:
launchctl unload ~/Library/LaunchAgents/com.whatever.clawdbot.plist

Check what's spawning the process:

# Find the parent process
ps -o ppid= -p $(pgrep -f clawdbot)

# Then see what that parent is
ps -p <parent_pid>

Brute force - find and kill the supervisor too:

#
pgrep -fl clawdbot
pgrep -fl node

This'll show you the full command lines - look for anything that looks like a watcher/supervisor.


What does pm2 list show? That's my top guess for a npm-based setup that auto-respawns.

hard iron
#

pm2 is not installed

misty nebulaBOT
#

Okay, let's dig deeper. Run these:

# What's the parent of the node process?
ps -o ppid,pid,command -p $(pgrep -f node | head -1)

# Or see the whole process tree
pstree -p $(pgrep -f clawdbot | head -1)
# If pstree isn't available:
ps -ef | grep -E 'node|clawdbot'

Also check:

# Any launchd jobs?
launchctl list | grep -i claw
#
launchctl list | grep -i node

# Running in a shell with auto-restart?
ps aux | grep -E 'bash|zsh|sh' | grep -v grep

Quick question: How did you originally set it up to run? Did you:

  • Just run npm start in a terminal?
  • Follow a guide that had you create a service?
  • Use something like nodemon or a watch script?

If you're not sure, check the package.json:

cat package.json | grep -A5 '"scripts"'
#

That might reveal if there's a watcher or auto-restart built into the start command.


The respawning has to be coming from somewhere - once we find the supervisor, we can properly stop it.

hard iron
misty nebulaBOT
#

Found it! This is a context overflow crash loop:

prompt is too long: 204654 tokens > 200000 maximum

The Discord indexing stuffed 204K tokens into the session β€” way over the 200K limit. Now every restart:

  1. Clawdbot loads the bloated session
  2. Tries to compact/summarize it
  3. Fails (too big even for that)
  4. Crashes
  5. Restarts β†’ repeat

The fix: Delete the corrupted session

You need to be fast (or do it in one command):

#
# Kill and immediately delete the session
pkill -9 -f clawdbot && rm -rf ~/.clawdbot/sessions/613be49b-7c8a-42bf-98cc-4f4645cd8639

# Or delete ALL sessions (nuclear option if the above doesn't work fast enough)
pkill -9 -f clawdbot && rm -rf ~/.clawdbot/sessions/*

Then restart Clawdbot normally.


Bonus issue spotted:

[default] provider exited: Failed to resolve Discord application id
#

Your Discord token is also dead (probably from the rate limiting earlier). You'll need to regenerate it in the Discord Developer Portal and update your config once you've broken the crash loop.

hard iron
#

Here are the logs after. No joy.

01:47:12 error [clawdbot] Unhandled promise rejection: Error: Context overflow: Summarization failed: 400 {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 204654 tokens > 200000 maximum"},"request_id":"req_011CX2e8PQzyaBS4C9d7BX9J"}. Your input may be too large for the context window.
at AgentSession._runAutoCompaction (file:///Users/primate/.nvm/versions/node/v24.12.0/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:1456:11)
at processTicksAndRejections (node:internal/process/task_queues:103:5)
at AgentSession._checkCompaction (file:///Users/primate/.nvm/versions/node/v24.12.0/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:1318:4)
at _handleAgentEvent (file:///Users/primate/.nvm/versions/node/v24.12.0/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:315:4)
01:47:18 info gateway/canvas {"subsystem":"gateway/canvas"} canvas host mounted at http://127.0.0.1:18789/__clawdbot__/canvas/ (root /Users/primate/clawd/canvas)
01:47:18 info gateway/canvas {"subsystem":"gateway/canvas"} canvas host listening on http://0.0.0.0:18793 (root /Users/primate/clawd/canvas)
01:47:18 info gateway/bridge {"subsystem":"gateway/bridge"} listening on tcp://0.0.0.0:18790 (node)
01:47:18 info gateway/heartbeat {"subsystem":"gateway/heartbeat"} {"intervalMs":1800000} heartbeat: started
01:47:18 info gateway {"subsystem":"gateway"} agent model: anthropic/claude-opus-4-5
01:47:18 info gateway {"subsystem":"gateway"} listening on ws://127.0.0.1:18789 (PID 31075)
01:47:18 info gateway {"subsystem":"gateway"} log file: /tmp/clawdbot/clawdbot-2026-01-12.log
01:47:18 info browser/server {"subsystem":"browser/server"} Browser control listening on http://127.0.0.1:18791/
01:47:18 info gateway/providers/whatsapp {"subsystem":"gateway/providers/whatsapp"} [default] skipping provider start (no linked session)
01:47:18 info cron {"module":"cron","storePath":"/Users/primate/.clawdbot/cron/jobs.json"} {"enabled":true,"jobs":1,"nextWakeAtMs":1768219200000} cron: started
01:47:18 info gateway/providers/discord {"subsystem":"gateway/providers/discord"} [default] starting provider
01:47:19 error gateway/providers/discord {"subsystem":"gateway/providers/discord"} [default] provider exited: Failed to resolve Discord application id
01:47:19 info bonjour: advertised bridge fqdn=X (Clawdbot)._clawdbot-bridge._tcp.local. host=X.local. port=18790 state=announcing
01:47:19 info gateway/providers/telegram {"subsystem":"gateway/providers/telegram"} [default] starting provider (@pr1m4sbot)
01:47:20 info agents/auth-profiles {"subsystem":"agents/auth-profiles"} read anthropic credentials from claude cli keychain
01:47:20 debug agent/embedded {"subsystem":"agent/embedded"} embedded run start: runId=571965b4-41e7-4040-8bd7-f9a596565dfe sessionId=613be49b-7c8a-42bf-98cc-4f4645cd8639 provider=anthropic model=claude-opus-4-5 thinking=low messageProvider=telegram
01:47:20 info agents/auth-profiles {"subsystem":"agents/auth-profiles"} read anthropic credentials from claude cli keychain
01:47:20 debug agent/embedded {"subsystem":"agent/embedded"} embedded run prompt start: runId=571965b4-41e7-4040-8bd7-f9a596565dfe sessionId=613be49b-7c8a-42bf-98cc-4f4645cd8639
01:47:20 debug agent/embedded {"subsystem":"agent/embedded"} embedded run agent start: runId=571965b4-41e7-4040-8bd7-f9a596565dfe

misty nebulaBOT
#

The session is still there (same ID 613be49b-7c8a-42bf-98cc-4f4645cd8639). The delete didn't take β€” either wrong path or it respawned too fast.

Let's find the actual session location and nuke it properly:

# Find where sessions actually live
find ~/.clawdbot /Users/primate -name "613be49b*" -type d 2>/dev/null

# Also check for session files
find ~/.clawdbot /Users/primate -name "*613be49b*" 2>/dev/null

Then, one-liner that should work:

# Kill, sleep (so nothing respawns mid-delete), delete, verify
pkill -9 -f node; sleep 2; rm -rf ~/.clawdbot/sessions/613be49b-7c8a-42bf-98cc-4f4645cd8639; ls ~/.clawdbot/sessions/
#

If sessions folder is elsewhere, try:

pkill -9 -f node; sleep 2; find ~ -name "613be49b*" -type d -exec rm -rf {} + 2>/dev/null; echo "done"

Also β€” what's respawning Clawdbot? If we can stop that first, this becomes much easier:

# After killing, does it come back on its own?
pkill -9 -f node && sleep 10 && pgrep -f clawdbot

If it returns after 10 seconds without you manually starting it, something (launchd? a script?) is supervising it. We need to stop that first.

hard iron
misty nebulaBOT
#

Still looping β€” the session wasn't deleted. Let's do this systematically.

Step 1: Stop the auto-respawn first

The PIDs increment every ~10 seconds (32157 β†’ 32180). Something is definitely supervising this. Let's find it:

# Check launchctl for anything clawdbot-related
launchctl list | grep -iE 'clawdbot|node'

# Look for launch agents
ls -la ~/Library/LaunchAgents/ 2>/dev/null
cat ~/Library/LaunchAgents/*.plist 2>/dev/null | grep -i clawdbot

Step 2: Find where sessions actually live

#
# Search broadly for this session ID
sudo find / -name "*613be49b*" 2>/dev/null

# Or just in likely places
find ~/.clawdbot ~/clawd /tmp -name "*613be49b*" 2>/dev/null
find ~/.clawdbot ~/clawd -type f -name "*.json" -exec grep -l "613be49b" {} \; 2>/dev/null

Step 3: Check what's in the sessions folder

ls -la ~/.clawdbot/sessions/ 2>/dev/null
ls -la ~/.clawdbot/ 2>/dev/null

#

Run those and paste the output β€” once we know where it's restarting from AND where the session lives, we can kill both properly.

hard iron
#

02:59:03 info agents/auth-profiles {"subsystem":"agents/auth-profiles"} read anthropic credentials from claude cli keychain
02:59:03 debug agent/embedded {"subsystem":"agent/embedded"} embedded run prompt start: runId=a0266c33-e8d6-46a1-9569-e82512d0572f sessionId=613be49b-7c8a-42bf-98cc-4f4645cd8639
02:59:03 debug agent/embedded {"subsystem":"agent/embedded"} embedded run agent start: runId=a0266c33-e8d6-46a1-9569-e82512d0572f
02:59:04 debug agent/embedded {"subsystem":"agent/embedded"} embedded run agent end: runId=a0266c33-e8d6-46a1-9569-e82512d0572f
02:59:04 debug agent/embedded {"subsystem":"agent/embedded"} embedded run compaction start: runId=a0266c33-e8d6-46a1-9569-e82512d0572f
02:59:04 debug agent/embedded {"subsystem":"agent/embedded"} embedded run prompt end: runId=a0266c33-e8d6-46a1-9569-e82512d0572f sessionId=613be49b-7c8a-42bf-98cc-4f4645cd8639 durationMs=763
02:59:05 debug agent/embedded {"subsystem":"agent/embedded"} embedded run done: runId=a0266c33-e8d6-46a1-9569-e82512d0572f sessionId=613be49b-7c8a-42bf-98cc-4f4645cd8639 durationMs=2046 aborted=false
02:59:05 error [clawdbot] Unhandled promise rejection: Error: Context overflow: Summarization failed: 400 {"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 210912 tokens > 200000 maximum"},"request_id":"req_011CX2jcHZtMR4jZ8uUE39VL"}. Your input may be too large for the context window.
at AgentSession._runAutoCompaction (file:///Users/primate/.nvm/versions/node/v24.12.0/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:1456:11)
at processTicksAndRejections (node:internal/process/task_queues:103:5)
at AgentSession._checkCompaction (file:///Users/primate/.nvm/versions/node/v24.12.0/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:1318:4)
at _handleAgentEvent (file:///Users/primate/.nvm/versions/node/v24.12.0/lib/node_modules/clawdbot/node_modules/@mariozechner/pi-coding-agent/src/core/agent-session.ts:315:4)
02:59:11 info gateway/canvas {"subsystem":"gateway/canvas"} canvas host mounted at http://127.0.0.1:18789/__clawdbot__/canvas/ (root /Users/primate/clawd/canvas)
02:59:11 info gateway/canvas {"subsystem":"gateway/canvas"} canvas host listening on http://0.0.0.0:18793 (root /Users/primate/clawd/canvas)
02:59:11 info gateway/bridge {"subsystem":"gateway/bridge"} listening on tcp://0.0.0.0:18790 (node)
02:59:11 info gateway/heartbeat {"subsystem":"gateway/heartbeat"} {"intervalMs":1800000} heartbeat: started
02:59:11 info gateway {"subsystem":"gateway"} agent model: anthropic/claude-opus-4-5
02:59:11 info gateway {"subsystem":"gateway"} listening on ws://127.0.0.1:18789 (PID 34326)
02:59:11 info gateway {"subsystem":"gateway"} log file: /tmp/clawdbot/clawdbot-2026-01-12.log
02:59:11 info browser/server {"subsystem":"browser/server"} Browser control listening on http://127.0.0.1:18791/
02:59:11 info gateway/providers/whatsapp {"subsystem":"gateway/providers/whatsapp"} [default] skipping provider start (no linked session)
02:59:11 info cron {"module":"cron","storePath":"/Users/primate/.clawdbot/cron/jobs.json"} {"enabled":true,"jobs":1,"nextWakeAtMs":1768219200000} cron: started
02:59:12 info gateway/providers/discord {"subsystem":"gateway/providers/discord"} [default] Discord Message Content Intent is limited; bots under 100 servers can use it without verification.

misty nebulaBOT
#

The logs tell the whole story:

prompt is too long: 210912 tokens > 200000 maximum

Your crustacean hit a nasty edge case: the context grew to 210k tokens, and when Clawdbot tried to auto-summarize (compaction), the summarization request itself exceeded the 200k limit. It's stuck in a loop - can't proceed, can't compact.

The "typing/not typing" dance is likely it repeatedly trying to recover and failing.

To recover:

  1. Kill the stuck session - restart Clawdbot entirely, or if you can access the CLI/web interface, end that specific session
  2. Start fresh - the session state is probably corrupted by the overflow

To avoid next time:

#

Indexing long Discord history needs to be chunked - fetch a month at a time, summarize, store to files, then continue. Trying to hold years of chat in context will always hit this wall.

The Discord token reset was probably separate - aggressive API calls can trigger Discord's abuse detection. Rate limiting is essential when bulk-fetching history.

Want help designing a safer incremental indexing approach? The key is: fetch β†’ process β†’ persist to disk β†’ clear context β†’ repeat. Never try to hold it all in memory.

hard iron
#

Tell me how to do it better.

misty nebulaBOT
#

Fair. Here's the clean version:


Step 1: Stop the respawner

Open Terminal and run:

launchctl list | grep -i clawdbot

If you see something like com.clawdbot.agent, unload it:

launchctl bootout gui/$(id -u) ~/Library/LaunchAgents/com.clawdbot*.plist

If nothing shows, just kill node and keep the terminal ready:

#
pkill -9 -f node

Step 2: Find and delete the session (immediately after killing)

rm -rf ~/.clawdbot/sessions/*

Step 3: Restart manually

#
cd /path/to/your/clawdbot  # wherever you installed it
npm start

If the session isn't in ~/.clawdbot/sessions/, find it first:

find ~ -type d -name "613be49b*" 2>/dev/null

That's it. Three steps. Stop respawn β†’ delete session β†’ start fresh.

Want me to walk you through it one command at a time?

hard iron
#

Tell me how to crawl all the history properly.

misty nebulaBOT
#

Good question β€” here's how to do it without blowing up your context or getting rate-limited:


The right way: Export to files, not into the session

# Create a directory for the export
mkdir -p ~/discord-history

Then ask your bot to do something like:

"Fetch all messages from Discord channel [ID] and save them to ~/discord-history/channel-name.json. Paginate with 100 messages per request, wait 1 second between requests. Don't keep the messages in your context β€” just write them to the file."


#

Key principles:

  1. Write to files, not memory β€” The bot should stream results to disk, not accumulate 200K tokens in-context

  2. Rate limit yourself β€” Discord allows ~50 requests/second but will punish bursts. 1 req/sec is safe. For large history, 1 req every 2 seconds is safer.

  3. Paginate properly β€” Use before=<last_message_id> to page backward through history

  4. One channel at a time β€” Don't try to index your whole server in one go


Example prompt that should work:

"Export Discord channel 123456789 to ~/discord-history/general.jsonl. Fetch 100 messages at a time, sleep 1.5 seconds between requests, and write each batch directly to the file. Don't store messages in context. Just log progress every 500 messages."