mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 18:31:10 +00:00
fix(cron): respect subagents.model in isolated cron sessions (#11474)
* fix(cron): respect subagents.model in isolated cron sessions * fix(cron): enforce model allowlist for subagents.model * Cron: fix isolated subagent model gate regressions --------- Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,7 @@ import { runWithModelFallback } from "../../agents/model-fallback.js";
|
||||
import {
|
||||
getModelRefStatus,
|
||||
isCliProvider,
|
||||
normalizeModelSelection,
|
||||
resolveAllowedModelRef,
|
||||
resolveConfiguredModelRef,
|
||||
resolveHooksGmailModel,
|
||||
@@ -160,6 +161,7 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
});
|
||||
let provider = resolvedDefault.provider;
|
||||
let model = resolvedDefault.model;
|
||||
|
||||
let catalog: Awaited<ReturnType<typeof loadModelCatalog>> | undefined;
|
||||
const loadCatalog = async () => {
|
||||
if (!catalog) {
|
||||
@@ -167,6 +169,24 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
}
|
||||
return catalog;
|
||||
};
|
||||
// Isolated cron sessions are subagents — prefer subagents.model when set,
|
||||
// but only if it passes the model allowlist. #11461
|
||||
const subagentModelRaw =
|
||||
normalizeModelSelection(agentConfigOverride?.subagents?.model) ??
|
||||
normalizeModelSelection(params.cfg.agents?.defaults?.subagents?.model);
|
||||
if (subagentModelRaw) {
|
||||
const resolvedSubagent = resolveAllowedModelRef({
|
||||
cfg: cfgWithAgentDefaults,
|
||||
catalog: await loadCatalog(),
|
||||
raw: subagentModelRaw,
|
||||
defaultProvider: resolvedDefault.provider,
|
||||
defaultModel: resolvedDefault.model,
|
||||
});
|
||||
if (!("error" in resolvedSubagent)) {
|
||||
provider = resolvedSubagent.ref.provider;
|
||||
model = resolvedSubagent.ref.model;
|
||||
}
|
||||
}
|
||||
// Resolve model - prefer hooks.gmail.model for Gmail hooks.
|
||||
const isGmailHook = baseSessionKey.startsWith("hook:gmail:");
|
||||
let hooksGmailModelApplied = false;
|
||||
|
||||
Reference in New Issue
Block a user