Skip to content

Commit b79b829

Browse files
committed
fix(inference): prefer main agent model updates
Signed-off-by: Deepak Jain <deepujain@gmail.com>
1 parent 9d793bb commit b79b829

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/lib/actions/inference-set.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ describe("patchOpenClawInferenceConfig", () => {
248248
{ id: "main", default: true, model: "inference/nvidia/old-model" },
249249
{
250250
id: "research",
251+
default: true,
251252
model: "inference/nvidia/secondary-model",
252253
workspace: "/sandbox/.openclaw/workspace-research",
253254
agentDir: "/sandbox/.openclaw/agents/research",
@@ -278,6 +279,7 @@ describe("patchOpenClawInferenceConfig", () => {
278279
{ id: "main", default: true, model: "inference/nvidia/new-model" },
279280
{
280281
id: "research",
282+
default: true,
281283
model: "inference/nvidia/secondary-model",
282284
workspace: "/sandbox/.openclaw/workspace-research",
283285
agentDir: "/sandbox/.openclaw/agents/research",

src/lib/actions/inference-set.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,21 @@ function updateAgentPrimary(config: ConfigObject, primaryModelRef: string): void
233233
function updatePrimaryAgentListModel(agents: ConfigObject, primaryModelRef: string): void {
234234
const list = agents.list;
235235
if (!Array.isArray(list)) return;
236+
let defaultAgent: ConfigObject | undefined;
236237
for (const entry of list) {
237238
if (!isConfigObject(entry)) continue;
238-
const isPrimaryAgent = entry.id === "main" || entry.default === true;
239-
if (isPrimaryAgent && typeof entry.model === "string") {
240-
entry.model = primaryModelRef;
239+
if (entry.id === "main") {
240+
if (typeof entry.model === "string") {
241+
entry.model = primaryModelRef;
242+
}
243+
return;
241244
}
245+
if (!defaultAgent && entry.default === true) {
246+
defaultAgent = entry;
247+
}
248+
}
249+
if (defaultAgent && typeof defaultAgent.model === "string") {
250+
defaultAgent.model = primaryModelRef;
242251
}
243252
}
244253

0 commit comments

Comments
 (0)