mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 04:15:48 -06:00
25d4807b38
* feat(anthropic): add server-side compaction replay * docs(anthropic): document server compaction * test(anthropic): harden compaction live probe Fix the live fixture baseUrl (the SDK appends /v1 itself), fail fast on errored turns instead of silently looping, assert request-side injection before capture, and log per-turn stream outcomes for live debugging. * test(anthropic): keep live settings type module-local * refactor(agents): split transcript replay sanitizers * test(anthropic): move compaction live probe into plugin tree * refactor(anthropic): consolidate compaction replay duplication * test(anthropic): align compaction threshold host coverage * test(anthropic): fabricate checkpoints via capture tracker Keeps captureAnthropicCompaction module-local; knip flags exports whose only consumers are tests.
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
ANTHROPIC_COMPACTION_LIVE_ENV,
|
|
buildAnthropicCompactionContextChunk,
|
|
resolveAnthropicCompactionLiveSettings,
|
|
} from "./server-compaction-live.test-support.js";
|
|
|
|
describe("Anthropic compaction live settings", () => {
|
|
it("stays disabled unless the dedicated spend gate is enabled", () => {
|
|
expect(resolveAnthropicCompactionLiveSettings({}, true)).toEqual({ enabled: false });
|
|
});
|
|
|
|
it("requires the global live gate and an API key", () => {
|
|
expect(() =>
|
|
resolveAnthropicCompactionLiveSettings({ [ANTHROPIC_COMPACTION_LIVE_ENV]: "1" }, false),
|
|
).toThrow("also requires OPENCLAW_LIVE_TEST=1");
|
|
expect(() =>
|
|
resolveAnthropicCompactionLiveSettings({ [ANTHROPIC_COMPACTION_LIVE_ENV]: "1" }, true),
|
|
).toThrow("requires ANTHROPIC_API_KEY");
|
|
});
|
|
|
|
it("builds the bounded reduced live profile", () => {
|
|
const settings = resolveAnthropicCompactionLiveSettings(
|
|
{
|
|
[ANTHROPIC_COMPACTION_LIVE_ENV]: "1",
|
|
ANTHROPIC_API_KEY: "test-key",
|
|
},
|
|
true,
|
|
);
|
|
|
|
expect(settings).toMatchObject({
|
|
enabled: true,
|
|
modelId: "claude-sonnet-4-6",
|
|
compactThreshold: 50_000,
|
|
maxDenseTurns: 3,
|
|
});
|
|
expect(buildAnthropicCompactionContextChunk(500)).toHaveLength(500);
|
|
});
|
|
});
|