chore(vendor): import pi 1.3.0

Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
alexion committed 2026-10-15 17:58:48 -04:00
1 parent 719370c8f7
commit 6081e3e325
1743 files changed
+205459 -131704

No files matched your search

+21
View File
@@ -324,6 +324,27 @@ describe("faux provider", () => {
expect(second.usage.input + second.usage.cacheRead).toBeGreaterThan(second.usage.input);
});
it("counts cached characters up to the first difference in the joined prompt", async () => {
const registration = registerFauxProvider();
registrations.push(registration);
registration.setResponses([fauxAssistantMessage("a"), fauxAssistantMessage("b"), fauxAssistantMessage("c")]);
const options = { sessionId: "session-1", cacheRetention: "short" } as const;
const user = (content: string) => ({ role: "user" as const, content, timestamp: 1 });
// Prompt texts: "user:hello world" (16 characters), then 16 + 2 + "user:next" (9) = 27.
await complete(registration.getModel(), { messages: [user("hello world")] }, options);
const extended = await complete(
registration.getModel(),
{ messages: [user("hello world"), user("next")] },
options,
);
expect(extended.usage).toMatchObject({ input: 3, cacheRead: 4, cacheWrite: 3 });
// The first message now differs after "user:hello w" (12 characters): "user:hello wide" + 2 + 9 = 26.
const edited = await complete(registration.getModel(), { messages: [user("hello wide"), user("next")] }, options);
expect(edited.usage).toMatchObject({ input: 4, cacheRead: 3, cacheWrite: 4 });
});
it("does not simulate caching when cacheRetention is none", async () => {
const registration = registerFauxProvider();
registrations.push(registration);