

























@@ -62,6 +62,7 @@ import { runWithModelFallback } from "./model-fallback.js";
6262import {
6363buildAllowedModelSet,
6464buildConfiguredModelCatalog,
65+isModelKeyAllowedBySet,
6566modelKey,
6667normalizeModelRef,
6768parseModelRef,
@@ -778,7 +779,7 @@ async function agentCommandInternal(
778779if (overrideModel) {
779780const normalizedOverride = normalizeModelRef(overrideProvider, overrideModel);
780781const key = modelKey(normalizedOverride.provider, normalizedOverride.model);
781-if (!allowAnyModel && !allowedModelKeys.has(key)) {
782+if (!allowAnyModel && !isModelKeyAllowedBySet(allowedModelKeys, key)) {
782783const { updated } = applyModelOverrideToSessionEntry({
783784 entry,
784785selection: { provider: defaultProvider, model: defaultModel, isDefault: true },
@@ -801,7 +802,7 @@ async function agentCommandInternal(
801802const candidateProvider = storedProviderOverride || defaultProvider;
802803const normalizedStored = normalizeModelRef(candidateProvider, storedModelOverride);
803804const key = modelKey(normalizedStored.provider, normalizedStored.model);
804-if (allowAnyModel || allowedModelKeys.has(key)) {
805+if (allowAnyModel || isModelKeyAllowedBySet(allowedModelKeys, key)) {
805806provider = normalizedStored.provider;
806807model = normalizedStored.model;
807808}
@@ -819,7 +820,7 @@ async function agentCommandInternal(
819820throw new Error("Invalid model override.");
820821}
821822const explicitKey = modelKey(explicitRef.provider, explicitRef.model);
822-if (!allowAnyModel && !allowedModelKeys.has(explicitKey)) {
823+if (!allowAnyModel && !isModelKeyAllowedBySet(allowedModelKeys, explicitKey)) {
823824throw new Error(
824825`Model override "${sanitizeForLog(explicitRef.provider)}/${sanitizeForLog(explicitRef.model)}" is not allowed for agent "${sessionAgentId}".`,
825826);
@@ -1125,7 +1126,7 @@ async function agentCommandInternal(
11251126}
11261127const switchRef = normalizeModelRef(err.provider, err.model);
11271128const switchKey = modelKey(switchRef.provider, switchRef.model);
1128-if (!allowAnyModel && !allowedModelKeys.has(switchKey)) {
1129+if (!allowAnyModel && !isModelKeyAllowedBySet(allowedModelKeys, switchKey)) {
11291130log.info(
11301131`Live session model switch in subagent run ${runId}: ` +
11311132`rejected ${sanitizeForLog(err.provider)}/${sanitizeForLog(err.model)} (not in allowlist)`,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。