Skip to content

Commit cad06fa

Browse files
fix: add session-memory hook support for Feishu provider (#31437)
* fix: add session-memory hook support for Feishu provider Issue #31275: Session-memory hook not triggered when using /new command in Feishu - Added command handler to Feishu provider - Integrated with OpenClaw's before_reset hook system - Ensures session memory is saved when /new or /reset commands are used * Changelog: note Feishu session-memory hook parity --------- Co-authored-by: Tak Hoffman <[email protected]>
1 parent a5a7239 commit cad06fa

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Docs: https://docs.openclaw.ai
3939
- Plugin command/runtime hardening: validate and normalize plugin command name/description at registration boundaries, and guard Telegram native menu normalization paths so malformed plugin command specs cannot crash startup (`trim` on undefined). (#31997) Fixes #31944. Thanks @liuxiaopai-ai.
4040
- Telegram: guard duplicate-token checks and gateway startup token normalization when account tokens are missing, preventing `token.trim()` crashes during status/start flows. (#31973) Thanks @ningding97.
4141
- Discord/lifecycle startup status: push an immediate `connected` status snapshot when the gateway is already connected before lifecycle debug listeners attach, with abort-guarding to avoid contradictory status flips during pre-aborted startup. (#32336) Thanks @mitchmcalister.
42+
- Feishu/session-memory hook parity: trigger the shared `before_reset` session-memory hook path when Feishu `/new` and `/reset` commands execute so reset flows preserve memory behavior consistent with other channels. (#31437) Thanks @Linux2010.
4243
- Feishu/LINE group system prompts: forward per-group `systemPrompt` config into inbound context `GroupSystemPrompt` for Feishu and LINE group/room events so configured group-specific behavior actually applies at dispatch time. (#31713) Thanks @whiskyboy.
4344
- Mentions/Slack formatting hardening: add null-safe guards for runtime text normalization paths so malformed/undefined text payloads do not crash mention stripping or mrkdwn conversion. (#31865) Thanks @stone-jin.
4445
- Feishu/Plugin sdk compatibility: add safe webhook default fallbacks when loading Feishu monitor state so mixed-version installs no longer crash if older `openclaw/plugin-sdk` builds omit webhook default constants. (#31606)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type { PluginHookRunner } from "openclaw/plugin-sdk";
2+
import { DEFAULT_RESET_TRIGGERS } from "../../../config/sessions/types.js";
3+
4+
/**
5+
* Handle Feishu command messages and trigger appropriate hooks
6+
*/
7+
export async function handleFeishuCommand(
8+
messageText: string,
9+
sessionKey: string,
10+
hookRunner: PluginHookRunner,
11+
context: {
12+
cfg: any;
13+
sessionEntry: any;
14+
previousSessionEntry?: any;
15+
commandSource: string;
16+
timestamp: number;
17+
}
18+
): Promise<boolean> {
19+
// Check if message is a reset command
20+
const trimmed = messageText.trim().toLowerCase();
21+
const isResetCommand = DEFAULT_RESET_TRIGGERS.some(trigger =>
22+
trimmed === trigger || trimmed.startsWith(`${trigger} `)
23+
);
24+
25+
if (isResetCommand) {
26+
// Extract the actual command (without arguments)
27+
const command = trimmed.split(' ')[0];
28+
29+
// Trigger the before_reset hook
30+
await hookRunner.runBeforeReset(
31+
{
32+
type: "command",
33+
action: command.replace('/', '') as "new" | "reset",
34+
context: {
35+
...context,
36+
commandSource: "feishu"
37+
}
38+
},
39+
{
40+
agentId: "main", // or extract from sessionKey
41+
sessionKey
42+
}
43+
);
44+
45+
return true; // Command was handled
46+
}
47+
48+
return false; // Not a command we handle
49+
}

0 commit comments

Comments
 (0)