openclaw - ✅(Solved) Fix Feishu webhook channel does not trigger agent_end hook [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#63018Fetched 2026-04-09 07:59:29
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Root Cause

In extensions/feishu/index.js, the plugin registers:

  • subagent_spawning
  • subagent_delivery_target
  • subagent_ended

But it does NOT register:

  • agent_end
  • before_compaction
  • after_compaction

The agent_end hook is required by memory plugins like session-save and memory-core to trigger automatic memory capture.

Fix Action

Fixed

PR fix notes

PR #63044: fix(agents): initialize hook runner for runtime loads #63018

Description (problem / solution / changelog)

Summary

  • Problem: Feishu webhook / embedded-runner flows can load a runtime plugin registry without activating the global hook runner, so lifecycle hooks like agent_end may never fire.
  • Why it matters: Memory and session plugins that depend on agent_end (and related lifecycle phases) miss end-of-turn notifications on Feishu, causing silent feature gaps.
  • What changed: When ensureRuntimePluginsLoaded(...) returns a registry and there is no global hook runner yet, initialize it so agent_end and other hooks are available.
  • What did NOT change (scope boundary): No Feishu-specific pipeline changes; no new hook types; no changes to hook payload schemas.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Fixes #63018

User-visible / Behavior Changes

Feishu (and other embedded-runner runtime flows) will now reliably trigger agent_end hooks once a runtime plugin registry is loaded, enabling memory/session plugins that rely on end-of-turn lifecycle.

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)

Repro + Verification

Environment

  • OS: Linux
  • Runtime/container: Node (repo default)
  • Integration/channel (if any): Feishu (webhook / embedded-runner paths)
  • Relevant config (redacted): N/A

Steps

  1. Ensure runtime plugins are loaded via ensureRuntimePluginsLoaded(...).
  2. Run an embedded agent turn that expects agent_end hooks to be available.
  3. Observe agent_end hook handlers firing after the turn completes.

Expected

  • agent_end hooks run when a runtime plugin registry exists.

Actual (before)

  • Some runtime/embedded-runner flows had a registry but no global hook runner, so agent_end hooks were skipped.

Evidence

  • Passing test: pnpm test src/agents/runtime-plugins.test.ts

Human Verification (required)

  • Verified scenarios: unit-level behavior that hook runner initializes when a registry is returned and no runner exists; no re-init when runner already exists.
  • Edge cases checked: runner already initialized; registry missing/undefined.
  • What you did not verify: end-to-end Feishu webhook integration run (requires external Feishu setup).

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: revert the commit touching src/agents/runtime-plugins.ts.
  • Known bad symptoms reviewers should watch for: unexpected hook runner initialization timing in unusual test harnesses.

Risks and Mitigations

  • Risk: initializing the global hook runner earlier than before in some runtime-only processes.
    • Mitigation: only initializes when a registry is successfully returned and no runner exists; includes unit coverage for both branches.

Changed files

  • src/agents/runtime-plugins.test.ts (modified, +36/-0)
  • src/agents/runtime-plugins.ts (modified, +8/-1)
RAW_BUFFERClick to expand / collapse

Bug Description

The Feishu channel plugin only registers subagent_ended hook, but not agent_end hook. This causes memory plugins (session-save, memory-core autoCapture) to not receive notifications when a Feishu conversation ends.

Root Cause

In extensions/feishu/index.js, the plugin registers:

  • subagent_spawning
  • subagent_delivery_target
  • subagent_ended

But it does NOT register:

  • agent_end
  • before_compaction
  • after_compaction

The agent_end hook is required by memory plugins like session-save and memory-core to trigger automatic memory capture.

Expected Behavior

When a Feishu message is processed and the agent responds, the agent_end hook should fire so that:

  1. session-save plugin can write session summary to memory/sessions/
  2. memory-core can trigger auto-capture
  3. Pre-compaction memory flush can run

Current Behavior

  • Feishu sessions do NOT trigger agent_end hook
  • Memory plugins that depend on agent_end silently fail for Feishu channels
  • Only WebChat/cron sessions properly trigger memory capture

Additional Context

This is the same root cause as OpenViking issue #1097 where Feishu webhook does not trigger afterTurn.

The fix would be to call hookRunner.runAgentEnd() in the Feishu message processing pipeline, similar to how other channels trigger it.

Suggested Fix

Add agent_end hook registration in the Feishu plugin and ensure it is called when a Feishu agent reply completes.

extent analysis

TL;DR

Register the agent_end hook in the Feishu channel plugin to enable memory plugins to receive notifications when a Feishu conversation ends.

Guidance

  • Identify the Feishu plugin registration code in extensions/feishu/index.js and add the agent_end hook registration.
  • Ensure the hookRunner.runAgentEnd() function is called when a Feishu agent reply completes, similar to other channels.
  • Verify that the session-save and memory-core plugins receive notifications and trigger automatic memory capture when a Feishu conversation ends.
  • Review the OpenViking issue #1097 for additional context on the root cause.

Example

// In extensions/feishu/index.js
// Add agent_end hook registration
plugin.registerHook('agent_end', (payload) => {
  // Call hookRunner.runAgentEnd() when a Feishu agent reply completes
  hookRunner.runAgentEnd(payload);
});

Notes

The suggested fix assumes that the hookRunner.runAgentEnd() function is already implemented and available in the codebase. If not, additional implementation may be required.

Recommendation

Apply workaround: Register the agent_end hook in the Feishu channel plugin and ensure it is called when a Feishu agent reply completes, as this will enable memory plugins to receive notifications and trigger automatic memory capture.

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