fix(config): accept agents.list[].params in schema validation

The runtime type definition (types.agents.ts) includes an optional
params field on agent list entries for per-agent model overrides like
cacheRetention and temperature. However, the zod validation schema
(AgentEntrySchema) was missing this field, causing 'openclaw config
validate' to reject documented configs.

Fixes #41160
This commit is contained in:
xaeon2026 2026-03-09 15:16:41 -04:00
parent 7b88249c9e
commit c9e6535b01
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import { AgentEntrySchema } from "./zod-schema.agent-runtime.js";
describe("AgentEntrySchema params field", () => {
it("accepts agents.list[].params with cacheRetention", () => {
const result = AgentEntrySchema.safeParse({
id: "main",
params: { cacheRetention: "none" },
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.params).toEqual({ cacheRetention: "none" });
}
});
it("accepts agents.list[].params with arbitrary model overrides", () => {
const result = AgentEntrySchema.safeParse({
id: "main",
params: { temperature: 0.7, maxTokens: 4096 },
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.params).toEqual({ temperature: 0.7, maxTokens: 4096 });
}
});
it("accepts agents.list[] without params (optional)", () => {
const result = AgentEntrySchema.safeParse({
id: "main",
});
expect(result.success).toBe(true);
if (result.success) {
expect(result.data.params).toBeUndefined();
}
});
});

View File

@ -726,6 +726,8 @@ export const AgentEntrySchema = z
heartbeat: HeartbeatSchema,
identity: IdentitySchema,
groupChat: GroupChatSchema,
/** Per-agent model params (e.g. cacheRetention, temperature). Merged on top of agents.defaults.models[...].params. */
params: z.record(z.string(), z.unknown()).optional(),
subagents: z
.object({
allowAgents: z.array(z.string()).optional(),