fix(config): allow per-agent contextTokens override in agents.list

This commit is contained in:
statxc
2026-04-24 22:13:40 +02:00
committed by Ayaan Zaidi
parent 391289564c
commit ed03d91ae0
6 changed files with 26 additions and 2 deletions

View File

@@ -224,6 +224,7 @@ Docs: https://docs.openclaw.ai
- WhatsApp: transcribe accepted voice notes before agent dispatch while keeping spoken transcripts out of command authorization. (#64120) Thanks @rogerdigital.
- Plugins/CLI: expose channel plugin CLI descriptors during discovery-mode plugin loads so snapshot registries keep channel commands visible without activating full runtimes. (#71309) Thanks @gumadeiras.
- WhatsApp: deliver media generated by tool-result replies while still suppressing text-only tool chatter. (#60968) Thanks @adaclaw.
- Config/agents: accept `agents.list[].contextTokens` in strict config validation so per-agent overrides survive hot reload, letting `/status` reflect the configured model window instead of the 200k fallback. Fixes #70692. (#71247) Thanks @statxc.
## 2026.4.23

View File

@@ -1,4 +1,4 @@
71ef32b7723f64d4a84ac43bb6d41ff21e0d77a099b42e026d8b0d3d5301f917 config-baseline.json
cfab1910132ed23777005e0c650a13f44626b0450963f733e9de56a13323ae2b config-baseline.core.json
5c7709e1686f6ad90beaa8e34ba45e6445e34c48d598407bd837361b58c365ab config-baseline.json
98c83ce8af9ec4703726d7d673add95279be008a801b1d298982cbd9c1785747 config-baseline.core.json
22d7cd6d8279146b2d79c9531a55b80b52a2c99c81338c508104729154fdd02d config-baseline.channel.json
86f615b7d267b03888af0af7ccb3f8232a6b636f8a741d522ff425e46729ba81 config-baseline.plugin.json

View File

@@ -6432,6 +6432,11 @@ export const GENERATED_BASE_CONFIG_SCHEMA: BaseConfigSchemaResponse = {
description:
"Optional per-agent overrides for the focused context budget knobs. Omitted fields inherit agents.defaults.contextLimits.",
},
contextTokens: {
type: "integer",
exclusiveMinimum: 0,
maximum: 9007199254740991,
},
heartbeat: {
type: "object",
properties: {

View File

@@ -95,6 +95,8 @@ 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"];
identity?: IdentityConfig;

View File

@@ -116,4 +116,19 @@ describe("agent defaults schema", () => {
expect(() => AgentDefaultsSchema.parse({ heartbeat: { timeoutSeconds: 0 } })).toThrow();
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,
});
expect(agent.contextTokens).toBe(1_048_576);
});
it("rejects non-positive contextTokens on agent entries and defaults", () => {
expect(() => AgentEntrySchema.parse({ id: "ops", contextTokens: 0 })).toThrow();
expect(() => AgentEntrySchema.parse({ id: "ops", contextTokens: -1 })).toThrow();
expect(() => AgentEntrySchema.parse({ id: "ops", contextTokens: 1.5 })).toThrow();
expect(() => AgentDefaultsSchema.parse({ contextTokens: 0 })).toThrow();
});
});

View File

@@ -829,6 +829,7 @@ export const AgentEntrySchema = z
humanDelay: HumanDelaySchema.optional(),
skillsLimits: AgentSkillsLimitsSchema,
contextLimits: AgentContextLimitsSchema,
contextTokens: z.number().int().positive().optional(),
heartbeat: HeartbeatSchema,
identity: IdentitySchema,
groupChat: GroupChatSchema,