mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:21:26 +00:00
fix: cap context window resolution (#6187) (thanks @iamEvanYT)
This commit is contained in:
@@ -77,7 +77,7 @@ describe("context-window-guard", () => {
|
||||
cfg,
|
||||
provider: "openrouter",
|
||||
modelId: "tiny",
|
||||
modelContextWindow: undefined,
|
||||
modelContextWindow: 64_000,
|
||||
defaultTokens: 200_000,
|
||||
});
|
||||
const guard = evaluateContextWindowGuard({ info });
|
||||
@@ -85,7 +85,7 @@ describe("context-window-guard", () => {
|
||||
expect(guard.shouldBlock).toBe(true);
|
||||
});
|
||||
|
||||
it("falls back to agents.defaults.contextTokens", () => {
|
||||
it("caps with agents.defaults.contextTokens", () => {
|
||||
const cfg = {
|
||||
agents: { defaults: { contextTokens: 20_000 } },
|
||||
} satisfies OpenClawConfig;
|
||||
@@ -93,7 +93,7 @@ describe("context-window-guard", () => {
|
||||
cfg,
|
||||
provider: "anthropic",
|
||||
modelId: "whatever",
|
||||
modelContextWindow: undefined,
|
||||
modelContextWindow: 200_000,
|
||||
defaultTokens: 200_000,
|
||||
});
|
||||
const guard = evaluateContextWindowGuard({ info });
|
||||
@@ -102,6 +102,21 @@ describe("context-window-guard", () => {
|
||||
expect(guard.shouldBlock).toBe(false);
|
||||
});
|
||||
|
||||
it("does not override when cap exceeds base window", () => {
|
||||
const cfg = {
|
||||
agents: { defaults: { contextTokens: 128_000 } },
|
||||
} satisfies OpenClawConfig;
|
||||
const info = resolveContextWindowInfo({
|
||||
cfg,
|
||||
provider: "anthropic",
|
||||
modelId: "whatever",
|
||||
modelContextWindow: 64_000,
|
||||
defaultTokens: 200_000,
|
||||
});
|
||||
expect(info.source).toBe("model");
|
||||
expect(info.tokens).toBe(64_000);
|
||||
});
|
||||
|
||||
it("uses default when nothing else is available", () => {
|
||||
const info = resolveContextWindowInfo({
|
||||
cfg: undefined,
|
||||
|
||||
Reference in New Issue
Block a user