mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:50:43 +00:00
Session: skip binding lookup for system events
This commit is contained in:
@@ -214,7 +214,9 @@ function resolveBoundConversationSessionKey(params: {
|
||||
} | null;
|
||||
}): string | undefined {
|
||||
const bindingContext =
|
||||
params.bindingContext ?? resolveSessionConversationBindingContext(params.cfg, params.ctx);
|
||||
params.bindingContext === undefined
|
||||
? resolveSessionConversationBindingContext(params.cfg, params.ctx)
|
||||
: params.bindingContext;
|
||||
if (!bindingContext) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -239,7 +241,15 @@ export async function initSessionState(params: {
|
||||
commandAuthorized: boolean;
|
||||
}): Promise<SessionInitResult> {
|
||||
const { ctx, cfg, commandAuthorized } = params;
|
||||
const conversationBindingContext = resolveSessionConversationBindingContext(cfg, ctx);
|
||||
// Heartbeat, cron-event, and exec-event runs should NEVER trigger session
|
||||
// resets or conversation binding retargeting. These are automated system
|
||||
// events, not user interactions that should affect session continuity.
|
||||
// See #58409 for details on silent session reset bug.
|
||||
const isSystemEvent =
|
||||
ctx.Provider === "heartbeat" || ctx.Provider === "cron-event" || ctx.Provider === "exec-event";
|
||||
const conversationBindingContext = isSystemEvent
|
||||
? null
|
||||
: resolveSessionConversationBindingContext(cfg, ctx);
|
||||
// Native slash commands (Telegram/Discord/Slack) are delivered on a separate
|
||||
// "slash session" key, but should mutate the target chat session.
|
||||
const commandTargetSessionKey =
|
||||
@@ -422,12 +432,7 @@ export async function initSessionState(params: {
|
||||
resetType,
|
||||
resetOverride: channelReset,
|
||||
});
|
||||
// Heartbeat, cron-event, and exec-event runs should NEVER trigger session resets.
|
||||
// These are automated system events, not user interactions that should affect
|
||||
// session continuity. Forcing freshEntry=true prevents accidental data loss.
|
||||
// See #58409 for details on silent session reset bug.
|
||||
const isSystemEvent =
|
||||
ctx.Provider === "heartbeat" || ctx.Provider === "cron-event" || ctx.Provider === "exec-event";
|
||||
// Forcing freshEntry=true prevents accidental data loss on automated system events.
|
||||
const entryFreshness = entry
|
||||
? isSystemEvent
|
||||
? ({ fresh: true } satisfies SessionFreshness)
|
||||
|
||||
Reference in New Issue
Block a user