mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 16:10:35 +00:00
fix (heartbeat/cron): preserve cron prompts for tagged interval events
This commit is contained in:
@@ -59,7 +59,7 @@ import {
|
||||
resolveHeartbeatDeliveryTarget,
|
||||
resolveHeartbeatSenderContext,
|
||||
} from "./outbound/targets.js";
|
||||
import { peekSystemEvents } from "./system-events.js";
|
||||
import { peekSystemEventEntries } from "./system-events.js";
|
||||
|
||||
type HeartbeatDeps = OutboundSendDeps &
|
||||
ChannelHeartbeatDeps & {
|
||||
@@ -487,11 +487,23 @@ export async function runHeartbeatOnce(opts: {
|
||||
// If so, use a specialized prompt that instructs the model to relay the result
|
||||
// instead of the standard heartbeat prompt with "reply HEARTBEAT_OK".
|
||||
const isExecEvent = opts.reason === "exec-event";
|
||||
const isCronEvent = Boolean(opts.reason?.startsWith("cron:"));
|
||||
const pendingEvents = isExecEvent || isCronEvent ? peekSystemEvents(sessionKey) : [];
|
||||
const cronEvents = pendingEvents.filter((evt) => isCronSystemEvent(evt));
|
||||
const pendingEventEntries = peekSystemEventEntries(sessionKey);
|
||||
const hasTaggedCronEvents = pendingEventEntries.some((event) =>
|
||||
event.contextKey?.startsWith("cron:"),
|
||||
);
|
||||
const shouldInspectPendingEvents = isExecEvent || isCronEventReason || hasTaggedCronEvents;
|
||||
const pendingEvents = shouldInspectPendingEvents
|
||||
? pendingEventEntries.map((event) => event.text)
|
||||
: [];
|
||||
const cronEvents = pendingEventEntries
|
||||
.filter(
|
||||
(event) =>
|
||||
(isCronEventReason || event.contextKey?.startsWith("cron:")) &&
|
||||
isCronSystemEvent(event.text),
|
||||
)
|
||||
.map((event) => event.text);
|
||||
const hasExecCompletion = pendingEvents.some(isExecCompletionEvent);
|
||||
const hasCronEvents = isCronEvent && cronEvents.length > 0;
|
||||
const hasCronEvents = cronEvents.length > 0;
|
||||
const prompt = hasExecCompletion
|
||||
? EXEC_EVENT_PROMPT
|
||||
: hasCronEvents
|
||||
|
||||
Reference in New Issue
Block a user