Subagents: restore announce chain + fix nested retry/drop regressions (#22223)

* Subagents: restore announce flow and fix nested delivery retries

* fix: prep subagent announce + docs alignment (#22223) (thanks @tyler6204)
This commit is contained in:
Tyler Yust
2026-02-20 15:39:09 -08:00
committed by GitHub
parent 086af56867
commit fe57bea088
21 changed files with 579 additions and 985 deletions

View File

@@ -1,19 +1,12 @@
import crypto from "node:crypto";
import type { OpenClawConfig } from "../../config/config.js";
import {
evaluateSessionFreshness,
loadSessionStore,
resolveSessionResetPolicy,
resolveStorePath,
type SessionEntry,
} from "../../config/sessions.js";
import { loadSessionStore, resolveStorePath, type SessionEntry } from "../../config/sessions.js";
export function resolveCronSession(params: {
cfg: OpenClawConfig;
sessionKey: string;
nowMs: number;
agentId: string;
forceNew?: boolean;
}) {
const sessionCfg = params.cfg.session;
const storePath = resolveStorePath(sessionCfg?.store, {
@@ -21,42 +14,8 @@ export function resolveCronSession(params: {
});
const store = loadSessionStore(storePath);
const entry = store[params.sessionKey];
// Check if we can reuse an existing session
let sessionId: string;
let isNewSession: boolean;
let systemSent: boolean;
if (!params.forceNew && entry?.sessionId) {
// Evaluate freshness using the configured reset policy
// Cron/webhook sessions use "direct" reset type (1:1 conversation style)
const resetPolicy = resolveSessionResetPolicy({
sessionCfg,
resetType: "direct",
});
const freshness = evaluateSessionFreshness({
updatedAt: entry.updatedAt,
now: params.nowMs,
policy: resetPolicy,
});
if (freshness.fresh) {
// Reuse existing session
sessionId = entry.sessionId;
isNewSession = false;
systemSent = entry.systemSent ?? false;
} else {
// Session expired, create new
sessionId = crypto.randomUUID();
isNewSession = true;
systemSent = false;
}
} else {
// No existing session or forced new
sessionId = crypto.randomUUID();
isNewSession = true;
systemSent = false;
}
const sessionId = crypto.randomUUID();
const systemSent = false;
const sessionEntry: SessionEntry = {
// Preserve existing per-session overrides even when rolling to a new sessionId.
@@ -66,5 +25,5 @@ export function resolveCronSession(params: {
updatedAt: params.nowMs,
systemSent,
};
return { storePath, store, sessionEntry, systemSent, isNewSession };
return { storePath, store, sessionEntry, systemSent, isNewSession: true };
}