Skip to content

[Bug]: session-memory hook silently skipped for /new via Discord — command:new event not emitted #26293

@pk197197

Description

@pk197197

Summary

When /new is issued from a Discord guild channel (native slash command), the session resets and the bot responds normally, but command:new and command events are never emitted — causing session-memory, command-logger, and all other hooks to silently skip. The same /new from WebChat works correctly, even when targeting the same Discord channel session.

Steps to reproduce

  1. Confirm hooks are loaded:

    openclaw hooks list
    → session-memory ✓ ready (command:new, command:reset)
    → command-logger ✓ ready (command)
    
  2. Send /new from Discord (native slash command in a guild channel)

    • Bot responds with new session greeting ✅
    • WebUI shows new session created ✅
  3. Check memory directory:

    ls ~/.openclaw/workspace/memory/

    → No new .md file created ❌

  4. Check logs:

    grep "session-memory" ~/.openclaw/logs/gateway.log | tail -5
    tail -3 ~/.openclaw/logs/commands.log | jq .

    → No hook execution logged, no command-logger entry ❌

  5. Now send /new from WebChat (Control UI) — memory file is created ✅

Expected behavior

/new from Discord should emit command:new and command events, triggering all registered hooks (session-memory, command-logger). A memory file (YYYY-MM-DD-slug.md) should be generated in <workspace>/memory/, same as when /new is issued from WebChat.

Actual behavior

/new from Discord:

  • Session resets correctly ✅
  • Bot responds with greeting ✅
  • command:new event is not emitted → session-memory hook does not run ❌
  • command event is not emitted → command-logger does not run ❌
  • No memory file generated ❌
  • No error logged ❌

The handler (dist/bundled/session-memory/handler.js) has only one early return (if (event.type !== "command" || !isResetCommand) return;). After that, every code path leads to either log.info or log.error. The complete absence of both confirms the handler was never invoked.

OpenClaw version

2026.2.23 (b817600)

Operating system

macOS (Apple Silicon, Mac Studio)

Install method

npm install -g openclaw@latest

Logs, screenshots, and evidence

### commands.log comparison

Discord `/new` was logged by command-logger earlier (Feb 15–21), but session-memory **never produced any output** for any of them:


// Discord — command-logger recorded, session-memory never ran
{"timestamp":"2026-02-21T14:26:42.476Z","action":"new","sessionKey":"agent:main:discord:channel:<CHANNEL_ID>","senderId":"<DISCORD_USER_ID>","source":"discord"}

// WebChat — both hooks ran successfully (same channel session!)
{"timestamp":"2026-02-24T18:52:11.487Z","action":"new","sessionKey":"agent:main:discord:channel:<CHANNEL_ID>","senderId":"openclaw-control-ui","source":"webchat"}


The WebChat entry targets the **same Discord channel session** and successfully generates a memory file. This rules out session-key-specific issues.

### gateway.log — zero hook activity for Discord `/new`

Every `Session context saved` entry corresponds to WebChat. Not a single instance from Discord:


2026-02-24T15:26:19+08:00 [hooks/session-memory] Session context saved to ~/.openclaw/workspace/memory/2026-02-24-0726.md  ← webchat
2026-02-24T15:27:59+08:00 [hooks/session-memory] Session context saved to ~/.openclaw/workspace/memory/2026-02-24-0727.md  ← webchat
2026-02-25T02:52:11+08:00 [hooks/session-memory] Session context saved to ~/.openclaw/workspace/memory/2026-02-24-1852.md  ← webchat


### gateway.err.log — WebChat triggers slug-generator, Discord does not


[diagnostic] lane task error: lane=session:temp:slug-generator ... "No API key found for provider \"anthropic\""
[llm-slug-generator] Failed to generate slug: Error: No API key found for provider "anthropic".


Hook ran via WebChat, slug failed (fell back to timestamp), file still saved. For Discord: **no slug-generator activity at all**.

### Memory directory

20+ `/new` from Discord (Feb 15–24) → zero files. All existing files are from WebChat.

Impact and severity

  • Affected: All users who primarily interact via Discord channels. Any hook listening to command:new or command:reset events is affected (not just session-memory).
  • Severity: Blocks workflow — Discord users silently lose all session memory on /new. No error is surfaced, so users may not realize memory is not being saved.
  • Frequency: Always. 100% reproducible. Tested 20+ times across multiple days and two different Discord channels.
  • Consequence: Complete loss of session context for Discord users. The session-memory feature effectively does not work on Discord, which is one of the most common OpenClaw channels.

Additional information

Suspected root cause

The Discord native slash command handler for /new likely executes the session reset logic directly but does not call the hook event emitter. The WebChat and text-command code paths do emit these events.

Relevant source files:

  • src/discord/monitor.ts — Discord interaction handler
  • src/auto-reply/reply/commands-core.ts — command processing
  • src/auto-reply/commands-registry.data.ts — command registry

Workaround

Use WebChat Control UI, switch to the Discord channel session, and click "New Session". This triggers the WebChat code path which correctly emits hook events.

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    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