mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:20:42 +00:00
test(config): cover agent context token validation
This commit is contained in:
@@ -95,7 +95,6 @@ export type AgentConfig = {
|
||||
skillsLimits?: Pick<SkillsLimitsConfig, "maxSkillsPromptChars">;
|
||||
/** Optional per-agent overrides for selected context/token-heavy limits. */
|
||||
contextLimits?: AgentContextLimitsConfig;
|
||||
/** Optional per-agent override for the model's total context window (in tokens). */
|
||||
contextTokens?: number;
|
||||
/** Optional per-agent heartbeat overrides. */
|
||||
heartbeat?: AgentDefaultsConfig["heartbeat"];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { validateConfigObject } from "./validation.js";
|
||||
import { AgentDefaultsSchema } from "./zod-schema.agent-defaults.js";
|
||||
import { AgentEntrySchema } from "./zod-schema.agent-runtime.js";
|
||||
|
||||
@@ -117,12 +118,26 @@ describe("agent defaults schema", () => {
|
||||
expect(() => AgentEntrySchema.parse({ id: "ops", heartbeat: { timeoutSeconds: 0 } })).toThrow();
|
||||
});
|
||||
|
||||
it("accepts per-agent contextTokens override", () => {
|
||||
const agent = AgentEntrySchema.parse({
|
||||
id: "ops",
|
||||
contextTokens: 1_048_576,
|
||||
it("preserves per-agent contextTokens through config validation", () => {
|
||||
const result = validateConfigObject({
|
||||
agents: {
|
||||
list: [
|
||||
{
|
||||
id: "ops",
|
||||
contextTokens: 1_048_576,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
ok: true,
|
||||
config: {
|
||||
agents: {
|
||||
list: [{ contextTokens: 1_048_576 }],
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(agent.contextTokens).toBe(1_048_576);
|
||||
});
|
||||
|
||||
it("rejects non-positive contextTokens on agent entries and defaults", () => {
|
||||
|
||||
Reference in New Issue
Block a user