Skip to content

Commit d2c0d3a

Browse files
committed
test(agents): skip anthropic billing drift in live tool checks
1 parent e99ab38 commit d2c0d3a

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/agents/anthropic-transport-stream.live.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { describe, expect, it } from "vitest";
99
import { streamAnthropic } from "../llm/providers/anthropic.js";
1010
import { createAnthropicMessagesTransportStreamFn } from "./anthropic-transport-stream.js";
1111
import { isLiveTestEnabled } from "./live-test-helpers.js";
12+
import { isLiveBillingDrift } from "./live-test-provider-drift.js";
1213

1314
const LIVE = isLiveTestEnabled(["ANTHROPIC_TRANSPORT_LIVE_TEST"]);
1415
const describeLive = LIVE ? describe : describe.skip;
@@ -65,6 +66,17 @@ async function readRequestBody(request: http.IncomingMessage): Promise<string> {
6566
return Buffer.concat(chunks).toString("utf8");
6667
}
6768

69+
function skipAnthropicBillingDrift(
70+
label: string,
71+
result: { stopReason: string; errorMessage?: string },
72+
): boolean {
73+
if (result.stopReason !== "error" || !isLiveBillingDrift(result.errorMessage ?? "")) {
74+
return false;
75+
}
76+
console.warn(`[anthropic:live] skip ${label}: billing drift`);
77+
return true;
78+
}
79+
6880
describeLive("anthropic transport stream live", () => {
6981
it("cancels an in-flight SSE body read over a real HTTP stream", async () => {
7082
const controller = new AbortController();
@@ -198,6 +210,9 @@ describeProviderLive("anthropic transport stream provider live", () => {
198210
);
199211

200212
const result = await stream.result();
213+
if (skipAnthropicBillingDrift("forced tool projection", result)) {
214+
return;
215+
}
201216
const toolCall = result.content.find(
202217
(block) => block.type === "toolCall" && block.name === "healthy_probe",
203218
);
@@ -257,6 +272,9 @@ describeProviderLive("anthropic transport stream provider live", () => {
257272
);
258273

259274
const result = await stream.result();
275+
if (skipAnthropicBillingDrift("SDK forced tool projection", result)) {
276+
return;
277+
}
260278
const toolCall = result.content.find(
261279
(block) => block.type === "toolCall" && block.name === "healthy_probe",
262280
);

0 commit comments

Comments
 (0)