@@ -9,6 +9,7 @@ import { describe, expect, it } from "vitest";
99import { streamAnthropic } from "../llm/providers/anthropic.js" ;
1010import { createAnthropicMessagesTransportStreamFn } from "./anthropic-transport-stream.js" ;
1111import { isLiveTestEnabled } from "./live-test-helpers.js" ;
12+ import { isLiveBillingDrift } from "./live-test-provider-drift.js" ;
1213
1314const LIVE = isLiveTestEnabled ( [ "ANTHROPIC_TRANSPORT_LIVE_TEST" ] ) ;
1415const 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+
6880describeLive ( "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