-
-
Notifications
You must be signed in to change notification settings - Fork 69.5k
Internal hooks not triggered in auto-reply path due to missing sessionKey parameter #29203
Copy link
Copy link
Open
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Problem Description
Summary
Internal hooks are not being triggered with message:sent events when messages are sent through the auto-reply path, despite hooks being correctly registered and configured.
Evidence
- Hook Registration: ✅ Successful
[hooks:loader] Registered hook: glm5-token-tracker -> message:sent
[hooks] loaded 5 internal hook handlers
- Message Delivery: ✅ Successful
[telegram] sendMessage ok chat=-5270945987 message=6269
- Hook Execution: ❌ Not triggered
- No
[glm5-token-tracker]logs in gateway.log - No data written to tracking files
- Other bundled hooks (command-logger, session-memory) also not working
Root Cause Analysis
Traced through source code:
File: dist/reply-D-ejYZny.js (Line 23308)
await deliverOutboundPayloads({
cfg,
channel: deliveryChannel, // "telegram"
to: deliveryTarget,
payloads: deliveryPayloads,
agentId: deliveryAgentId,
// ...
// ⚠️ Missing parameters:
// - sessionKey
// - mirror
});File: dist/deliver-B2A1_Ib0.js (Line ~100)
const sessionKeyForInternalHooks = params.mirror?.sessionKey ?? params.sessionKey;
if (!sessionKeyForInternalHooks) return; // ⚠️ Hook not triggered
triggerInternalHook(...);Impact
- All internal hooks listening to
message:sentevents fail - Bundled hooks affected:
command-logger(command events)session-memory(command:new, reset events)
- Channels affected: All (Telegram, WhatsApp, Discord, Signal, etc.)
Workaround
Currently using plugin system as alternative, which works independently of hooks.
Questions
- Is this a design decision or a bug?
- What is the expected behavior?
- Should hooks trigger in auto-reply path?
- Or should documentation clarify this limitation?
- Are there plans to fix this?
- Should
sessionKeybe passed indeliverAgentCommandResult?
Environment
- OpenClaw version: 2026.2.23
- Node.js version: v22.22.0
- macOS: Darwin 22.6.0
- Channels: Telegram
Additional Context
I've created a demo hook to track token usage, which correctly registers but never executes. Other users may encounter similar issues with bundled hooks not working.
Related Code
- HTTP API path provides
sessionKey:dist/gateway-cli-BlDZ_8TO.js(Line 12415-12450) - Auto-reply path does NOT:
dist/reply-D-ejYZny.js(Line 23308)
Proposed Fix
Add sessionKey parameter in deliverAgentCommandResult:
// In reply-D-ejYZny.js around line 23213
const deliveryAgentId = opts.agentId ?? (opts.sessionKey ? resolveSessionAgentId({
sessionKey: opts.sessionKey,
config: cfg
}) : void 0);
await deliverOutboundPayloads({
cfg,
channel: deliveryChannel,
to: deliveryTarget,
payloads: deliveryPayloads,
agentId: deliveryAgentId,
sessionKey: opts.sessionKey, // ✅ Add this line
// ... existing parameters ...
});Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.