-
-
Notifications
You must be signed in to change notification settings - Fork 69.6k
agent_end hook passes wrong agentId (always 'agent' instead of actual agent ID) #39521
Copy link
Copy link
Closed
Closed
Copy link
Description
Bug
In reply-DpTyb3Hh.js, the agent_end hook extracts agentId incorrectly:
agentId: params.sessionKey?.split(":")[0] ?? "main",Session keys follow the format agent:<agentId>:main, so split(":")[0] always returns "agent" instead of the actual agent ID.
Expected
"agent:mao:main".split(":")[1]→"mao""agent:forge:main".split(":")[1]→"forge"
Actual
"agent:mao:main".split(":")[0]→"agent"(wrong)
Impact
Memory plugins (e.g. memory-lancedb-pro) that use ctx.agentId from agent_end events cannot correctly scope auto-captured memories per agent. In a multi-agent setup, only the main agent gets auto-capture working correctly because the plugin falls back to ctx?.agentId || "main".
Additionally, it appears agent_end may not fire at all for secondary agents (mao, forge) — only for the main agent. This could be a separate issue with how hookRunner is passed to reply handlers for non-default agents.
Environment
- OpenClaw 2026.3.2
- memory-lancedb-pro 1.1.0-beta.3
- Multi-agent setup with 3 agents (main, mao, forge)
Fix suggestion
// Extract agentId correctly from session key format "agent:<id>:<session>"
agentId: params.sessionKey?.startsWith("agent:")
? params.sessionKey.split(":")[1]
: "main",Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.