mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 19:54:57 +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:
@@ -12,6 +12,8 @@ import {
|
||||
readConfigFileSnapshot,
|
||||
writeConfigFile,
|
||||
} from "../../config/config.js";
|
||||
import { toAgentModelListLike } from "../../config/model-input.js";
|
||||
import type { AgentModelConfig } from "../../config/types.agents-shared.js";
|
||||
import { normalizeAgentId } from "../../routing/session-key.js";
|
||||
|
||||
export const ensureFlagCompatibility = (opts: { json?: boolean; plain?: boolean }) => {
|
||||
@@ -164,7 +166,8 @@ export function mergePrimaryFallbackConfig(
|
||||
existing: PrimaryFallbackConfig | undefined,
|
||||
patch: { primary?: string; fallbacks?: string[] },
|
||||
): PrimaryFallbackConfig {
|
||||
const next: PrimaryFallbackConfig = { ...existing };
|
||||
const base = existing && typeof existing === "object" ? existing : undefined;
|
||||
const next: PrimaryFallbackConfig = { ...base };
|
||||
if (patch.primary !== undefined) {
|
||||
next.primary = patch.primary;
|
||||
}
|
||||
@@ -188,9 +191,9 @@ export function applyDefaultModelPrimaryUpdate(params: {
|
||||
}
|
||||
|
||||
const defaults = params.cfg.agents?.defaults ?? {};
|
||||
const existing = (defaults as Record<string, unknown>)[params.field] as
|
||||
| PrimaryFallbackConfig
|
||||
| undefined;
|
||||
const existing = toAgentModelListLike(
|
||||
(defaults as Record<string, unknown>)[params.field] as AgentModelConfig | undefined,
|
||||
);
|
||||
|
||||
return {
|
||||
...params.cfg,
|
||||
|
||||
Reference in New Issue
Block a user