fix(usage): price Claude fast-mode requests at the fast rate (#13599)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
86054b6df2
commit
e3e7cc3fc2
8 files changed
+129
-38
No files matched your search
@@ -24,6 +24,7 @@ function record(overrides: Partial<UsageRecord> = {}): UsageRecord {
|
||||
reasoningTokens: 0,
|
||||
},
|
||||
reportedCostUsd: null,
|
||||
fast: false,
|
||||
dedupeKey: "msg_1:",
|
||||
...overrides,
|
||||
};
|
||||
@@ -57,7 +58,11 @@ function cacheWith(entries: readonly [string, number, readonly UsageRecord[]][])
|
||||
describe("scan cache round trip", () => {
|
||||
it("restores records unchanged", () => {
|
||||
const original = cacheWith([
|
||||
["/a.jsonl", 100, [record(), record({ dedupeKey: "msg_2:", model: "claude-opus-5" })]],
|
||||
[
|
||||
"/a.jsonl",
|
||||
100,
|
||||
[record(), record({ dedupeKey: "msg_2:", model: "claude-opus-5-5", fast: true })],
|
||||
],
|
||||
["/b.jsonl", 200, [record({ sessionId: "session-b", reportedCostUsd: 1.5 })]],
|
||||
]);
|
||||
original.set("/grok.jsonl", {
|
||||
@@ -123,9 +128,20 @@ describe("scan cache round trip", () => {
|
||||
expect(decodeScanCache(JSON.parse(JSON.stringify(poisoned))).has("/a.jsonl")).toBe(false);
|
||||
});
|
||||
|
||||
it("drops an entry whose fast flag is not 0 or 1", () => {
|
||||
const encoded = encodeScanCache(cacheWith([["/a.jsonl", 100, [record({ fast: true })]]]));
|
||||
const row = encoded.files["/a.jsonl"]!.r[0]!;
|
||||
const poisoned = {
|
||||
...encoded,
|
||||
files: { "/a.jsonl": { ...encoded.files["/a.jsonl"]!, r: [[...row.slice(0, 10), true]] } },
|
||||
};
|
||||
|
||||
expect(decodeScanCache(JSON.parse(JSON.stringify(poisoned))).has("/a.jsonl")).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a document from the previous cache version", () => {
|
||||
const encoded = encodeScanCache(cacheWith([["/a.jsonl", 100, [record()]]]));
|
||||
const previous = { ...encoded, version: 2 };
|
||||
const previous = { ...encoded, version: 3 };
|
||||
|
||||
expect(decodeScanCache(JSON.parse(JSON.stringify(previous))).size).toBe(0);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user