agents: lower context window hard minimum from 16k to 1024

Allow small-context models like ollama/qwen2.5:7b-2k (2048 tokens) to
run without being blocked by the guard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarun Sukhani
2026-02-11 15:03:29 +08:00
parent 0f6a15deca
commit 0149f39e72
2 changed files with 6 additions and 6 deletions

View File

@@ -8,17 +8,17 @@ import {
} from "./context-window-guard.js";
describe("context-window-guard", () => {
it("blocks below 16k (model metadata)", () => {
it("blocks below 1024 (model metadata)", () => {
const info = resolveContextWindowInfo({
cfg: undefined,
provider: "openrouter",
modelId: "tiny",
modelContextWindow: 8000,
modelContextWindow: 512,
defaultTokens: 200_000,
});
const guard = evaluateContextWindowGuard({ info });
expect(guard.source).toBe("model");
expect(guard.tokens).toBe(8000);
expect(guard.tokens).toBe(512);
expect(guard.shouldWarn).toBe(true);
expect(guard.shouldBlock).toBe(true);
});
@@ -64,7 +64,7 @@ describe("context-window-guard", () => {
reasoning: false,
input: ["text"],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 12_000,
contextWindow: 512,
maxTokens: 256,
},
],
@@ -143,7 +143,7 @@ describe("context-window-guard", () => {
});
it("exports thresholds as expected", () => {
expect(CONTEXT_WINDOW_HARD_MIN_TOKENS).toBe(16_000);
expect(CONTEXT_WINDOW_HARD_MIN_TOKENS).toBe(1_024);
expect(CONTEXT_WINDOW_WARN_BELOW_TOKENS).toBe(32_000);
});
});

View File

@@ -1,6 +1,6 @@
import type { OpenClawConfig } from "../config/config.js";
export const CONTEXT_WINDOW_HARD_MIN_TOKENS = 16_000;
export const CONTEXT_WINDOW_HARD_MIN_TOKENS = 1_024;
export const CONTEXT_WINDOW_WARN_BELOW_TOKENS = 32_000;
export type ContextWindowSource = "model" | "modelsConfig" | "agentContextTokens" | "default";