Files
Moltbot/src/config/model-input.ts
边黎安 a4c373935f fix(agents): fall back to agents.defaults.model when agent has no model config (#24210)
Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 0f272b102763736001a82cfda23f35ff2ee9cac8
Co-authored-by: bianbiandashen <16240681+bianbiandashen@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-02-23 03:18:55 -05:00

37 lines
1011 B
TypeScript

import type { AgentModelConfig } from "./types.agents-shared.js";
type AgentModelListLike = {
primary?: string;
fallbacks?: string[];
};
export function resolveAgentModelPrimaryValue(model?: AgentModelConfig): string | undefined {
if (typeof model === "string") {
const trimmed = model.trim();
return trimmed || undefined;
}
if (!model || typeof model !== "object") {
return undefined;
}
const primary = model.primary?.trim();
return primary || undefined;
}
export function resolveAgentModelFallbackValues(model?: AgentModelConfig): string[] {
if (!model || typeof model !== "object") {
return [];
}
return Array.isArray(model.fallbacks) ? model.fallbacks : [];
}
export function toAgentModelListLike(model?: AgentModelConfig): AgentModelListLike | undefined {
if (typeof model === "string") {
const primary = model.trim();
return primary ? { primary } : undefined;
}
if (!model || typeof model !== "object") {
return undefined;
}
return model;
}