mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 23:38:27 +00:00
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: 0f272b1027
Co-authored-by: bianbiandashen <16240681+bianbiandashen@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
@@ -2,12 +2,12 @@ import { buildModelAliasIndex, resolveModelRefFromString } from "../../agents/mo
|
||||
import type { OpenClawConfig } from "../../config/config.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { logConfigUpdated } from "../../config/logging.js";
|
||||
import { resolveAgentModelFallbackValues, toAgentModelListLike } from "../../config/model-input.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import {
|
||||
DEFAULT_PROVIDER,
|
||||
ensureFlagCompatibility,
|
||||
mergePrimaryFallbackConfig,
|
||||
type PrimaryFallbackConfig,
|
||||
modelKey,
|
||||
resolveModelTarget,
|
||||
resolveModelKeysFromEntries,
|
||||
@@ -17,17 +17,14 @@ import {
|
||||
type DefaultsFallbackKey = "model" | "imageModel";
|
||||
|
||||
function getFallbacks(cfg: OpenClawConfig, key: DefaultsFallbackKey): string[] {
|
||||
const entry = cfg.agents?.defaults?.[key] as unknown as PrimaryFallbackConfig | undefined;
|
||||
return entry?.fallbacks ?? [];
|
||||
return resolveAgentModelFallbackValues(cfg.agents?.defaults?.[key]);
|
||||
}
|
||||
|
||||
function patchDefaultsFallbacks(
|
||||
cfg: OpenClawConfig,
|
||||
params: { key: DefaultsFallbackKey; fallbacks: string[]; models?: Record<string, unknown> },
|
||||
): OpenClawConfig {
|
||||
const existing = cfg.agents?.defaults?.[params.key] as unknown as
|
||||
| PrimaryFallbackConfig
|
||||
| undefined;
|
||||
const existing = toAgentModelListLike(cfg.agents?.defaults?.[params.key]);
|
||||
return {
|
||||
...cfg,
|
||||
agents: {
|
||||
|
||||
Reference in New Issue
Block a user