Revert "fix(ai): own Anthropic SSE parsing to avoid SDK JSON.parse hard-failures"

This reverts commit 4b926a30a2.
This commit is contained in:
Mario Zechner
2026-04-21 23:19:25 +02:00
parent 81de426f96
commit fc9220d2de
12 changed files with 124 additions and 430 deletions

View File

@@ -27,7 +27,7 @@ describe("Cache Retention (PI_CACHE_RETENTION)", () => {
it.skipIf(!process.env.ANTHROPIC_API_KEY)(
"should use default cache TTL (no ttl field) when PI_CACHE_RETENTION is not set",
async () => {
const model = getModel("anthropic", "claude-haiku-4-5");
const model = getModel("anthropic", "claude-3-5-haiku-20241022");
let capturedPayload: any = null;
const s = stream(model, context, {
@@ -50,7 +50,7 @@ describe("Cache Retention (PI_CACHE_RETENTION)", () => {
it.skipIf(!process.env.ANTHROPIC_API_KEY)("should use 1h cache TTL when PI_CACHE_RETENTION=long", async () => {
process.env.PI_CACHE_RETENTION = "long";
const model = getModel("anthropic", "claude-haiku-4-5");
const model = getModel("anthropic", "claude-3-5-haiku-20241022");
let capturedPayload: any = null;
const s = stream(model, context, {
@@ -74,7 +74,7 @@ describe("Cache Retention (PI_CACHE_RETENTION)", () => {
process.env.PI_CACHE_RETENTION = "long";
// Create a model with a different baseUrl (simulating a proxy)
const baseModel = getModel("anthropic", "claude-haiku-4-5");
const baseModel = getModel("anthropic", "claude-3-5-haiku-20241022");
const proxyModel = {
...baseModel,
baseUrl: "https://my-proxy.example.com/v1",
@@ -114,7 +114,7 @@ describe("Cache Retention (PI_CACHE_RETENTION)", () => {
});
it("should omit cache_control when cacheRetention is none", async () => {
const baseModel = getModel("anthropic", "claude-haiku-4-5");
const baseModel = getModel("anthropic", "claude-3-5-haiku-20241022");
let capturedPayload: any = null;
const { streamAnthropic } = await import("../src/providers/anthropic.js");
@@ -140,7 +140,7 @@ describe("Cache Retention (PI_CACHE_RETENTION)", () => {
});
it("should add cache_control to string user messages", async () => {
const baseModel = getModel("anthropic", "claude-haiku-4-5");
const baseModel = getModel("anthropic", "claude-3-5-haiku-20241022");
let capturedPayload: any = null;
const { streamAnthropic } = await import("../src/providers/anthropic.js");
@@ -168,7 +168,7 @@ describe("Cache Retention (PI_CACHE_RETENTION)", () => {
});
it("should set 1h cache TTL when cacheRetention is long", async () => {
const baseModel = getModel("anthropic", "claude-haiku-4-5");
const baseModel = getModel("anthropic", "claude-3-5-haiku-20241022");
let capturedPayload: any = null;
const { streamAnthropic } = await import("../src/providers/anthropic.js");