mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-13 10:11:20 +00:00
* feat(agents): add prompt cache break diagnostics * test(agents): wire cache trace into live cache suite * fix(agents): always record cache trace result stage * feat(status): show cache reuse in verbose output * fix(agents): ignore missing prompt cache usage * chore(changelog): note prompt cache diagnostics * fix(agents): harden prompt cache diagnostics
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatPromptCacheCompact, formatTokensCompact } from "./status.format.js";
|
|
|
|
describe("status cache formatting", () => {
|
|
it("formats explicit cache details for verbose status output", () => {
|
|
expect(
|
|
formatPromptCacheCompact({
|
|
inputTokens: 2_000,
|
|
cacheRead: 2_000,
|
|
cacheWrite: 1_000,
|
|
totalTokens: 5_000,
|
|
}),
|
|
).toBe("40% hit · read 2.0k · write 1.0k");
|
|
});
|
|
|
|
it("shows cache writes even before there is a cache hit", () => {
|
|
expect(
|
|
formatPromptCacheCompact({
|
|
inputTokens: 2_000,
|
|
cacheRead: 0,
|
|
cacheWrite: 1_000,
|
|
totalTokens: 3_000,
|
|
}),
|
|
).toBe("0% hit · write 1.0k");
|
|
});
|
|
|
|
it("keeps the compact token suffix aligned with prompt-side cache math", () => {
|
|
expect(
|
|
formatTokensCompact({
|
|
inputTokens: 500,
|
|
cacheRead: 2_000,
|
|
cacheWrite: 500,
|
|
totalTokens: 5_000,
|
|
contextTokens: 10_000,
|
|
percentUsed: 50,
|
|
}),
|
|
).toBe("5.0k/10k (50%) · 🗄️ 67% cached");
|
|
});
|
|
});
|