diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/build.gradle b/braintrust-sdk/instrumentation/anthropic_2_2_0/build.gradle
index 8fedd855..4bfbce07 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/build.gradle
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/build.gradle
@@ -5,9 +5,17 @@ muzzle {
pass {
group = 'com.anthropic'
module = 'anthropic-java'
- // 3.x is a breaking major (e.g. HttpRequest.body() now returns Optional); not yet supported
+ // Upper-bounded below 3.0.0: 3.x is a breaking major (HttpRequest.body() now returns
+ // Optional) and the anthropic_3_0_0 module takes over.
versions = '[2.2.0,3.0.0)'
}
+ // Assert the classLoaderMatcher rejects 3.0.0+ so the two anthropic modules never both
+ // instrument the same client builder.
+ fail {
+ group = 'com.anthropic'
+ module = 'anthropic-java'
+ pinVersions '3.0.0'
+ }
}
dependencies {
@@ -30,7 +38,8 @@ dependencies {
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testImplementation "net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}"
testRuntimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"
- testImplementation 'com.anthropic:anthropic-java:2.2.0'
+ // Exercise later 2.x convenience APIs while retaining the 2.2.0 compilation baseline.
+ testImplementation 'com.anthropic:anthropic-java:2.75.0'
}
test {
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/BraintrustAnthropic.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/BraintrustAnthropic.java
index 88e9fac8..64e928a4 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/BraintrustAnthropic.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/BraintrustAnthropic.java
@@ -1,14 +1,155 @@
package dev.braintrust.instrumentation.anthropic;
import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.AnthropicClientAsync;
import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Tracer;
+import java.lang.reflect.Method;
+import javax.annotation.Nullable;
+import lombok.extern.slf4j.Slf4j;
-/** Braintrust Anthropic client instrumentation. */
+/**
+ * Braintrust Anthropic client instrumentation.
+ *
+ *
Dispatches to the module matching the anthropic-java version of each client: {@code
+ * v3_0_0.BraintrustAnthropic} for 3.0.0 and up, {@code v2_2_0.BraintrustAnthropic} otherwise.
+ */
+@Slf4j
public final class BraintrustAnthropic {
+ /**
+ * Sentinel class that first appeared in anthropic-java 3.0.0. The {@code
+ * AnthropicInstrumentationModule.classLoaderMatcher()}s key on the same class, so the manual
+ * path picks the same module the agent would.
+ */
+ private static final String V3_SENTINEL = "com.anthropic.models.messages.AssistantMessageParam";
+
+ private static final String V3_0_0_WRAPPER =
+ "dev.braintrust.instrumentation.anthropic.v3_0_0.BraintrustAnthropic";
+
+ /**
+ * Whether the anthropic-java that defined a client class is 3.0.0+. Probed on the client's own
+ * classloader (not this class's), so it is correct per client even when several anthropic-java
+ * versions are loaded side by side.
+ */
+ private static final ClassValue IS_V3 =
+ new ClassValue<>() {
+ @Override
+ protected Boolean computeValue(Class> clientClass) {
+ try {
+ Class.forName(V3_SENTINEL, false, clientClass.getClassLoader());
+ return true;
+ } catch (ClassNotFoundException | LinkageError e) {
+ return false;
+ }
+ }
+ };
+
/** Instrument Anthropic client with Braintrust traces. */
public static AnthropicClient wrap(OpenTelemetry openTelemetry, AnthropicClient client) {
+ if (isV3(client)) {
+ return forwardToV3(V3.WRAP_OTEL_SYNC, openTelemetry, client);
+ }
return dev.braintrust.instrumentation.anthropic.v2_2_0.BraintrustAnthropic.wrap(
openTelemetry, client);
}
+
+ /** Instrument an async Anthropic client with Braintrust traces. */
+ public static AnthropicClientAsync wrap(
+ OpenTelemetry openTelemetry, AnthropicClientAsync client) {
+ if (isV3(client)) {
+ return forwardToV3(V3.WRAP_OTEL_ASYNC, openTelemetry, client);
+ }
+ return dev.braintrust.instrumentation.anthropic.v2_2_0.BraintrustAnthropic.wrap(
+ openTelemetry, client);
+ }
+
+ /**
+ * Instruments a client using the given tracer, replacing any tracer it was previously
+ * instrumented with.
+ */
+ public static AnthropicClient wrap(Tracer tracer, AnthropicClient client) {
+ if (isV3(client)) {
+ return forwardToV3(V3.WRAP_TRACER_SYNC, tracer, client);
+ }
+ return dev.braintrust.instrumentation.anthropic.v2_2_0.BraintrustAnthropic.wrap(
+ tracer, client);
+ }
+
+ /** Async counterpart of {@link #wrap(Tracer, AnthropicClient)}. */
+ public static AnthropicClientAsync wrap(Tracer tracer, AnthropicClientAsync client) {
+ if (isV3(client)) {
+ return forwardToV3(V3.WRAP_TRACER_ASYNC, tracer, client);
+ }
+ return dev.braintrust.instrumentation.anthropic.v2_2_0.BraintrustAnthropic.wrap(
+ tracer, client);
+ }
+
+ private static boolean isV3(Object client) {
+ return IS_V3.get(client.getClass());
+ }
+
+ @SuppressWarnings("unchecked")
+ private static C forwardToV3(@Nullable Method wrap, Object tracing, C client) {
+ if (wrap == null) {
+ return client; // already logged when V3 was initialized
+ }
+ try {
+ return (C) wrap.invoke(null, tracing, client);
+ } catch (ReflectiveOperationException | LinkageError e) {
+ log.error(
+ "failed to forward to {}.wrap; client will not be instrumented",
+ V3_0_0_WRAPPER,
+ e);
+ return client;
+ }
+ }
+
+ /**
+ * {@code v3_0_0.BraintrustAnthropic.wrap} overloads, resolved on first use by a 3.x client.
+ * Reflection keeps this module from depending on {@code anthropic_3_0_0}, which would put
+ * anthropic-java 3.x on its compile classpath. A {@code null} method means the v3 module is
+ * unexpectedly missing; v2_2_0 is binary-incompatible with 3.x, so there is no safe fallback.
+ */
+ private static final class V3 {
+ private static final Class> WRAPPER = loadWrapper();
+ static final Method WRAP_OTEL_SYNC = method(OpenTelemetry.class, AnthropicClient.class);
+ static final Method WRAP_OTEL_ASYNC =
+ method(OpenTelemetry.class, AnthropicClientAsync.class);
+ static final Method WRAP_TRACER_SYNC = method(Tracer.class, AnthropicClient.class);
+ static final Method WRAP_TRACER_ASYNC = method(Tracer.class, AnthropicClientAsync.class);
+
+ @Nullable
+ private static Class> loadWrapper() {
+ try {
+ return Class.forName(
+ V3_0_0_WRAPPER, true, BraintrustAnthropic.class.getClassLoader());
+ } catch (ClassNotFoundException | LinkageError e) {
+ log.error(
+ "anthropic-java 3.0.0+ detected but {} is unavailable; clients will not be"
+ + " instrumented",
+ V3_0_0_WRAPPER,
+ e);
+ return null;
+ }
+ }
+
+ @Nullable
+ private static Method method(Class> tracingType, Class> clientType) {
+ if (WRAPPER == null) {
+ return null;
+ }
+ try {
+ return WRAPPER.getMethod("wrap", tracingType, clientType);
+ } catch (NoSuchMethodException | LinkageError e) {
+ log.error(
+ "{}.wrap({}, {}) is unavailable; such clients will not be instrumented",
+ V3_0_0_WRAPPER,
+ tracingType.getSimpleName(),
+ clientType.getSimpleName(),
+ e);
+ return null;
+ }
+ }
+ }
}
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropic.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropic.java
index 32b11383..05a54d3e 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropic.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropic.java
@@ -7,6 +7,7 @@
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.Tracer;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
@@ -87,6 +88,25 @@ private static boolean instrument(Tracer tracer, Object client, boolean replaceT
}
}
+ /** Preserves the source's current tracer when withOptions replaces a service's transport. */
+ static boolean instrumentDerivedService(Object source, Object service) {
+ try {
+ ClientOptions options = getField(source, "clientOptions");
+ // async() can rebuild the SDK retry layer around the traced original transport.
+ HttpClient transport = options.httpClient();
+ if (!(transport instanceof TracingHttpClient)) {
+ transport = getField(options, "originalHttpClient");
+ }
+ if (transport instanceof TracingHttpClient tracing) {
+ return instrument(tracing.tracer(), service, false);
+ }
+ } catch (ReflectiveOperationException | RuntimeException e) {
+ log.error("failed to instrument derived anthropic service", e);
+ }
+ // Without a tracing transport, adding the context proxy would leak its internal header.
+ return false;
+ }
+
private static void instrumentHttpClient(Tracer tracer, Object client, boolean replaceTracer) {
int[] instrumented = {0};
forAllFields(
@@ -111,13 +131,69 @@ private static void instrumentHttpClient(Tracer tracer, Object client, boolean r
}
}
- /** Swaps both HTTP client fields on a {@link ClientOptions} for tracing wrappers. */
+ /**
+ * Swaps both HTTP client fields on a {@link ClientOptions} for tracing wrappers and turns off
+ * the SDK's built-in tracing.
+ */
private static void instrumentClientOptions(
Tracer tracer, ClientOptions clientOptions, boolean replaceTracer) {
+ disableNativeTracing(clientOptions);
+ try {
+ HttpClient original = getField(clientOptions, "originalHttpClient");
+ if (original instanceof TracingHttpClient tracing
+ && !(clientOptions.httpClient() instanceof TracingHttpClient)) {
+ // async()/withOptions() rebuild the SDK transport around the traced original.
+ // Rebuild around its untraced delegate to retain retries without nested LLM spans.
+ var builder = clientOptions.toBuilder();
+ // Avoid the public setter's extra GC-closing wrapper for this shared transport.
+ setPrivateField(builder, "httpClient", tracing.underlying());
+ HttpClient rebuilt = builder.build().httpClient();
+ setPrivateField(
+ clientOptions,
+ "httpClient",
+ new TracingHttpClient(replaceTracer ? tracer : tracing.tracer(), rebuilt));
+ }
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException(e);
+ }
swapHttpClient(tracer, clientOptions, "originalHttpClient", replaceTracer);
swapHttpClient(tracer, clientOptions, "httpClient", replaceTracer);
}
+ /**
+ * anthropic-java 2.72.0+ has built-in OTel tracing, on by default via GlobalOpenTelemetry,
+ * which would emit a duplicate {@code com.anthropic.sdk.java} span around each of ours. The SDK
+ * re-reads {@code ClientOptions.openTelemetry().traces().enabled()} on every API call, so
+ * replacing the field disables it for this client. Reflective because this module compiles
+ * against 2.2.0, which predates that API; a no-op on older versions. Best-effort: on failure we
+ * keep our instrumentation and accept the duplicate spans.
+ */
+ private static void disableNativeTracing(ClientOptions clientOptions) {
+ Method openTelemetryGetter;
+ try {
+ openTelemetryGetter = ClientOptions.class.getMethod("openTelemetry");
+ } catch (NoSuchMethodException e) {
+ return; // anthropic-java < 2.72.0: no built-in tracing
+ }
+ try {
+ Object otel = openTelemetryGetter.invoke(clientOptions);
+ Object traces = otel.getClass().getMethod("traces").invoke(otel);
+ if (!(Boolean) traces.getClass().getMethod("enabled").invoke(traces)) {
+ return;
+ }
+ Object builder = otel.getClass().getMethod("toBuilder").invoke(otel);
+ builder.getClass().getMethod("traces", boolean.class).invoke(builder, false);
+ setPrivateField(
+ clientOptions,
+ "openTelemetry",
+ builder.getClass().getMethod("build").invoke(builder));
+ } catch (ReflectiveOperationException | RuntimeException e) {
+ log.warn(
+ "failed to disable anthropic-java built-in tracing; spans may be duplicated",
+ e);
+ }
+ }
+
private static void swapHttpClient(
Tracer tracer, ClientOptions clientOptions, String fieldName, boolean replaceTracer) {
try {
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ContextCapturingProxy.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ContextCapturingProxy.java
index 48596bcf..cf5c007f 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ContextCapturingProxy.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ContextCapturingProxy.java
@@ -83,6 +83,11 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
default -> "ContextCapturingProxy(" + delegate + ")"; // toString
};
}
+ // Convenience overloads must call back through the proxy once they create Params.
+ // Invoking them on the delegate would bypass context capture before async dispatch.
+ if (method.isDefault()) {
+ return InvocationHandler.invokeDefault(proxy, method, args);
+ }
Object[] invokeArgs = injectContextHeader(args);
Object result;
try {
@@ -96,6 +101,12 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
if (result != null
&& returnType.isInterface()
&& returnType.getName().startsWith("com.anthropic.")) {
+ // withOptions can replace the transport that strips our private context header.
+ // Only keep capturing context if the derived service is instrumented too.
+ if (method.getName().equals("withOptions")
+ && !BraintrustAnthropic.instrumentDerivedService(delegate, result)) {
+ return result;
+ }
return Proxy.newProxyInstance(
returnType.getClassLoader(),
new Class>[] {returnType},
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ResponseReassembler.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ResponseReassembler.java
index 5decf031..1bea3221 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ResponseReassembler.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/ResponseReassembler.java
@@ -1,5 +1,6 @@
package dev.braintrust.instrumentation.anthropic.v2_2_0;
+import com.anthropic.core.JsonValue;
import com.anthropic.helpers.MessageAccumulator;
import com.anthropic.models.messages.RawMessageStreamEvent;
import dev.braintrust.json.BraintrustJsonMapper;
@@ -32,9 +33,14 @@ private ResponseReassembler() {}
*
* {@code timeToFirstTokenNanos} is only populated for a stream, since a non-streaming
* response has no first token to time.
+ *
+ *
{@code error} retains an SSE error payload independently of message completion.
*/
- record Result(@Nullable String body, @Nullable Long timeToFirstTokenNanos) {
- static final Result EMPTY = new Result(null, null);
+ record Result(
+ @Nullable String body,
+ @Nullable Long timeToFirstTokenNanos,
+ @Nullable JsonValue error) {
+ static final Result EMPTY = new Result(null, null, null);
}
/** Detects the wire format and reassembles accordingly. Never throws. */
@@ -50,10 +56,10 @@ static Result reassemble(byte[] bytes, long timeToFirstTokenNanos) {
firstLine != null
&& (firstLine.startsWith("data:") || firstLine.startsWith("event:"));
if (isSse) {
- return new Result(reassembleSse(bytes), timeToFirstTokenNanos);
+ return reassembleSse(bytes, timeToFirstTokenNanos);
}
// Non-streaming: plain Message JSON — pass it whole, no time_to_first_token
- return new Result(new String(bytes, StandardCharsets.UTF_8), null);
+ return new Result(new String(bytes, StandardCharsets.UTF_8), null, null);
} catch (Exception e) {
log.error("Could not reassemble Anthropic response buffer", e);
return Result.EMPTY;
@@ -84,12 +90,11 @@ private static String firstNonEmptyLine(byte[] bytes) {
* data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hi"}}
*
*
- * We only need the {@code data:} lines — the event name is redundant with the {@code type}
- * field inside the JSON. Feed each data payload to {@link MessageAccumulator} and serialize the
- * assembled {@link com.anthropic.models.messages.Message}.
+ * Feed message data payloads to {@link MessageAccumulator} and serialize the assembled {@link
+ * com.anthropic.models.messages.Message}. Error events are returned separately so the tracing
+ * layer can report failures raised by the SDK above the HTTP stream.
*/
- @Nullable
- private static String reassembleSse(byte[] sseBytes) {
+ private static Result reassembleSse(byte[] sseBytes, long timeToFirstTokenNanos) {
try {
var mapper = BraintrustJsonMapper.get();
var reader =
@@ -98,20 +103,39 @@ private static String reassembleSse(byte[] sseBytes) {
new ByteArrayInputStream(sseBytes), StandardCharsets.UTF_8));
var accumulator = MessageAccumulator.create();
String line;
+ String event = null;
while ((line = reader.readLine()) != null) {
+ if (line.isEmpty()) {
+ event = null;
+ continue;
+ }
+ if (line.startsWith("event:")) {
+ event = line.substring("event:".length()).strip();
+ continue;
+ }
if (!line.startsWith("data:")) continue;
String data = line.substring("data:".length()).strip();
if (data.isEmpty()) continue;
try {
- accumulator.accumulate(mapper.readValue(data, RawMessageStreamEvent.class));
+ var payload = mapper.readTree(data);
+ // Preserve errors even when no complete message exists.
+ if ("error".equals(event) || "error".equals(payload.path("type").asText())) {
+ return new Result(
+ null, timeToFirstTokenNanos, JsonValue.fromJsonNode(payload));
+ }
+ accumulator.accumulate(
+ mapper.treeToValue(payload, RawMessageStreamEvent.class));
} catch (Exception ignored) {
// skip unrecognized event types (e.g. ping)
}
}
- return BraintrustJsonMapper.toJson(accumulator.message());
+ return new Result(
+ BraintrustJsonMapper.toJson(accumulator.message()),
+ timeToFirstTokenNanos,
+ null);
} catch (Exception e) {
log.error("Could not parse Anthropic SSE buffer to tag streaming span output", e);
- return null;
+ return new Result(null, timeToFirstTokenNanos, null);
}
}
}
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/TracingHttpClient.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/TracingHttpClient.java
index c04aeafa..19c84655 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/TracingHttpClient.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/TracingHttpClient.java
@@ -15,6 +15,7 @@
import io.opentelemetry.api.trace.Tracer;
import io.opentelemetry.context.Context;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
@@ -25,6 +26,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Consumer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
@@ -51,6 +53,14 @@ TracingHttpClient withTracer(Tracer tracer) {
return this.tracer == tracer ? this : new TracingHttpClient(tracer, underlying);
}
+ Tracer tracer() {
+ return tracer;
+ }
+
+ HttpClient underlying() {
+ return underlying;
+ }
+
/**
* Starts a request span. anthropic-java (and frameworks like Spring AI 2.x) dispatch
* async/streaming requests on executors where the caller's thread-local context is lost — which
@@ -121,31 +131,26 @@ public void close() {
if (!isLlmRequest(extracted.request())) {
return executeHttp(extracted, requestOptions);
}
+ long spanStartNanos = System.nanoTime();
var span = startSpan(InstrumentationSemConv.UNSET_LLM_SPAN_NAME, extracted.callerContext());
try (var ignored = span.makeCurrent()) {
- var bufferedRequest = bufferRequestBody(extracted.request());
-
- String inputJson =
- bufferedRequest.body() != null
- ? readBodyAsString(bufferedRequest.body())
- : null;
-
+ var buffered = bufferRequestBody(extracted.request());
+ var bufferedRequest = buffered.request();
InstrumentationSemConv.tagLLMSpanRequest(
span,
InstrumentationSemConv.PROVIDER_NAME_ANTHROPIC,
bufferedRequest.baseUrl() != null ? bufferedRequest.baseUrl() : "",
bufferedRequest.pathSegments(),
bufferedRequest.method().name(),
- inputJson,
+ buffered.bodyJson(),
null,
headersAsMap(bufferedRequest.headers()));
var response = underlying.execute(bufferedRequest, requestOptions);
- return new TeeingStreamHttpResponse(response, span, tracer);
- } catch (Exception e) {
- InstrumentationSemConv.tagLLMSpanResponse(span, e);
- span.end();
- throw e;
+ return new TeeingStreamHttpResponse(response, span, tracer, spanStartNanos);
+ } catch (Throwable failure) {
+ failSpanQuietly(span, failure);
+ throw failure;
}
}
@@ -156,40 +161,72 @@ public void close() {
if (!isLlmRequest(extracted.request())) {
return executeHttpAsync(extracted, requestOptions);
}
+ long spanStartNanos = System.nanoTime();
var span = startSpan(InstrumentationSemConv.UNSET_LLM_SPAN_NAME, extracted.callerContext());
try {
- var bufferedRequest = bufferRequestBody(extracted.request());
- String inputJson =
- bufferedRequest.body() != null
- ? readBodyAsString(bufferedRequest.body())
- : null;
+ var buffered = bufferRequestBody(extracted.request());
+ var bufferedRequest = buffered.request();
InstrumentationSemConv.tagLLMSpanRequest(
span,
InstrumentationSemConv.PROVIDER_NAME_ANTHROPIC,
bufferedRequest.baseUrl() != null ? bufferedRequest.baseUrl() : "",
bufferedRequest.pathSegments(),
bufferedRequest.method().name(),
- inputJson,
+ buffered.bodyJson(),
null,
headersAsMap(bufferedRequest.headers()));
- return underlying
+ var result = new CompletableFuture();
+ underlying
.executeAsync(bufferedRequest, requestOptions)
- .thenApply(
- response ->
- (HttpResponse)
- new TeeingStreamHttpResponse(response, span, tracer))
.whenComplete(
- (response, t) -> {
- if (t != null) {
- // this means the future itself failed
- InstrumentationSemConv.tagLLMSpanResponse(span, t);
- span.end();
+ // Every path must settle `result`: an exception escaping this
+ // callback would be swallowed by the discarded whenComplete future
+ // and leave the caller waiting forever.
+ (response, error) -> {
+ if (error != null) {
+ failSpanQuietly(span, error);
+ result.completeExceptionally(error);
+ return;
+ }
+ TeeingStreamHttpResponse wrapped;
+ try {
+ wrapped =
+ new TeeingStreamHttpResponse(
+ response, span, tracer, spanStartNanos);
+ } catch (Throwable failure) {
+ failSpanQuietly(span, failure);
+ try {
+ response.close();
+ } catch (Throwable closeFailure) {
+ if (closeFailure != failure) {
+ failure.addSuppressed(closeFailure);
+ }
+ }
+ result.completeExceptionally(failure);
+ return;
+ }
+ if (!result.complete(wrapped)) {
+ wrapped.close();
}
});
- } catch (Exception e) {
- InstrumentationSemConv.tagLLMSpanResponse(span, e);
+ return result;
+ } catch (Throwable failure) {
+ failSpanQuietly(span, failure);
+ throw failure;
+ }
+ }
+
+ /** Ends failed requests, including linkage errors, without masking the original throwable. */
+ private static void failSpanQuietly(Span span, Throwable failure) {
+ try {
+ InstrumentationSemConv.tagLLMSpanResponse(span, failure);
+ } catch (Throwable taggingFailure) {
+ log.error("Could not tag span with request failure", taggingFailure);
+ }
+ try {
span.end();
- throw e;
+ } catch (Throwable endFailure) {
+ log.error("Could not end span", endFailure);
}
}
@@ -254,53 +291,75 @@ private CompletableFuture executeHttpAsync(
// Request buffering — identical pattern to OpenAI TracingHttpClient
// -------------------------------------------------------------------------
- private static HttpRequest bufferRequestBody(HttpRequest request) {
+ /**
+ * Reads the request body once into memory, so it can be both recorded on the span and sent. The
+ * bytes are copied exactly once: the decoded JSON and the replacement body both read the same
+ * backing array.
+ */
+ private static BufferedRequest bufferRequestBody(HttpRequest request) {
HttpRequestBody originalBody = request.body();
if (originalBody == null) {
- return request;
- }
- var baos = new ByteArrayOutputStream();
- originalBody.writeTo(baos);
- byte[] bytes = baos.toByteArray();
- String contentType = originalBody.contentType();
-
- HttpRequestBody bufferedBody =
- new HttpRequestBody() {
- @Override
- public void writeTo(OutputStream outputStream) {
- try {
- outputStream.write(bytes);
- } catch (java.io.IOException e) {
- throw new RuntimeException(e);
- }
- }
+ return new BufferedRequest(request, null);
+ }
+ var sink = new ByteSink(originalBody.contentLength());
+ originalBody.writeTo(sink);
+ var bufferedBody = new BufferedBody(sink.array(), sink.size(), originalBody.contentType());
+ return new BufferedRequest(
+ request.toBuilder().body(bufferedBody).build(),
+ sink.toString(StandardCharsets.UTF_8));
+ }
- @Override
- public String contentType() {
- return contentType;
- }
+ private record BufferedRequest(HttpRequest request, @Nullable String bodyJson) {}
- @Override
- public long contentLength() {
- return bytes.length;
- }
+ /** {@link ByteArrayOutputStream} that exposes its backing array instead of copying it. */
+ private static final class ByteSink extends ByteArrayOutputStream {
+ ByteSink(long sizeHint) {
+ super(sizeHint > 0 && sizeHint < Integer.MAX_VALUE - 8 ? (int) sizeHint : 32);
+ }
- @Override
- public boolean repeatable() {
- return true;
- }
+ byte[] array() {
+ return buf;
+ }
+ }
- @Override
- public void close() {}
- };
+ /** Repeatable body over the first {@code length} bytes of {@code bytes}. */
+ private static final class BufferedBody implements HttpRequestBody {
+ private final byte[] bytes;
+ private final int length;
+ private final String contentType;
- return request.toBuilder().body(bufferedBody).build();
- }
+ BufferedBody(byte[] bytes, int length, String contentType) {
+ this.bytes = bytes;
+ this.length = length;
+ this.contentType = contentType;
+ }
+
+ @Override
+ public void writeTo(OutputStream outputStream) {
+ try {
+ outputStream.write(bytes, 0, length);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String contentType() {
+ return contentType;
+ }
+
+ @Override
+ public long contentLength() {
+ return length;
+ }
+
+ @Override
+ public boolean repeatable() {
+ return true;
+ }
- private static String readBodyAsString(HttpRequestBody body) {
- var baos = new ByteArrayOutputStream((int) Math.max(body.contentLength(), 0));
- body.writeTo(baos);
- return baos.toString(StandardCharsets.UTF_8);
+ @Override
+ public void close() {}
}
// -------------------------------------------------------------------------
@@ -315,15 +374,17 @@ private static final class TeeingStreamHttpResponse implements HttpResponse {
private final HttpResponse delegate;
private final Span span;
private final Tracer tracer;
- private final long spanStartNanos = System.nanoTime();
+ private final long spanStartNanos;
private final AtomicLong timeToFirstTokenNanos = new AtomicLong();
private final ByteArrayOutputStream teeBuffer = new ByteArrayOutputStream();
private final InputStream teeStream;
- TeeingStreamHttpResponse(HttpResponse delegate, Span span, Tracer tracer) {
+ TeeingStreamHttpResponse(
+ HttpResponse delegate, Span span, Tracer tracer, long spanStartNanos) {
this.delegate = delegate;
this.span = span;
this.tracer = tracer;
+ this.spanStartNanos = spanStartNanos;
this.teeStream =
new TeeInputStream(
delegate.body(), teeBuffer, this::onFirstByte, this::onStreamClosed);
@@ -333,8 +394,11 @@ private void onFirstByte() {
timeToFirstTokenNanos.set(System.nanoTime() - spanStartNanos);
}
- private void onStreamClosed() {
+ private void onStreamClosed(@Nullable IOException failure) {
try {
+ if (failure != null) {
+ InstrumentationSemConv.tagLLMSpanResponse(span, failure);
+ }
byte[] bytes;
synchronized (teeBuffer) {
bytes = teeBuffer.toByteArray();
@@ -361,6 +425,15 @@ private void onStreamClosed() {
try {
var reassembled =
ResponseReassembler.reassemble(bytes, timeToFirstTokenNanos.get());
+ if (reassembled.error() != null) {
+ InstrumentationSemConv.tagLLMSpanResponse(
+ span,
+ com.anthropic.errors.SseException.builder()
+ .statusCode(statusCode)
+ .headers(delegate.headers())
+ .body(reassembled.error())
+ .build());
+ }
InstrumentationSemConv.tagLLMSpanResponse(
tracer,
span,
@@ -406,12 +479,15 @@ private static final class TeeInputStream extends InputStream {
private final InputStream source;
private final OutputStream sink;
private final Runnable onFirstByte;
- private final Runnable onClose;
+ private final Consumer onClose;
private final AtomicBoolean firstByteSeen = new AtomicBoolean(false);
private final AtomicBoolean closed = new AtomicBoolean(false);
TeeInputStream(
- InputStream source, OutputStream sink, Runnable onFirstByte, Runnable onClose) {
+ InputStream source,
+ OutputStream sink,
+ Runnable onFirstByte,
+ Consumer onClose) {
this.source = source;
this.sink = sink;
this.onFirstByte = onFirstByte;
@@ -420,31 +496,41 @@ private static final class TeeInputStream extends InputStream {
@Override
public int read() throws java.io.IOException {
- int b = source.read();
- if (b == -1) {
- notifyClosed();
- } else {
- notifyFirstByte();
- sink.write(b);
+ try {
+ int b = source.read();
+ if (b == -1) {
+ notifyClosed(null);
+ } else {
+ notifyFirstByte();
+ sink.write(b);
+ }
+ return b;
+ } catch (IOException e) {
+ notifyFailed(e);
+ throw e;
}
- return b;
}
@Override
public int read(byte[] buf, int off, int len) throws java.io.IOException {
- int n = source.read(buf, off, len);
- if (n == -1) {
- notifyClosed();
- } else {
- notifyFirstByte();
- sink.write(buf, off, n);
+ try {
+ int n = source.read(buf, off, len);
+ if (n == -1) {
+ notifyClosed(null);
+ } else if (n > 0) {
+ notifyFirstByte();
+ sink.write(buf, off, n);
+ }
+ return n;
+ } catch (IOException e) {
+ notifyFailed(e);
+ throw e;
}
- return n;
}
@Override
public void close() throws java.io.IOException {
- notifyClosed();
+ notifyClosed(null);
source.close();
}
@@ -454,9 +540,17 @@ private void notifyFirstByte() {
}
}
- private void notifyClosed() {
+ private void notifyFailed(IOException failure) {
+ try {
+ notifyClosed(failure);
+ } catch (Throwable e) {
+ log.error("Could not tag span from response read failure", e);
+ }
+ }
+
+ private void notifyClosed(@Nullable IOException failure) {
if (!closed.compareAndExchange(false, true)) {
- onClose.run();
+ onClose.accept(failure);
}
}
}
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/auto/AnthropicInstrumentationModule.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/auto/AnthropicInstrumentationModule.java
index da387a39..7d37f95f 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/auto/AnthropicInstrumentationModule.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/main/java/dev/braintrust/instrumentation/anthropic/v2_2_0/auto/AnthropicInstrumentationModule.java
@@ -1,6 +1,7 @@
package dev.braintrust.instrumentation.anthropic.v2_2_0.auto;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.anthropic.client.AnthropicClient;
@@ -10,6 +11,7 @@
import dev.braintrust.instrumentation.TypeInstrumentation;
import dev.braintrust.instrumentation.TypeTransformer;
import dev.braintrust.instrumentation.anthropic.v2_2_0.BraintrustAnthropic;
+import dev.braintrust.instrumentation.muzzle.ClassLoaderMatchers;
import io.opentelemetry.api.GlobalOpenTelemetry;
import java.util.List;
import net.bytebuddy.asm.Advice;
@@ -26,11 +28,24 @@ public AnthropicInstrumentationModule() {
super("anthropic_2_2_0");
}
+ /**
+ * Gates this module to anthropic-java < 3.0.0 (3.x is covered by {@code anthropic_3_0_0}, whose
+ * matcher requires {@code AssistantMessageParam}, a class new in 3.0.0).
+ */
+ @Override
+ public ElementMatcher classLoaderMatcher() {
+ return not(
+ ClassLoaderMatchers.hasClassNamed(
+ "com.anthropic.models.messages.AssistantMessageParam"));
+ }
+
@Override
public List getHelperClassNames() {
return List.of(
MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient",
- MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$1",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$BufferedRequest",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$ByteSink",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$BufferedBody",
MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$TeeingStreamHttpResponse",
MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$TeeInputStream",
MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$ExtractedRequest",
diff --git a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/test/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropicTest.java b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/test/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropicTest.java
index e30e1c91..5ead9c31 100644
--- a/braintrust-sdk/instrumentation/anthropic_2_2_0/src/test/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropicTest.java
+++ b/braintrust-sdk/instrumentation/anthropic_2_2_0/src/test/java/dev/braintrust/instrumentation/anthropic/v2_2_0/BraintrustAnthropicTest.java
@@ -21,12 +21,14 @@
import io.opentelemetry.api.trace.Span;
import io.opentelemetry.api.trace.StatusCode;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import lombok.SneakyThrows;
import net.bytebuddy.agent.ByteBuddyAgent;
import org.junit.jupiter.api.BeforeAll;
@@ -973,6 +975,204 @@ void cancelledNonLlmFutureStillEndsSpanOnTransportCompletion(
assertHttpSpan(parent, transportFailure || statusCode >= 300, transportFailure);
}
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void cancelledLlmFutureStillEndsSpanOnTransportCompletion(boolean transportFailure) {
+ var delegate = new PassthroughHttpClient();
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var closes = new AtomicInteger();
+ var future = client.executeAsync(messagesRequest(), RequestOptions.none());
+ assertTrue(future.cancel(true));
+ assertFalse(delegate.pending.isDone());
+ if (transportFailure) {
+ delegate.pending.completeExceptionally(new IllegalStateException("transport failed"));
+ } else {
+ delegate.pending.complete(
+ streamResponse(new ByteArrayInputStream(new byte[0]), closes));
+ }
+ assertTrue(future.isCancelled());
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertTrue(span.hasEnded());
+ assertEquals(
+ transportFailure ? StatusCode.ERROR : StatusCode.UNSET,
+ span.getStatus().getStatusCode());
+ assertEquals(transportFailure ? 1 : 0, span.getEvents().size());
+ assertEquals(transportFailure ? 0 : 1, closes.get());
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void timeToFirstTokenIncludesTransportDelay(boolean async) throws Exception {
+ String sse =
+ """
+ event: message_start
+ data: {"type":"message_start","message":{"id":"msg_test","type":"message","role":"assistant","model":"claude-test","content":[],"usage":{"input_tokens":1,"output_tokens":0}}}
+
+ event: content_block_start
+ data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
+
+ event: content_block_delta
+ data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
+
+ event: content_block_stop
+ data: {"type":"content_block_stop","index":0}
+
+ event: message_delta
+ data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":1}}
+
+ event: message_stop
+ data: {"type":"message_stop"}
+
+ """;
+ var delegate = new PassthroughHttpClient();
+ var closes = new AtomicInteger();
+ delegate.response =
+ streamResponse(
+ new ByteArrayInputStream(sse.getBytes(StandardCharsets.UTF_8)), closes);
+ long[] delayNanos = new long[1];
+ Runnable delay =
+ () -> {
+ long start = System.nanoTime();
+ try {
+ Thread.sleep(60);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new RuntimeException(e);
+ }
+ delayNanos[0] = System.nanoTime() - start;
+ };
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ HttpResponse response;
+ if (async) {
+ var future = client.executeAsync(messagesRequest(), RequestOptions.none());
+ delay.run();
+ delegate.pending.complete(delegate.response);
+ response = future.get(5, TimeUnit.SECONDS);
+ } else {
+ delegate.beforeResponse = delay;
+ response = client.execute(messagesRequest(), RequestOptions.none());
+ }
+ try (response) {
+ response.body().readAllBytes();
+ }
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ var metrics =
+ JSON_MAPPER.readTree(
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics")));
+ assertTrue(metrics.has("time_to_first_token"));
+ assertTrue(
+ metrics.get("time_to_first_token").asDouble() >= delayNanos[0] / 1_000_000_000.0,
+ "TTFT must include the time spent awaiting response headers");
+ assertEquals(StatusCode.UNSET, span.getStatus().getStatusCode());
+ assertTrue(span.getEvents().isEmpty());
+ assertEquals(1, closes.get());
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "false, true", "true, false", "true, true"})
+ void streamReadFailureEndsSpanBeforeClose(boolean async, boolean bulk) throws Exception {
+ var failure = new IOException("response stream failed");
+ var source =
+ new InputStream() {
+ private boolean first = true;
+
+ @Override
+ public int read() throws IOException {
+ if (first) {
+ first = false;
+ return '{';
+ }
+ throw failure;
+ }
+
+ @Override
+ public int read(byte[] bytes, int off, int len) throws IOException {
+ int value = read();
+ bytes[off] = (byte) value;
+ return 1;
+ }
+ };
+ var closes = new AtomicInteger();
+ var delegate = new PassthroughHttpClient();
+ delegate.response = streamResponse(source, closes);
+ delegate.pending.complete(delegate.response);
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var response =
+ async
+ ? client.executeAsync(messagesRequest(), RequestOptions.none())
+ .get(5, TimeUnit.SECONDS)
+ : client.execute(messagesRequest(), RequestOptions.none());
+ var body = response.body();
+ byte[] bytes = new byte[8];
+ if (bulk) {
+ assertEquals(1, body.read(bytes, 0, bytes.length));
+ } else {
+ assertEquals('{', body.read());
+ }
+ assertSame(
+ failure,
+ assertThrows(
+ IOException.class,
+ () -> {
+ if (bulk) {
+ body.read(bytes, 0, bytes.length);
+ } else {
+ body.read();
+ }
+ }));
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size(), "read failure must export before explicit close");
+ var span = spans.get(0);
+ assertTrue(span.hasEnded());
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(1, span.getEvents().size());
+ assertEquals("exception", span.getEvents().get(0).getName());
+ assertEquals(
+ failure.getMessage(),
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.message")));
+ assertEquals(
+ "stubbed-request-id",
+ span.getAttributes().get(AttributeKey.stringKey("request-id")));
+ assertEquals(0, closes.get());
+ assertSame(failure, assertThrows(IOException.class, () -> body.read()));
+ response.close();
+ var afterClose = testHarness.awaitExportedSpans();
+ assertEquals(1, afterClose.size());
+ assertEquals(1, afterClose.get(0).getEvents().size());
+ assertEquals(1, closes.get());
+ }
+
+ private static HttpResponse streamResponse(InputStream body, AtomicInteger closes) {
+ return new HttpResponse() {
+ @Override
+ public int statusCode() {
+ return 200;
+ }
+
+ @Override
+ public Headers headers() {
+ return Headers.builder().put("request-id", "stubbed-request-id").build();
+ }
+
+ @Override
+ public InputStream body() {
+ return body;
+ }
+
+ @Override
+ public void close() {
+ closes.incrementAndGet();
+ }
+ };
+ }
+
private void assertHttpSpan(Span parent, boolean failed, boolean exception) {
var spans = testHarness.awaitExportedSpans();
assertEquals(2, spans.size(), "one parent and one ended http span, no LLM/tool children");
@@ -1034,6 +1234,293 @@ public void close() {}
.build();
}
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void structuredOutputRetainsCallerParent(boolean async) throws Exception {
+ var transport = messageTransport();
+ var client = stubbedClient(transport);
+ try (AutoCloseable ignoredClient = client::close) {
+ var params =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Return the capital of France.")
+ .outputConfig(Capital.class)
+ .build();
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ var response =
+ async
+ ? client.async().messages().create(params).get(5, TimeUnit.SECONDS)
+ : client.messages().create(params);
+ assertEquals("msg_test", response.id());
+ } finally {
+ parent.end();
+ }
+ assertRequestParent(parent);
+ assertTrue(
+ transport
+ .sentRequest
+ .headers()
+ .values(ContextCapturingProxy.CONTEXT_HEADER)
+ .isEmpty());
+ }
+ }
+
+ public static class Capital {
+ public String city;
+ }
+
+ @Test
+ void parameterlessAsyncCallRetainsCallerParent() throws Exception {
+ var transport = new PassthroughHttpClient();
+ transport.pending.complete(
+ new StubHttpClient(
+ 200,
+ "{\"data\":[],\"has_more\":false,\"first_id\":null,\"last_id\":null}")
+ .execute(messagesRequest(), RequestOptions.none()));
+ var client = stubbedClient(transport);
+ try (AutoCloseable ignoredClient = client::close) {
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ assertTrue(
+ client.async()
+ .messages()
+ .batches()
+ .list()
+ .get(5, TimeUnit.SECONDS)
+ .data()
+ .isEmpty());
+ } finally {
+ parent.end();
+ }
+ assertRequestParent(parent);
+ assertTrue(
+ transport
+ .sentRequest
+ .headers()
+ .values(ContextCapturingProxy.CONTEXT_HEADER)
+ .isEmpty());
+ }
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "false, true", "true, false", "true, true"})
+ void serviceOptionsRetainTracingWithoutLeakingContext(boolean async, boolean replaceTransport)
+ throws Exception {
+ var original = messageTransport();
+ var replacement = replaceTransport ? messageTransport() : original;
+ java.util.function.Consumer options =
+ o -> {
+ if (replaceTransport) {
+ o.httpClient(replacement);
+ } else {
+ o.maxRetries(1);
+ }
+ };
+ var client = stubbedClient(original);
+ try (AutoCloseable ignoredClient = client::close) {
+ var params =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Return the capital of France.")
+ .build();
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ var response =
+ async
+ ? client.async()
+ .messages()
+ .withOptions(options)
+ .create(params)
+ .get(5, TimeUnit.SECONDS)
+ : client.messages().withOptions(options).create(params);
+ assertEquals("msg_test", response.id());
+ } finally {
+ parent.end();
+ }
+ if (replaceTransport) {
+ assertNull(original.sentRequest);
+ }
+ assertTrue(
+ replacement
+ .sentRequest
+ .headers()
+ .values(ContextCapturingProxy.CONTEXT_HEADER)
+ .isEmpty(),
+ "Internal correlation header must never reach the replacement transport");
+ assertRequestParent(parent);
+ }
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "false, true", "true, false", "true, true"})
+ void sseErrorMarksSpanFailedWithoutChangingSdkException(boolean async, boolean partial)
+ throws Exception {
+ String error =
+ """
+ event: error
+ data: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}
+
+ """;
+ if (partial) {
+ error =
+ """
+ event: message_start
+ data: {"type":"message_start","message":{"id":"msg_test","type":"message","role":"assistant","model":"claude-test","content":[],"usage":{"input_tokens":1,"output_tokens":0}}}
+
+ event: content_block_start
+ data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
+
+ event: content_block_delta
+ data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
+
+ """
+ + error;
+ }
+ var transport = new PassthroughHttpClient();
+ transport.response =
+ new StubHttpClient(200, error).execute(messagesRequest(), RequestOptions.none());
+ transport.pending.complete(transport.response);
+ var client = stubbedClient(transport);
+ try (AutoCloseable ignoredClient = client::close) {
+ var params =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Hello")
+ .build();
+ if (async) {
+ try (var response =
+ client.async()
+ .messages()
+ .withRawResponse()
+ .createStreaming(params)
+ .get(5, TimeUnit.SECONDS)) {
+ var failure =
+ assertThrows(
+ com.anthropic.errors.SseException.class,
+ () -> response.parse().stream().forEach(event -> {}));
+ assertTrue(failure.getMessage().contains("Overloaded"));
+ }
+ } else {
+ try (var stream = client.messages().createStreaming(params)) {
+ var failure =
+ assertThrows(
+ com.anthropic.errors.SseException.class,
+ () -> stream.stream().forEach(event -> {}));
+ assertTrue(failure.getMessage().contains("Overloaded"));
+ }
+ }
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(1, span.getEvents().size());
+ String message =
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.message"));
+ assertTrue(message.contains("overloaded_error"));
+ assertTrue(message.contains("Overloaded"));
+ assertEquals(
+ "stubbed-request-id",
+ span.getAttributes().get(AttributeKey.stringKey("request-id")));
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void llmLinkageErrorEndsSpanWithoutMaskingFailure(boolean async) {
+ var failure = new NoSuchMethodError("incompatible transport API");
+ var transport =
+ new com.anthropic.core.http.HttpClient() {
+ @Override
+ public HttpResponse execute(HttpRequest request, RequestOptions options) {
+ throw failure;
+ }
+
+ @Override
+ public CompletableFuture executeAsync(
+ HttpRequest request, RequestOptions options) {
+ throw failure;
+ }
+
+ @Override
+ public void close() {}
+ };
+ var client = new TracingHttpClient(testHarness.openTelemetry(), transport);
+ assertSame(
+ failure,
+ assertThrows(
+ NoSuchMethodError.class,
+ () -> {
+ if (async) {
+ client.executeAsync(messagesRequest(), RequestOptions.none());
+ } else {
+ client.execute(messagesRequest(), RequestOptions.none());
+ }
+ }));
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertTrue(span.hasEnded());
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(1, span.getEvents().size());
+ assertEquals(
+ NoSuchMethodError.class.getName(),
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.type")));
+ assertEquals(
+ failure.getMessage(),
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.message")));
+ }
+
+ private AnthropicClient stubbedClient(com.anthropic.core.http.HttpClient transport) {
+ return BraintrustAnthropic.wrap(
+ testHarness.openTelemetry(),
+ new com.anthropic.client.AnthropicClientImpl(
+ com.anthropic.core.ClientOptions.builder()
+ .httpClient(transport)
+ .putHeader("x-api-key", "test-key")
+ .maxRetries(0)
+ .build()));
+ }
+
+ private static PassthroughHttpClient messageTransport() {
+ var transport = new PassthroughHttpClient();
+ transport.response =
+ new StubHttpClient(
+ 200,
+ """
+ {"id":"msg_test","type":"message","role":"assistant","model":"claude-test",
+ "content":[{"type":"text","text":"{\\"city\\":\\"Paris\\"}"}],
+ "stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":1,"output_tokens":1}}
+ """)
+ .execute(messagesRequest(), RequestOptions.none());
+ transport.pending.complete(transport.response);
+ return transport;
+ }
+
+ private void assertRequestParent(Span parent) {
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(2, spans.size(), () -> "One caller and one request span: " + spans);
+ var request =
+ spans.stream().filter(s -> !s.getName().equals("caller")).findFirst().orElseThrow();
+ assertEquals(parent.getSpanContext().getSpanId(), request.getParentSpanId());
+ assertEquals(parent.getSpanContext().getTraceId(), request.getTraceId());
+ }
+
private static final class PassthroughHttpClient implements com.anthropic.core.http.HttpClient {
private final CompletableFuture pending = new CompletableFuture<>();
private HttpResponse response;
@@ -1041,6 +1528,7 @@ private static final class PassthroughHttpClient implements com.anthropic.core.h
private boolean immediateFailure;
private HttpRequest sentRequest;
private Span requestSpan;
+ private Runnable beforeResponse = () -> {};
@Override
public HttpResponse execute(HttpRequest request, RequestOptions options) {
@@ -1049,6 +1537,7 @@ public HttpResponse execute(HttpRequest request, RequestOptions options) {
if (failure != null) {
throw failure;
}
+ beforeResponse.run();
return response;
}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/build.gradle b/braintrust-sdk/instrumentation/anthropic_3_0_0/build.gradle
new file mode 100644
index 00000000..54d448ca
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/build.gradle
@@ -0,0 +1,53 @@
+// Java plugin, toolchain (Java 17 / Adoptium), options.release, and repositories
+// are inherited from the parent's subprojects {} block.
+
+def anthropicVersion = '3.0.0'
+// Test against a recent release to exercise forward compatibility.
+def anthropicTestVersion = '3.4.0'
+
+muzzle {
+ pass {
+ group = 'com.anthropic'
+ module = 'anthropic-java'
+ versions = "[${anthropicVersion},)"
+ }
+ // 2.x is covered by anthropic_2_2_0; assert the classLoaderMatcher rejects it.
+ fail {
+ group = 'com.anthropic'
+ module = 'anthropic-java'
+ pinVersions '2.75.0'
+ }
+}
+
+dependencies {
+ compileOnly project(':braintrust-java-agent:instrumenter')
+ implementation "io.opentelemetry:opentelemetry-api:${otelVersion}"
+ implementation 'com.google.code.findbugs:jsr305:3.0.2' // for @Nullable annotations
+ implementation "org.slf4j:slf4j-api:${slf4jVersion}"
+ implementation project(':braintrust-sdk')
+
+ // ByteBuddy for ElementMatcher types used in instrumentation definitions
+ compileOnly "net.bytebuddy:byte-buddy:${byteBuddyVersion}"
+
+ // Target library — compileOnly because it will be on the app classpath at runtime
+ compileOnly "com.anthropic:anthropic-java:${anthropicVersion}"
+
+ // Test dependencies
+ testImplementation(testFixtures(project(":test-harness")))
+ testImplementation project(':braintrust-java-agent:instrumenter')
+ testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
+ testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
+ testImplementation "net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}"
+ testRuntimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"
+ testImplementation "com.anthropic:anthropic-java:${anthropicTestVersion}"
+}
+
+test {
+ useJUnitPlatform()
+ workingDir = rootProject.projectDir
+ testLogging {
+ events "passed", "skipped", "failed"
+ showStandardStreams = true
+ exceptionFormat "full"
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropic.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropic.java
new file mode 100644
index 00000000..d92fb085
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropic.java
@@ -0,0 +1,248 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.AnthropicClientAsync;
+import com.anthropic.core.ClientOptions;
+import com.anthropic.core.http.HttpClient;
+import com.anthropic.core.opentelemetry.OpenTelemetryOptions;
+import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Tracer;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.function.Consumer;
+import lombok.extern.slf4j.Slf4j;
+
+/** Braintrust Anthropic client instrumentation. */
+@Slf4j
+public final class BraintrustAnthropic {
+ static final String INSTRUMENTATION_NAME = "anthropic";
+ static final String INSTRUMENTATION_VERSION = "3.0.0";
+
+ /** Instrument Anthropic client with Braintrust traces. */
+ public static AnthropicClient wrap(OpenTelemetry openTelemetry, AnthropicClient client) {
+ if (!instrument(
+ openTelemetry.getTracer(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION),
+ client,
+ false)) {
+ return client;
+ }
+ return ContextCapturingProxy.wrap(client, AnthropicClient.class);
+ }
+
+ /** Instrument an async Anthropic client with Braintrust traces. */
+ public static AnthropicClientAsync wrap(
+ OpenTelemetry openTelemetry, AnthropicClientAsync client) {
+ if (!instrument(
+ openTelemetry.getTracer(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION),
+ client,
+ false)) {
+ return client;
+ }
+ return ContextCapturingProxy.wrap(client, AnthropicClientAsync.class);
+ }
+
+ /**
+ * Instruments a client using the owning library's tracer, replacing any existing provider
+ * tracer without adding another tracing layer.
+ */
+ public static AnthropicClient wrap(Tracer tracer, AnthropicClient client) {
+ if (!instrument(tracer, client, true)) {
+ return client;
+ }
+ return ContextCapturingProxy.wrap(client, AnthropicClient.class);
+ }
+
+ /** Async counterpart of {@link #wrap(Tracer, AnthropicClient)}. */
+ public static AnthropicClientAsync wrap(Tracer tracer, AnthropicClientAsync client) {
+ if (!instrument(tracer, client, true)) {
+ return client;
+ }
+ return ContextCapturingProxy.wrap(client, AnthropicClientAsync.class);
+ }
+
+ /**
+ * Swaps the client's {@code ClientOptions.httpClient} for a {@link TracingHttpClient} in place;
+ * wrapping is idempotent.
+ *
+ * @return whether the HTTP layer is instrumented. When false (custom client implementations or
+ * changed SDK internals), the caller must NOT install {@link ContextCapturingProxy}: the
+ * proxy's internal context header is only stripped by {@link TracingHttpClient}, so
+ * installing it without one would leak trace/span IDs to the provider.
+ */
+ private static boolean instrument(Tracer tracer, Object client, boolean replaceTracer) {
+ if (ContextCapturingProxy.isContextCapturingProxy(client)) {
+ if (!replaceTracer) {
+ return true;
+ }
+ client = ContextCapturingProxy.unwrap(client);
+ }
+ try {
+ instrumentHttpClient(tracer, client, replaceTracer);
+ return true;
+ } catch (Exception e) {
+ log.error(
+ "failed to apply anthropic instrumentation to {} — leaving client untouched",
+ client.getClass().getName(),
+ e);
+ return false;
+ }
+ }
+
+ /** Preserves the source's current tracer when withOptions replaces a service's transport. */
+ static boolean instrumentDerivedService(Object source, Object service) {
+ try {
+ ClientOptions options = getField(source, "clientOptions");
+ // async() rebuilds ClientOptions: its retry layer can enclose the instrumented
+ // original transport instead of itself being wrapped.
+ HttpClient transport = options.httpClient();
+ if (!(transport instanceof TracingHttpClient)) {
+ transport = getField(options, "originalHttpClient");
+ }
+ if (transport instanceof TracingHttpClient tracing) {
+ return instrument(tracing.tracer(), service, false);
+ }
+ } catch (ReflectiveOperationException | RuntimeException e) {
+ log.error("failed to instrument derived anthropic service", e);
+ }
+ // Without a tracing transport, adding the context proxy would leak its internal header.
+ return false;
+ }
+
+ private static void instrumentHttpClient(Tracer tracer, Object client, boolean replaceTracer) {
+ int[] instrumented = {0};
+ forAllFields(
+ client,
+ fieldName -> {
+ try {
+ if (getField(client, fieldName) instanceof ClientOptions clientOptions) {
+ instrumentClientOptions(tracer, clientOptions, replaceTracer);
+ instrumented[0]++;
+ }
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ if (instrumented[0] == 0) {
+ // Finding nothing is as much a failure as a reflection error: the request path
+ // would bypass TracingHttpClient entirely.
+ throw new IllegalStateException(
+ "no ClientOptions field found on "
+ + client.getClass().getName()
+ + " — unrecognized client shape");
+ }
+ }
+
+ /**
+ * Swaps both HTTP client fields on a {@link ClientOptions} for tracing wrappers and turns off
+ * the SDK's built-in tracing.
+ */
+ private static void instrumentClientOptions(
+ Tracer tracer, ClientOptions clientOptions, boolean replaceTracer) {
+ disableNativeTracing(clientOptions);
+ try {
+ HttpClient original = getField(clientOptions, "originalHttpClient");
+ if (original instanceof TracingHttpClient tracing
+ && !(clientOptions.httpClient() instanceof TracingHttpClient)) {
+ // async()/withOptions() rebuild the SDK transport around the traced original.
+ // Rebuild around its untraced delegate before adding our outer wrapper, retaining
+ // the SDK's retry, authentication, interceptor, and logging configuration.
+ var builder = clientOptions.toBuilder();
+ // The public setter installs another GC-closing wrapper. Reuse the existing
+ // transport's ownership instead of letting this derived client close a shared one.
+ setPrivateField(builder, "httpClient", tracing.underlying());
+ HttpClient rebuilt = builder.build().httpClient();
+ setPrivateField(
+ clientOptions,
+ "httpClient",
+ new TracingHttpClient(replaceTracer ? tracer : tracing.tracer(), rebuilt));
+ }
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException(e);
+ }
+ swapHttpClient(tracer, clientOptions, "originalHttpClient", replaceTracer);
+ swapHttpClient(tracer, clientOptions, "httpClient", replaceTracer);
+ }
+
+ /**
+ * anthropic-java (2.72.0+) has built-in OTel tracing, on by default via GlobalOpenTelemetry,
+ * which would emit a duplicate {@code com.anthropic.sdk.java} span around each of ours. The SDK
+ * re-reads {@code ClientOptions.openTelemetry().traces().enabled()} on every API call, so
+ * replacing the field disables it for this client. Best-effort: on failure we keep our
+ * instrumentation and accept the duplicate spans.
+ */
+ private static void disableNativeTracing(ClientOptions clientOptions) {
+ try {
+ OpenTelemetryOptions otel = clientOptions.openTelemetry();
+ if (!otel.traces().enabled()) {
+ return;
+ }
+ setPrivateField(clientOptions, "openTelemetry", otel.toBuilder().traces(false).build());
+ } catch (ReflectiveOperationException | RuntimeException e) {
+ log.warn(
+ "failed to disable anthropic-java built-in tracing; spans may be duplicated",
+ e);
+ }
+ }
+
+ private static void swapHttpClient(
+ Tracer tracer, ClientOptions clientOptions, String fieldName, boolean replaceTracer) {
+ try {
+ HttpClient httpClient = getField(clientOptions, fieldName);
+ if (httpClient instanceof TracingHttpClient tracing) {
+ if (replaceTracer) {
+ setPrivateField(clientOptions, fieldName, tracing.withTracer(tracer));
+ }
+ } else {
+ setPrivateField(
+ clientOptions, fieldName, new TracingHttpClient(tracer, httpClient));
+ }
+ } catch (ReflectiveOperationException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static void forAllFields(Object object, Consumer consumer) {
+ if (object == null || consumer == null) return;
+ Class> clazz = object.getClass();
+ while (clazz != null && clazz != Object.class) {
+ for (Field field : clazz.getDeclaredFields()) {
+ if (field.isSynthetic()) continue;
+ if (Modifier.isStatic(field.getModifiers())) continue;
+ consumer.accept(field.getName());
+ }
+ clazz = clazz.getSuperclass();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private static T getField(Object obj, String fieldName)
+ throws ReflectiveOperationException {
+ Class> clazz = obj.getClass();
+ while (clazz != null) {
+ try {
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ return (T) field.get(obj);
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ throw new NoSuchFieldException(fieldName);
+ }
+
+ private static void setPrivateField(Object obj, String fieldName, Object value)
+ throws ReflectiveOperationException {
+ Class> clazz = obj.getClass();
+ while (clazz != null) {
+ try {
+ Field field = clazz.getDeclaredField(fieldName);
+ field.setAccessible(true);
+ field.set(obj, value);
+ return;
+ } catch (NoSuchFieldException e) {
+ clazz = clazz.getSuperclass();
+ }
+ }
+ throw new NoSuchFieldException(fieldName);
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/ContextCapturingProxy.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/ContextCapturingProxy.java
new file mode 100644
index 00000000..aae2276f
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/ContextCapturingProxy.java
@@ -0,0 +1,197 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import com.anthropic.core.Params;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanContext;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Captures the caller's OTel context at the service-call boundary of a wrapped anthropic-java
+ * client.
+ *
+ * anthropic-java dispatches async requests through CompletableFuture continuations on the common
+ * pool, so by the time {@link TracingHttpClient#executeAsync} runs, the caller's thread-local
+ * context (e.g. an active application span) is gone. The service-method invocation itself, however,
+ * happens on the caller's thread — and the only data that travels from there into the HTTP layer is
+ * the request. So this proxy rewrites any {@link Params} argument to carry the current span as an
+ * internal {@code traceparent}-format header, which {@link TracingHttpClient} extracts (and strips
+ * from the outgoing request) to parent the LLM span.
+ *
+ *
Purely reflective and API-shape based, so it works for every service and endpoint: methods
+ * returning other {@code com.anthropic} interfaces (service accessors like {@code messages()},
+ * {@code async()}) return proxied instances, so context capture follows the whole call graph.
+ */
+@Slf4j
+final class ContextCapturingProxy implements InvocationHandler {
+
+ /** Internal correlation header; never sent — TracingHttpClient removes it. */
+ static final String CONTEXT_HEADER = "x-braintrust-instrumentation-context";
+
+ /** Per-params-class reflection handles: [toBuilder, putAdditionalHeader, build]. */
+ private static final Map, Method[]> PARAMS_METHODS = new ConcurrentHashMap<>();
+
+ private static final Method[] UNSUPPORTED = new Method[0];
+
+ private final Object delegate;
+
+ private ContextCapturingProxy(Object delegate) {
+ this.delegate = delegate;
+ }
+
+ /** Wraps {@code delegate} in a context-capturing proxy of {@code iface}. Idempotent. */
+ @SuppressWarnings("unchecked")
+ static T wrap(T delegate, Class iface) {
+ if (delegate == null || isContextCapturingProxy(delegate)) {
+ return delegate;
+ }
+ return (T)
+ Proxy.newProxyInstance(
+ iface.getClassLoader(),
+ new Class>[] {iface},
+ new ContextCapturingProxy(delegate));
+ }
+
+ static boolean isContextCapturingProxy(Object o) {
+ return o != null
+ && Proxy.isProxyClass(o.getClass())
+ && Proxy.getInvocationHandler(o) instanceof ContextCapturingProxy;
+ }
+
+ static Object unwrap(Object proxy) {
+ do {
+ proxy = ((ContextCapturingProxy) Proxy.getInvocationHandler(proxy)).delegate;
+ } while (isContextCapturingProxy(proxy));
+ return proxy;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ // equals/hashCode/toString are the only Object methods routed to an InvocationHandler.
+ // They must not be forwarded like service methods: delegate.equals(proxy) is false, so a
+ // forwarded equals would make proxy.equals(proxy) false — violating reflexivity and
+ // breaking map/set usage of wrapped clients.
+ if (method.getDeclaringClass() == Object.class) {
+ return switch (method.getName()) {
+ case "equals" -> proxy == args[0] || delegateEquals(args[0]);
+ case "hashCode" -> delegate.hashCode();
+ default -> "ContextCapturingProxy(" + delegate + ")"; // toString
+ };
+ }
+ // Convenience overloads must dispatch back through this proxy once they have
+ // constructed Params (e.g. structured output and parameterless batch listing).
+ if (method.isDefault()) {
+ return InvocationHandler.invokeDefault(proxy, method, args);
+ }
+ Object[] invokeArgs = injectContextHeader(args);
+ Object result;
+ try {
+ result = method.invoke(delegate, invokeArgs);
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ }
+ // Follow the service graph: accessors like messages(), async() return com.anthropic
+ // interfaces whose methods must also capture context.
+ Class> returnType = method.getReturnType();
+ if (result != null
+ && returnType.isInterface()
+ && returnType.getName().startsWith("com.anthropic.")) {
+ // withOptions can replace the transport. Only capture context if its new
+ // HTTP layer is instrumented and will strip the internal header.
+ if (method.getName().equals("withOptions")
+ && !BraintrustAnthropic.instrumentDerivedService(delegate, result)) {
+ return result;
+ }
+ return Proxy.newProxyInstance(
+ returnType.getClassLoader(),
+ new Class>[] {returnType},
+ new ContextCapturingProxy(result));
+ }
+ return result;
+ }
+
+ /** Two proxies are equal iff their delegates are (consistent with delegate-based hashCode). */
+ private boolean delegateEquals(Object other) {
+ return isContextCapturingProxy(other)
+ && delegate.equals(
+ ((ContextCapturingProxy) Proxy.getInvocationHandler(other)).delegate);
+ }
+
+ /** Rewrites any {@link Params} argument to carry the current span as an internal header. */
+ private Object[] injectContextHeader(Object[] args) {
+ if (args == null) {
+ return null;
+ }
+ String traceparent = currentTraceparent();
+ if (traceparent == null) {
+ return args;
+ }
+ Object[] result = args;
+ for (int i = 0; i < args.length; i++) {
+ if (args[i] instanceof Params params) {
+ Object rewritten = withContextHeader(params, traceparent);
+ if (rewritten != null) {
+ if (result == args) {
+ result = args.clone();
+ }
+ result[i] = rewritten;
+ }
+ }
+ }
+ return result;
+ }
+
+ private static String currentTraceparent() {
+ SpanContext spanContext = Span.current().getSpanContext();
+ if (!spanContext.isValid()) {
+ return null;
+ }
+ return "00-"
+ + spanContext.getTraceId()
+ + "-"
+ + spanContext.getSpanId()
+ + "-"
+ + spanContext.getTraceFlags().asHex();
+ }
+
+ /**
+ * {@code params.toBuilder().putAdditionalHeader(CONTEXT_HEADER, traceparent).build()}, done
+ * reflectively so it works for every generated params type. Returns {@code null} (leaving the
+ * original untouched) when the shape doesn't match.
+ */
+ private static Object withContextHeader(Params params, String traceparent) {
+ Method[] methods =
+ PARAMS_METHODS.computeIfAbsent(
+ params.getClass(), ContextCapturingProxy::resolveParamsMethods);
+ if (methods == UNSUPPORTED) {
+ return null;
+ }
+ try {
+ Object builder = methods[0].invoke(params);
+ methods[1].invoke(builder, CONTEXT_HEADER, traceparent);
+ return methods[2].invoke(builder);
+ } catch (Exception e) {
+ log.debug("failed to inject context header into {}", params.getClass().getName(), e);
+ return null;
+ }
+ }
+
+ private static Method[] resolveParamsMethods(Class> paramsClass) {
+ try {
+ Method toBuilder = paramsClass.getMethod("toBuilder");
+ Class> builderClass = toBuilder.getReturnType();
+ Method putHeader =
+ builderClass.getMethod("putAdditionalHeader", String.class, String.class);
+ Method build = builderClass.getMethod("build");
+ return new Method[] {toBuilder, putHeader, build};
+ } catch (NoSuchMethodException e) {
+ log.debug("params type {} has no header builder shape", paramsClass.getName());
+ return UNSUPPORTED;
+ }
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/ResponseReassembler.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/ResponseReassembler.java
new file mode 100644
index 00000000..f5b3f30f
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/ResponseReassembler.java
@@ -0,0 +1,142 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import com.anthropic.core.JsonValue;
+import com.anthropic.helpers.MessageAccumulator;
+import com.anthropic.models.messages.RawMessageStreamEvent;
+import dev.braintrust.json.BraintrustJsonMapper;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import javax.annotation.Nullable;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * Turns the raw bytes of an Anthropic response into a single JSON document the semconv layer can
+ * tag.
+ *
+ * All of the wire-format bookkeeping lives here — SSE-vs-plain-JSON detection and chunk
+ * reassembly — so that {@code TracingHttpClient} is left holding only the span lifecycle and one
+ * flat call into {@code InstrumentationSemConv}.
+ */
+@Slf4j
+class ResponseReassembler {
+
+ private ResponseReassembler() {}
+
+ /**
+ * A reassembled response body plus the timing that belongs with it.
+ *
+ *
{@code body} is null when there was nothing usable to reassemble — an empty response, or
+ * one we couldn't parse. Callers should still tag the response in that case; the headers remain
+ * worth recording.
+ *
+ *
{@code timeToFirstTokenNanos} is only populated for a stream, since a non-streaming
+ * response has no first token to time.
+ *
+ *
{@code error} retains an SSE error payload independently of message completion.
+ */
+ record Result(
+ @Nullable String body,
+ @Nullable Long timeToFirstTokenNanos,
+ @Nullable JsonValue error) {
+ static final Result EMPTY = new Result(null, null, null);
+ }
+
+ /** Detects the wire format and reassembles accordingly. Never throws. */
+ static Result reassemble(byte[] bytes, long timeToFirstTokenNanos) {
+ if (bytes.length == 0) {
+ return Result.EMPTY;
+ }
+ try {
+ String firstLine = firstNonEmptyLine(bytes);
+ // Anthropic SSE starts with "event: message_start\ndata: ..." so we detect either
+ // prefix. OpenAI SSE starts directly with "data:".
+ boolean isSse =
+ firstLine != null
+ && (firstLine.startsWith("data:") || firstLine.startsWith("event:"));
+ if (isSse) {
+ return reassembleSse(bytes, timeToFirstTokenNanos);
+ }
+ // Non-streaming: plain Message JSON — pass it whole, no time_to_first_token
+ return new Result(new String(bytes, StandardCharsets.UTF_8), null, null);
+ } catch (Exception e) {
+ log.error("Could not reassemble Anthropic response buffer", e);
+ return Result.EMPTY;
+ }
+ }
+
+ @Nullable
+ private static String firstNonEmptyLine(byte[] bytes) {
+ int start = 0;
+ for (int i = 0; i <= bytes.length; i++) {
+ if (i == bytes.length || bytes[i] == '\n') {
+ String line = new String(bytes, start, i - start, StandardCharsets.UTF_8).strip();
+ if (!line.isEmpty()) return line;
+ start = i + 1;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Anthropic SSE wire format has named events:
+ *
+ *
+ * event: message_start
+ * data: {"type":"message_start","message":{...}}
+ *
+ * event: content_block_delta
+ * data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hi"}}
+ *
+ *
+ * Feed message data payloads to {@link MessageAccumulator} and serialize the assembled {@link
+ * com.anthropic.models.messages.Message}. Error events are returned separately so the tracing
+ * layer can report failures raised by the SDK above the HTTP stream.
+ */
+ private static Result reassembleSse(byte[] sseBytes, long timeToFirstTokenNanos) {
+ try {
+ var mapper = BraintrustJsonMapper.get();
+ var reader =
+ new BufferedReader(
+ new InputStreamReader(
+ new ByteArrayInputStream(sseBytes), StandardCharsets.UTF_8));
+ var accumulator = MessageAccumulator.create();
+ String line;
+ String event = null;
+ while ((line = reader.readLine()) != null) {
+ if (line.isEmpty()) {
+ event = null;
+ continue;
+ }
+ if (line.startsWith("event:")) {
+ event = line.substring("event:".length()).strip();
+ continue;
+ }
+ if (!line.startsWith("data:")) continue;
+ String data = line.substring("data:".length()).strip();
+ if (data.isEmpty()) continue;
+ try {
+ var payload = mapper.readTree(data);
+ // The SDK raises these above the HTTP stream, so byte reads alone cannot
+ // detect the failure. Preserve it even when no complete message exists.
+ if ("error".equals(event) || "error".equals(payload.path("type").asText())) {
+ return new Result(
+ null, timeToFirstTokenNanos, JsonValue.fromJsonNode(payload));
+ }
+ accumulator.accumulate(
+ mapper.treeToValue(payload, RawMessageStreamEvent.class));
+ } catch (Exception ignored) {
+ // skip unrecognized event types (e.g. ping)
+ }
+ }
+ return new Result(
+ BraintrustJsonMapper.toJson(accumulator.message()),
+ timeToFirstTokenNanos,
+ null);
+ } catch (Exception e) {
+ log.error("Could not parse Anthropic SSE buffer to tag streaming span output", e);
+ return new Result(null, timeToFirstTokenNanos, null);
+ }
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/TracingHttpClient.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/TracingHttpClient.java
new file mode 100644
index 00000000..12200b5f
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/TracingHttpClient.java
@@ -0,0 +1,600 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import com.anthropic.core.RequestOptions;
+import com.anthropic.core.http.HttpClient;
+import com.anthropic.core.http.HttpMethod;
+import com.anthropic.core.http.HttpRequest;
+import com.anthropic.core.http.HttpRequestBody;
+import com.anthropic.core.http.HttpResponse;
+import dev.braintrust.instrumentation.InstrumentationSemConv;
+import io.opentelemetry.api.OpenTelemetry;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.SpanContext;
+import io.opentelemetry.api.trace.TraceFlags;
+import io.opentelemetry.api.trace.TraceState;
+import io.opentelemetry.api.trace.Tracer;
+import io.opentelemetry.context.Context;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Consumer;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class TracingHttpClient implements HttpClient {
+ private final Tracer tracer;
+ private final HttpClient underlying;
+
+ public TracingHttpClient(OpenTelemetry openTelemetry, HttpClient underlying) {
+ this(
+ openTelemetry.getTracer(
+ BraintrustAnthropic.INSTRUMENTATION_NAME,
+ BraintrustAnthropic.INSTRUMENTATION_VERSION),
+ underlying);
+ }
+
+ TracingHttpClient(Tracer tracer, HttpClient underlying) {
+ this.tracer = tracer;
+ this.underlying = underlying;
+ }
+
+ TracingHttpClient withTracer(Tracer tracer) {
+ return this.tracer == tracer ? this : new TracingHttpClient(tracer, underlying);
+ }
+
+ Tracer tracer() {
+ return tracer;
+ }
+
+ HttpClient underlying() {
+ return underlying;
+ }
+
+ /**
+ * Starts a request span. anthropic-java (and frameworks like Spring AI 2.x) dispatch
+ * async/streaming requests on executors where the caller's thread-local context is lost — which
+ * would orphan the span. {@link ContextCapturingProxy} captures the caller's context at the
+ * service-call boundary and threads it through as {@code headerContext}; when that is absent we
+ * fall back to whatever context is current on this thread (correct for synchronous calls). We
+ * deliberately do not fall back to the context that was current when the client was
+ * instrumented — a long-lived client wrapped inside some unrelated span would otherwise parent
+ * every future request to that stale span.
+ */
+ private Span startSpan(String name, @Nullable Context headerContext) {
+ Context parent = headerContext != null ? headerContext : Context.current();
+ return tracer.spanBuilder(name).setParent(parent).startSpan();
+ }
+
+ /**
+ * Extracts the caller context injected by {@link ContextCapturingProxy} (if any) and strips the
+ * internal header from the outgoing request.
+ */
+ private static ExtractedRequest extractCallerContext(HttpRequest request) {
+ var values = request.headers().values(ContextCapturingProxy.CONTEXT_HEADER);
+ if (values.isEmpty()) {
+ return new ExtractedRequest(request, null);
+ }
+ Context context = contextFromTraceparent(values.get(0));
+ HttpRequest stripped =
+ request.toBuilder()
+ .replaceHeaders(ContextCapturingProxy.CONTEXT_HEADER, java.util.List.of())
+ .build();
+ return new ExtractedRequest(stripped, context);
+ }
+
+ /** Parses a W3C {@code traceparent} value ({@code 00---}). */
+ @Nullable
+ private static Context contextFromTraceparent(String traceparent) {
+ try {
+ String[] parts = traceparent.split("-");
+ if (parts.length < 4) {
+ return null;
+ }
+ SpanContext spanContext =
+ SpanContext.create(
+ parts[1],
+ parts[2],
+ TraceFlags.fromHex(parts[3], 0),
+ TraceState.getDefault());
+ if (!spanContext.isValid()) {
+ return null;
+ }
+ return Context.root().with(Span.wrap(spanContext));
+ } catch (Exception e) {
+ log.debug("invalid context header value: {}", traceparent, e);
+ return null;
+ }
+ }
+
+ private record ExtractedRequest(HttpRequest request, @Nullable Context callerContext) {}
+
+ @Override
+ public void close() {
+ underlying.close();
+ }
+
+ @Override
+ public @Nonnull HttpResponse execute(
+ @Nonnull HttpRequest httpRequest, @Nonnull RequestOptions requestOptions) {
+ var extracted = extractCallerContext(httpRequest);
+ if (!isLlmRequest(extracted.request())) {
+ return executeHttp(extracted, requestOptions);
+ }
+ long spanStartNanos = System.nanoTime();
+ var span = startSpan(InstrumentationSemConv.UNSET_LLM_SPAN_NAME, extracted.callerContext());
+ try (var ignored = span.makeCurrent()) {
+ var buffered = bufferRequestBody(extracted.request());
+ var bufferedRequest = buffered.request();
+ InstrumentationSemConv.tagLLMSpanRequest(
+ span,
+ InstrumentationSemConv.PROVIDER_NAME_ANTHROPIC,
+ bufferedRequest.baseUrl() != null ? bufferedRequest.baseUrl() : "",
+ bufferedRequest.pathSegments(),
+ bufferedRequest.method().name(),
+ buffered.bodyJson(),
+ null,
+ headersAsMap(bufferedRequest.headers()));
+
+ var response = underlying.execute(bufferedRequest, requestOptions);
+ return new TeeingStreamHttpResponse(response, span, tracer, spanStartNanos);
+ } catch (Throwable failure) {
+ failSpanQuietly(span, failure);
+ throw failure;
+ }
+ }
+
+ @Override
+ public @Nonnull CompletableFuture executeAsync(
+ @Nonnull HttpRequest httpRequest, @Nonnull RequestOptions requestOptions) {
+ var extracted = extractCallerContext(httpRequest);
+ if (!isLlmRequest(extracted.request())) {
+ return executeHttpAsync(extracted, requestOptions);
+ }
+ long spanStartNanos = System.nanoTime();
+ var span = startSpan(InstrumentationSemConv.UNSET_LLM_SPAN_NAME, extracted.callerContext());
+ try {
+ var buffered = bufferRequestBody(extracted.request());
+ var bufferedRequest = buffered.request();
+ InstrumentationSemConv.tagLLMSpanRequest(
+ span,
+ InstrumentationSemConv.PROVIDER_NAME_ANTHROPIC,
+ bufferedRequest.baseUrl() != null ? bufferedRequest.baseUrl() : "",
+ bufferedRequest.pathSegments(),
+ bufferedRequest.method().name(),
+ buffered.bodyJson(),
+ null,
+ headersAsMap(bufferedRequest.headers()));
+ var result = new CompletableFuture();
+ underlying
+ .executeAsync(bufferedRequest, requestOptions)
+ .whenComplete(
+ // Every path must settle `result`: an exception escaping this
+ // callback would be swallowed by the discarded whenComplete future
+ // and leave the caller waiting forever.
+ (response, error) -> {
+ if (error != null) {
+ failSpanQuietly(span, error);
+ result.completeExceptionally(error);
+ return;
+ }
+ TeeingStreamHttpResponse wrapped;
+ try {
+ wrapped =
+ new TeeingStreamHttpResponse(
+ response, span, tracer, spanStartNanos);
+ } catch (Throwable failure) {
+ failSpanQuietly(span, failure);
+ try {
+ response.close();
+ } catch (Throwable closeFailure) {
+ if (closeFailure != failure) {
+ failure.addSuppressed(closeFailure);
+ }
+ }
+ result.completeExceptionally(failure);
+ return;
+ }
+ if (!result.complete(wrapped)) {
+ wrapped.close();
+ }
+ });
+ return result;
+ } catch (Throwable failure) {
+ failSpanQuietly(span, failure);
+ throw failure;
+ }
+ }
+
+ /** Ends failed requests, including linkage errors, without masking the original throwable. */
+ private static void failSpanQuietly(Span span, Throwable failure) {
+ try {
+ InstrumentationSemConv.tagLLMSpanResponse(span, failure);
+ } catch (Throwable taggingFailure) {
+ log.error("Could not tag span with request failure", taggingFailure);
+ }
+ try {
+ span.end();
+ } catch (Throwable endFailure) {
+ log.error("Could not end span", endFailure);
+ }
+ }
+
+ /**
+ * Only {@code POST .../messages} and the legacy {@code POST .../complete} produce model output
+ * and get the full LLM treatment. Everything else ({@code messages/batches}, {@code
+ * messages/count_tokens}, models, files, ...) gets a plain {@code anthropic.http} span with the
+ * body left untouched.
+ */
+ private static final Set LLM_ENDPOINTS = Set.of("messages", "complete");
+
+ private static boolean isLlmRequest(HttpRequest request) {
+ var path = request.pathSegments();
+ return request.method() == HttpMethod.POST
+ && !path.isEmpty()
+ && LLM_ENDPOINTS.contains(path.get(path.size() - 1));
+ }
+
+ private HttpResponse executeHttp(ExtractedRequest extracted, RequestOptions requestOptions) {
+ var span = startSpan("anthropic.http", extracted.callerContext());
+ try (var ignored = span.makeCurrent()) {
+ var response = underlying.execute(extracted.request(), requestOptions);
+ InstrumentationSemConv.tagHttpSpanResponse(span, response.statusCode());
+ return response;
+ } catch (Exception e) {
+ InstrumentationSemConv.tagLLMSpanResponse(span, e);
+ throw e;
+ } finally {
+ span.end();
+ }
+ }
+
+ private CompletableFuture executeHttpAsync(
+ ExtractedRequest extracted, RequestOptions requestOptions) {
+ var span = startSpan("anthropic.http", extracted.callerContext());
+ try (var ignored = span.makeCurrent()) {
+ var result = new CompletableFuture();
+ underlying
+ .executeAsync(extracted.request(), requestOptions)
+ .whenComplete(
+ (response, error) -> {
+ try {
+ try {
+ if (error != null) {
+ InstrumentationSemConv.tagLLMSpanResponse(span, error);
+ } else {
+ InstrumentationSemConv.tagHttpSpanResponse(
+ span, response.statusCode());
+ }
+ } finally {
+ span.end();
+ }
+ } catch (Throwable failure) {
+ result.completeExceptionally(error != null ? error : failure);
+ if (response != null) {
+ response.close();
+ }
+ return;
+ }
+ if (error != null) {
+ result.completeExceptionally(error);
+ } else if (!result.complete(response)) {
+ // Cancellation does not cancel the transport; release a
+ // response
+ // that can no longer be delivered to its caller.
+ response.close();
+ }
+ });
+ return result;
+ } catch (Exception e) {
+ InstrumentationSemConv.tagLLMSpanResponse(span, e);
+ span.end();
+ throw e;
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Request buffering — identical pattern to OpenAI TracingHttpClient
+ // -------------------------------------------------------------------------
+
+ /**
+ * Reads the request body once into memory, so it can be both recorded on the span and sent. The
+ * bytes are copied exactly once: the decoded JSON and the replacement body both read the same
+ * backing array.
+ */
+ private static BufferedRequest bufferRequestBody(HttpRequest request) {
+ // anthropic-java 3.x: HttpRequest.body() returns Optional (was nullable in 2.x)
+ HttpRequestBody originalBody = request.body().orElse(null);
+ if (originalBody == null) {
+ return new BufferedRequest(request, null);
+ }
+ var sink = new ByteSink(originalBody.contentLength());
+ originalBody.writeTo(sink);
+ var bufferedBody = new BufferedBody(sink.array(), sink.size(), originalBody.contentType());
+ return new BufferedRequest(
+ request.toBuilder().body(bufferedBody).build(),
+ sink.toString(StandardCharsets.UTF_8));
+ }
+
+ private record BufferedRequest(HttpRequest request, @Nullable String bodyJson) {}
+
+ /** {@link ByteArrayOutputStream} that exposes its backing array instead of copying it. */
+ private static final class ByteSink extends ByteArrayOutputStream {
+ ByteSink(long sizeHint) {
+ super(sizeHint > 0 && sizeHint < Integer.MAX_VALUE - 8 ? (int) sizeHint : 32);
+ }
+
+ byte[] array() {
+ return buf;
+ }
+ }
+
+ /** Repeatable body over the first {@code length} bytes of {@code bytes}. */
+ private static final class BufferedBody implements HttpRequestBody {
+ private final byte[] bytes;
+ private final int length;
+ private final String contentType;
+
+ BufferedBody(byte[] bytes, int length, String contentType) {
+ this.bytes = bytes;
+ this.length = length;
+ this.contentType = contentType;
+ }
+
+ @Override
+ public void writeTo(OutputStream outputStream) {
+ try {
+ outputStream.write(bytes, 0, length);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public String contentType() {
+ return contentType;
+ }
+
+ @Override
+ public long contentLength() {
+ return length;
+ }
+
+ @Override
+ public boolean repeatable() {
+ return true;
+ }
+
+ @Override
+ public void close() {}
+ }
+
+ // -------------------------------------------------------------------------
+ // Response tee — identical pattern to OpenAI TracingHttpClient
+ // -------------------------------------------------------------------------
+
+ /**
+ * Tees the response body so bytes are accumulated as the caller reads, then on close tags the
+ * span by auto-detecting SSE vs plain JSON from the first non-empty line.
+ */
+ private static final class TeeingStreamHttpResponse implements HttpResponse {
+ private final HttpResponse delegate;
+ private final Span span;
+ private final Tracer tracer;
+ private final long spanStartNanos;
+ private final AtomicLong timeToFirstTokenNanos = new AtomicLong();
+ private final ByteArrayOutputStream teeBuffer = new ByteArrayOutputStream();
+ private final InputStream teeStream;
+
+ TeeingStreamHttpResponse(
+ HttpResponse delegate, Span span, Tracer tracer, long spanStartNanos) {
+ this.delegate = delegate;
+ this.span = span;
+ this.tracer = tracer;
+ this.spanStartNanos = spanStartNanos;
+ this.teeStream =
+ new TeeInputStream(
+ delegate.body(), teeBuffer, this::onFirstByte, this::onStreamClosed);
+ }
+
+ private void onFirstByte() {
+ timeToFirstTokenNanos.set(System.nanoTime() - spanStartNanos);
+ }
+
+ private void onStreamClosed(@Nullable IOException failure) {
+ try {
+ if (failure != null) {
+ InstrumentationSemConv.tagLLMSpanResponse(span, failure);
+ }
+ byte[] bytes;
+ synchronized (teeBuffer) {
+ bytes = teeBuffer.toByteArray();
+ }
+
+ // Recorded before tagging: the anthropic sdk raises above this layer, so the
+ // error status is ours alone to set, and losing it to a body-parsing problem is
+ // worse than losing the parsed output.
+ // Anything outside 2xx, not just 4xx/5xx: both vendor SDKs treat success as
+ // exactly 200..299, so a final 3xx that the http client did not follow (a 304, or
+ // a redirect with no usable Location) is raised to the caller as an
+ // UnexpectedStatusCodeException and must mark the span failed too.
+ int statusCode = delegate.statusCode();
+ if (statusCode < 200 || statusCode >= 300) {
+ InstrumentationSemConv.tagLLMSpanHttpError(
+ span, statusCode, new String(bytes, StandardCharsets.UTF_8));
+ }
+
+ // Wire-format bookkeeping lives in ResponseReassembler; this hands semconv
+ // everything the response carried in one flat call. A null body (empty or
+ // unparseable response) still tags the headers.
+ // tagLLMSpanResponse also emits child spans for any server-side tool calls (web
+ // search, etc.) nested under the LLM span while it is still live.
+ try {
+ var reassembled =
+ ResponseReassembler.reassemble(bytes, timeToFirstTokenNanos.get());
+ if (reassembled.error() != null) {
+ InstrumentationSemConv.tagLLMSpanResponse(
+ span,
+ com.anthropic.errors.SseException.builder()
+ .statusCode(statusCode)
+ .headers(delegate.headers())
+ .body(reassembled.error())
+ .build());
+ }
+ InstrumentationSemConv.tagLLMSpanResponse(
+ tracer,
+ span,
+ InstrumentationSemConv.PROVIDER_NAME_ANTHROPIC,
+ reassembled.body(),
+ reassembled.timeToFirstTokenNanos(),
+ headersAsMap(delegate.headers()));
+ } catch (Exception e) {
+ // Observability must never change the response behavior seen by the caller.
+ log.error("Could not tag span from response buffer", e);
+ }
+ } finally {
+ span.end();
+ }
+ }
+
+ @Override
+ public int statusCode() {
+ return delegate.statusCode();
+ }
+
+ @Override
+ public com.anthropic.core.http.Headers headers() {
+ return delegate.headers();
+ }
+
+ @Override
+ public InputStream body() {
+ return teeStream;
+ }
+
+ @Override
+ public void close() {
+ try {
+ teeStream.close();
+ } catch (java.io.IOException ignored) {
+ }
+ delegate.close();
+ }
+ }
+
+ private static final class TeeInputStream extends InputStream {
+ private final InputStream source;
+ private final OutputStream sink;
+ private final Runnable onFirstByte;
+ private final Consumer onClose;
+ private final AtomicBoolean firstByteSeen = new AtomicBoolean(false);
+ private final AtomicBoolean closed = new AtomicBoolean(false);
+
+ TeeInputStream(
+ InputStream source,
+ OutputStream sink,
+ Runnable onFirstByte,
+ Consumer onClose) {
+ this.source = source;
+ this.sink = sink;
+ this.onFirstByte = onFirstByte;
+ this.onClose = onClose;
+ }
+
+ @Override
+ public int read() throws java.io.IOException {
+ try {
+ int b = source.read();
+ if (b == -1) {
+ notifyClosed(null);
+ } else {
+ notifyFirstByte();
+ sink.write(b);
+ }
+ return b;
+ } catch (IOException failure) {
+ notifyReadFailed(failure);
+ throw failure;
+ }
+ }
+
+ @Override
+ public int read(byte[] buf, int off, int len) throws java.io.IOException {
+ try {
+ int n = source.read(buf, off, len);
+ if (n == -1) {
+ notifyClosed(null);
+ } else if (n > 0) {
+ notifyFirstByte();
+ sink.write(buf, off, n);
+ }
+ return n;
+ } catch (IOException failure) {
+ notifyReadFailed(failure);
+ throw failure;
+ }
+ }
+
+ @Override
+ public void close() throws java.io.IOException {
+ notifyClosed(null);
+ source.close();
+ }
+
+ private void notifyFirstByte() {
+ if (!firstByteSeen.compareAndExchange(false, true)) {
+ onFirstByte.run();
+ }
+ }
+
+ private void notifyReadFailed(IOException failure) {
+ try {
+ notifyClosed(failure);
+ } catch (Throwable taggingFailure) {
+ log.error("Could not tag span from failed response stream", taggingFailure);
+ }
+ }
+
+ private void notifyClosed(@Nullable IOException failure) {
+ if (!closed.compareAndExchange(false, true)) {
+ onClose.accept(failure);
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ // Span tagging from buffered bytes
+ // -------------------------------------------------------------------------
+
+ /**
+ * Adapts the anthropic sdk's {@code Headers} to the vendor-neutral shape {@link
+ * InstrumentationSemConv} consumes. Returns an empty map on failure so a header-shape change
+ * can never take down the tagging that follows it.
+ */
+ private static Map> headersAsMap(
+ @Nullable com.anthropic.core.http.Headers headers) {
+ if (headers == null) {
+ return Map.of();
+ }
+ try {
+ var map = new HashMap>();
+ for (String name : headers.names()) {
+ map.put(name, headers.values(name));
+ }
+ return map;
+ } catch (Exception e) {
+ log.debug("could not read headers", e);
+ return Map.of();
+ }
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/auto/AnthropicInstrumentationModule.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/auto/AnthropicInstrumentationModule.java
new file mode 100644
index 00000000..8e5670cc
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/main/java/dev/braintrust/instrumentation/anthropic/v3_0_0/auto/AnthropicInstrumentationModule.java
@@ -0,0 +1,118 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0.auto;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+
+import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.AnthropicClientAsync;
+import com.google.auto.service.AutoService;
+import dev.braintrust.instrumentation.InstrumentationModule;
+import dev.braintrust.instrumentation.TypeInstrumentation;
+import dev.braintrust.instrumentation.TypeTransformer;
+import dev.braintrust.instrumentation.anthropic.v3_0_0.BraintrustAnthropic;
+import dev.braintrust.instrumentation.muzzle.ClassLoaderMatchers;
+import io.opentelemetry.api.GlobalOpenTelemetry;
+import java.util.List;
+import net.bytebuddy.asm.Advice;
+import net.bytebuddy.description.type.TypeDescription;
+import net.bytebuddy.implementation.bytecode.assign.Assigner;
+import net.bytebuddy.matcher.ElementMatcher;
+
+@AutoService(InstrumentationModule.class)
+public class AnthropicInstrumentationModule extends InstrumentationModule {
+ private static final String MANUAL_INSTRUMENTATION_PACKAGE =
+ "dev.braintrust.instrumentation.anthropic.v3_0_0.";
+
+ public AnthropicInstrumentationModule() {
+ super("anthropic_3_0_0");
+ }
+
+ /**
+ * Gates this module to anthropic-java >= 3.0.0, keyed on {@code AssistantMessageParam} (new in
+ * 3.0.0). The {@code anthropic_2_2_0} module's matcher excludes the same class, so exactly one
+ * module applies for any given anthropic-java version.
+ */
+ @Override
+ public ElementMatcher classLoaderMatcher() {
+ return ClassLoaderMatchers.hasClassNamed(
+ "com.anthropic.models.messages.AssistantMessageParam");
+ }
+
+ @Override
+ public List getHelperClassNames() {
+ return List.of(
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$BufferedRequest",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$ByteSink",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$BufferedBody",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$TeeingStreamHttpResponse",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$TeeInputStream",
+ MANUAL_INSTRUMENTATION_PACKAGE + "TracingHttpClient$ExtractedRequest",
+ MANUAL_INSTRUMENTATION_PACKAGE + "BraintrustAnthropic",
+ MANUAL_INSTRUMENTATION_PACKAGE + "ContextCapturingProxy",
+ MANUAL_INSTRUMENTATION_PACKAGE + "ResponseReassembler",
+ MANUAL_INSTRUMENTATION_PACKAGE + "ResponseReassembler$Result",
+ "dev.braintrust.json.BraintrustJsonMapper",
+ "dev.braintrust.instrumentation.InstrumentationSemConv");
+ }
+
+ @Override
+ public List typeInstrumentations() {
+ return List.of(
+ new AnthropicOkHttpClientBuilderInstrumentation(),
+ new AnthropicOkHttpClientAsyncBuilderInstrumentation());
+ }
+
+ public static class AnthropicOkHttpClientBuilderInstrumentation implements TypeInstrumentation {
+ @Override
+ public ElementMatcher typeMatcher() {
+ return named("com.anthropic.client.okhttp.AnthropicOkHttpClient$Builder");
+ }
+
+ @Override
+ public void transform(TypeTransformer transformer) {
+ transformer.applyAdviceToMethod(
+ named("build").and(takesArguments(0)),
+ AnthropicInstrumentationModule.class.getName()
+ + "$AnthropicOkHttpClientBuilderAdvice");
+ }
+ }
+
+ private static class AnthropicOkHttpClientBuilderAdvice {
+ @Advice.OnMethodExit
+ public static void build(
+ @Advice.Return(readOnly = false, typing = Assigner.Typing.DYNAMIC)
+ Object returnedObject) {
+ returnedObject =
+ BraintrustAnthropic.wrap(
+ GlobalOpenTelemetry.get(), (AnthropicClient) returnedObject);
+ }
+ }
+
+ public static class AnthropicOkHttpClientAsyncBuilderInstrumentation
+ implements TypeInstrumentation {
+ @Override
+ public ElementMatcher typeMatcher() {
+ return named("com.anthropic.client.okhttp.AnthropicOkHttpClientAsync$Builder");
+ }
+
+ @Override
+ public void transform(TypeTransformer transformer) {
+ transformer.applyAdviceToMethod(
+ named("build").and(takesArguments(0)),
+ AnthropicInstrumentationModule.class.getName()
+ + "$AnthropicOkHttpClientAsyncBuilderAdvice");
+ }
+ }
+
+ private static class AnthropicOkHttpClientAsyncBuilderAdvice {
+ @Advice.OnMethodExit
+ public static void build(
+ @Advice.Return(readOnly = false, typing = Assigner.Typing.DYNAMIC)
+ Object returnedObject) {
+ returnedObject =
+ BraintrustAnthropic.wrap(
+ GlobalOpenTelemetry.get(), (AnthropicClientAsync) returnedObject);
+ }
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicPromptCachingTest.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicPromptCachingTest.java
new file mode 100644
index 00000000..0dac7b66
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicPromptCachingTest.java
@@ -0,0 +1,189 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.okhttp.AnthropicOkHttpClient;
+import com.anthropic.core.JsonValue;
+import com.anthropic.models.messages.CacheControlEphemeral;
+import com.anthropic.models.messages.MessageCreateParams;
+import com.anthropic.models.messages.TextBlockParam;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import dev.braintrust.TestHarness;
+import dev.braintrust.instrumentation.Instrumenter;
+import io.opentelemetry.api.common.AttributeKey;
+import java.util.List;
+import java.util.UUID;
+import lombok.SneakyThrows;
+import net.bytebuddy.agent.ByteBuddyAgent;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests that prompt caching metrics (per-TTL breakdown) are correctly extracted from Anthropic API
+ * responses and attached to spans.
+ *
+ * Uses a cache-buster nonce in the system prompt to guarantee cache misses, ensuring {@code
+ * cache_creation_input_tokens} is always positive. In VCR replay mode the nonce is a fixed string
+ * so cassette matching still works.
+ */
+public class BraintrustAnthropicPromptCachingTest {
+ private static final String TEST_MODEL = "claude-sonnet-4-5-20250929";
+ private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+
+ /**
+ * Nonce injected into system prompts to bust Anthropic's server-side prompt cache. Random UUID
+ * when running live ({@code VCR_MODE=off}), fixed string otherwise so VCR cassettes match.
+ */
+ private static final String VCR_NONCE;
+
+ static {
+ String vcrMode = System.getenv().getOrDefault("VCR_MODE", "replay").toUpperCase();
+ VCR_NONCE = "OFF".equals(vcrMode) ? UUID.randomUUID().toString() : "vcr-mode";
+ }
+
+ @BeforeAll
+ public static void beforeAll() {
+ var instrumentation = ByteBuddyAgent.install();
+ Instrumenter.install(
+ instrumentation, BraintrustAnthropicPromptCachingTest.class.getClassLoader());
+ }
+
+ private TestHarness testHarness;
+
+ @BeforeEach
+ void beforeEach() {
+ testHarness = TestHarness.setup();
+ }
+
+ /**
+ * Sends a single request with two system content blocks — one cached at 5m TTL and one at 1h
+ * TTL — and verifies that the per-TTL prompt cache creation metrics are present on the span.
+ */
+ @Test
+ @SneakyThrows
+ void testPromptCachingDualTtl() {
+ AnthropicClient client =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ // 1h TTL block — must come before 5m (Anthropic requires descending TTL order).
+ // Requires the extended-cache-ttl beta header.
+ // The text must exceed Claude Sonnet's minimum cacheable size (~1024 tokens / ~4000 chars).
+ CacheControlEphemeral cacheControl1h =
+ CacheControlEphemeral.builder()
+ .putAdditionalProperty("ttl", JsonValue.from("1h"))
+ .build();
+
+ TextBlockParam systemBlock1h =
+ TextBlockParam.builder()
+ .text(
+ buildPaddedSystemText(
+ "1h-block",
+ "Reference: capitals include Paris, Berlin, Rome, Madrid,"
+ + " Lisbon."))
+ .cacheControl(cacheControl1h)
+ .build();
+
+ // 5m TTL block — default ephemeral cache.
+ CacheControlEphemeral cacheControl5m =
+ CacheControlEphemeral.builder()
+ .putAdditionalProperty("ttl", JsonValue.from("5m"))
+ .build();
+
+ TextBlockParam systemBlock5m =
+ TextBlockParam.builder()
+ .text(
+ buildPaddedSystemText(
+ "5m-block",
+ "You are a helpful geography assistant. Answer in one"
+ + " sentence."))
+ .cacheControl(cacheControl5m)
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .systemOfTextBlockParams(List.of(systemBlock1h, systemBlock5m))
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(128)
+ .putAdditionalHeader("anthropic-beta", "extended-cache-ttl-2025-04-11")
+ .build();
+
+ var response = client.messages().create(request);
+
+ // Basic response sanity
+ assertNotNull(response);
+ assertNotNull(response.id());
+ var contentBlock = response.content().get(0);
+ assertTrue(contentBlock.isText());
+ assertFalse(contentBlock.asText().text().isEmpty());
+
+ // Verify span metrics
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson, "metrics should be present");
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+
+ // Standard token metrics
+ assertPositive(metrics, "prompt_tokens");
+ assertPositive(metrics, "completion_tokens");
+ assertPositive(metrics, "tokens");
+
+ // Per-TTL breakdown — both should be positive on a cold cache
+ assertFalse(
+ metrics.has("prompt_cache_creation_tokens"),
+ "anthropic cache tokens must be set INSTEAD of the aggregate meteric");
+ assertPositive(metrics, "prompt_cache_creation_5m_tokens");
+ assertPositive(metrics, "prompt_cache_creation_1h_tokens");
+ assertEquals(
+ response.usage().cacheCreationInputTokens().get(),
+ (metrics.get("prompt_cache_creation_5m_tokens").intValue()
+ + metrics.get("prompt_cache_creation_1h_tokens").intValue()),
+ "ttl tokens should sum to total token count");
+
+ // Cache read may be 0 on cold cache, but should be present and non-negative
+ assertTrue(metrics.has("prompt_cached_tokens"), "prompt_cached_tokens should be present");
+ assertTrue(
+ metrics.get("prompt_cached_tokens").asDouble() >= 0,
+ "prompt_cached_tokens should be non-negative");
+ }
+
+ private static void assertPositive(JsonNode metrics, String field) {
+ assertTrue(metrics.has(field), field + " should be present");
+ assertTrue(
+ metrics.get(field).isNumber(),
+ field + " should be a number, got: " + metrics.get(field));
+ assertTrue(
+ metrics.get(field).asDouble() > 0,
+ field + " should be positive, got: " + metrics.get(field).asDouble());
+ }
+
+ /**
+ * Build a system prompt text padded to exceed the minimum cacheable size (~4000 ASCII chars).
+ * Includes the VCR nonce and a block identifier for cache isolation.
+ */
+ private String buildPaddedSystemText(String blockId, String coreInstruction) {
+ StringBuilder sb = new StringBuilder();
+ sb.append("[cache-buster: ").append(blockId).append(" ").append(VCR_NONCE).append("]\n");
+ sb.append(coreInstruction).append("\n\n");
+
+ // Pad with numbered guidelines to exceed the token minimum.
+ for (int i = 1; i <= 80; i++) {
+ sb.append(i)
+ .append(". This is guideline number ")
+ .append(i)
+ .append(". It exists to pad the system prompt past the minimum cacheable ")
+ .append("token threshold for Claude Sonnet models. Each guideline adds ")
+ .append("approximately fifty tokens of padding text to the prompt.\n");
+ }
+ return sb.toString();
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicServerSideSpansTest.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicServerSideSpansTest.java
new file mode 100644
index 00000000..fac7f99f
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicServerSideSpansTest.java
@@ -0,0 +1,136 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.okhttp.AnthropicOkHttpClient;
+import com.anthropic.models.messages.MessageCreateParams;
+import com.anthropic.models.messages.Model;
+import com.anthropic.models.messages.WebSearchTool20250305;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import dev.braintrust.TestHarness;
+import dev.braintrust.instrumentation.Instrumenter;
+import io.opentelemetry.api.common.AttributeKey;
+import io.opentelemetry.sdk.trace.data.SpanData;
+import java.util.List;
+import lombok.SneakyThrows;
+import net.bytebuddy.agent.ByteBuddyAgent;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Verifies that Anthropic server-side tool calls are captured as both a cost metric on the LLM span
+ * and a child {@code type:"tool"} span parented to it, giving each call its own cost/latency
+ * visibility on the trace timeline. Web search ({@code server_tool_use_web_search_requests}) is the
+ * case exercised here.
+ */
+public class BraintrustAnthropicServerSideSpansTest {
+ private static final String TEST_MODEL = "claude-sonnet-4-5-20250929";
+ private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+ private static final AttributeKey SPAN_ATTRIBUTES =
+ AttributeKey.stringKey("braintrust.span_attributes");
+ private static final AttributeKey METADATA =
+ AttributeKey.stringKey("braintrust.metadata");
+ private static final AttributeKey METRICS =
+ AttributeKey.stringKey("braintrust.metrics");
+
+ @BeforeAll
+ public static void beforeAll() {
+ var instrumentation = ByteBuddyAgent.install();
+ Instrumenter.install(
+ instrumentation, BraintrustAnthropicServerSideSpansTest.class.getClassLoader());
+ }
+
+ private TestHarness testHarness;
+
+ @BeforeEach
+ void beforeEach() {
+ testHarness = TestHarness.setup();
+ }
+
+ private static MessageCreateParams webSearchRequest() {
+ return MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .maxTokens(1024)
+ .addUserMessage(
+ "Search the web for one recent AI news headline and answer in one"
+ + " sentence.")
+ .addTool(WebSearchTool20250305.builder().maxUses(3).build())
+ .build();
+ }
+
+ @Test
+ @SneakyThrows
+ void testWebSearch() {
+ AnthropicClient client =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var response = client.messages().create(webSearchRequest());
+ assertNotNull(response);
+
+ assertWebSearch(testHarness.awaitExportedSpans(2));
+ }
+
+ @Test
+ @SneakyThrows
+ void testWebSearchStreaming() {
+ AnthropicClient client =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ try (var stream = client.messages().createStreaming(webSearchRequest())) {
+ stream.stream().forEach(event -> {});
+ }
+
+ assertWebSearch(testHarness.awaitExportedSpans(2));
+ }
+
+ @SneakyThrows
+ private static void assertWebSearch(List spans) {
+ var llmSpans = spans.stream().filter(s -> isType(s, "llm")).toList();
+ assertEquals(1, llmSpans.size(), "expected a single LLM span");
+ var llm = llmSpans.get(0);
+
+ // Cost metric on the LLM span.
+ JsonNode metrics = JSON_MAPPER.readTree(llm.getAttributes().get(METRICS));
+ assertTrue(
+ metrics.has("server_tool_use_web_search_requests"),
+ "expected server_tool_use_web_search_requests metric, got: " + metrics);
+ assertTrue(metrics.get("server_tool_use_web_search_requests").asDouble() >= 1.0);
+
+ // At least one web_search tool span, parented to the LLM span.
+ var toolSpans =
+ spans.stream()
+ .filter(s -> isType(s, "tool"))
+ .filter(s -> "web_search".equals(s.getName()))
+ .toList();
+ assertFalse(
+ toolSpans.isEmpty(),
+ "expected at least one web_search tool span, got: "
+ + spans.stream().map(SpanData::getName).toList());
+
+ for (var tool : toolSpans) {
+ assertEquals(
+ llm.getSpanId(),
+ tool.getParentSpanId(),
+ "web_search tool span must be a child of the LLM span");
+ JsonNode metadata = JSON_MAPPER.readTree(tool.getAttributes().get(METADATA));
+ assertEquals("server_tool_use", metadata.path("tool_call_type").asText());
+ assertEquals("web_search_tool_result", metadata.path("tool_result_type").asText());
+ assertFalse(metadata.path("tool_use_id").asText().isEmpty());
+ }
+ }
+
+ @SneakyThrows
+ private static boolean isType(SpanData span, String type) {
+ String attr = span.getAttributes().get(SPAN_ATTRIBUTES);
+ return attr != null && type.equals(JSON_MAPPER.readTree(attr).path("type").asText());
+ }
+}
diff --git a/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicTest.java b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicTest.java
new file mode 100644
index 00000000..e99566c3
--- /dev/null
+++ b/braintrust-sdk/instrumentation/anthropic_3_0_0/src/test/java/dev/braintrust/instrumentation/anthropic/v3_0_0/BraintrustAnthropicTest.java
@@ -0,0 +1,1655 @@
+package dev.braintrust.instrumentation.anthropic.v3_0_0;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.AnthropicClientImpl;
+import com.anthropic.client.okhttp.AnthropicOkHttpClient;
+import com.anthropic.core.ClientOptions;
+import com.anthropic.core.RequestOptions;
+import com.anthropic.core.http.Headers;
+import com.anthropic.core.http.HttpMethod;
+import com.anthropic.core.http.HttpRequest;
+import com.anthropic.core.http.HttpRequestBody;
+import com.anthropic.core.http.HttpResponse;
+import com.anthropic.errors.SseException;
+import com.anthropic.models.messages.MessageCreateParams;
+import com.anthropic.models.messages.Model;
+import com.anthropic.models.messages.batches.BatchListParams;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import dev.braintrust.TestHarness;
+import dev.braintrust.instrumentation.Instrumenter;
+import io.opentelemetry.api.common.AttributeKey;
+import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.api.trace.StatusCode;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import lombok.SneakyThrows;
+import net.bytebuddy.agent.ByteBuddyAgent;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
+import org.junit.jupiter.params.provider.ValueSource;
+
+public class BraintrustAnthropicTest {
+ private static final String TEST_MODEL = "claude-haiku-4-5";
+ private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+
+ @BeforeAll
+ public static void beforeAll() {
+ var instrumentation = ByteBuddyAgent.install();
+ Instrumenter.install(instrumentation, BraintrustAnthropicTest.class.getClassLoader());
+ }
+
+ private TestHarness testHarness;
+
+ @BeforeEach
+ void beforeEach() {
+ testHarness = TestHarness.setup();
+ }
+
+ @SneakyThrows
+ private static void assertInstrumentationOrigin(io.opentelemetry.sdk.trace.data.SpanData span) {
+ JsonNode instrumentation =
+ JSON_MAPPER
+ .readTree(
+ span.getAttributes()
+ .get(AttributeKey.stringKey("braintrust.context_json")))
+ .path("span_origin")
+ .path("instrumentation");
+ assertEquals("anthropic", instrumentation.path("name").asText());
+ assertEquals(
+ System.getProperty("braintrust.muzzle.minimumVersion"),
+ instrumentation.path("version").asText(),
+ "span origin version must match the minimum passing muzzle version");
+ }
+
+ @Test
+ @SneakyThrows
+ void testBatchListAsync() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+ var parent =
+ testHarness
+ .openTelemetry()
+ .getTracer("batch-test")
+ .spanBuilder("parent")
+ .startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ var page =
+ anthropicClient
+ .async()
+ .messages()
+ .batches()
+ .list(BatchListParams.builder().limit(1L).build())
+ .get(5, TimeUnit.MINUTES);
+ assertTrue(page.response().data().size() <= 1);
+ if (page.response().hasMore()) {
+ assertEquals(1, page.response().data().size());
+ }
+ } finally {
+ parent.end();
+ }
+ assertHttpSpan(parent, false, false);
+ for (var span : testHarness.awaitExportedSpans()) {
+ assertEquals(parent.getSpanContext().getTraceId(), span.getTraceId());
+ }
+ }
+
+ @Test
+ @SneakyThrows
+ void testWrapAnthropic() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ var response = anthropicClient.messages().create(request);
+
+ // Verify the response
+ assertNotNull(response);
+ assertNotNull(response.id());
+ var contentBlock = response.content().get(0);
+ assertTrue(contentBlock.isText());
+ assertNotNull(contentBlock.asText().text());
+
+ // Verify spans were exported
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertInstrumentationOrigin(span);
+
+ assertFalse(span.getName().isEmpty(), "span name should be non-empty");
+
+ // Verify span_attributes
+ String spanAttributesJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.span_attributes"));
+ assertNotNull(spanAttributesJson);
+ JsonNode spanAttributes = JSON_MAPPER.readTree(spanAttributesJson);
+ assertEquals("llm", spanAttributes.get("type").asText());
+
+ // Verify metadata
+ String metadataJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metadata"));
+ assertNotNull(metadataJson);
+ JsonNode metadata = JSON_MAPPER.readTree(metadataJson);
+ assertEquals("anthropic", metadata.get("provider").asText());
+ assertTrue(
+ metadata.get("model").asText().startsWith("claude-haiku-4"),
+ "model should start with claude-haiku-4");
+
+ // Verify input
+ String inputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.input_json"));
+ assertNotNull(inputJson);
+ JsonNode input = JSON_MAPPER.readTree(inputJson);
+ assertTrue(input.isArray());
+ assertTrue(input.size() > 0);
+
+ // Verify output — full Message object
+ String outputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.output_json"));
+ assertNotNull(outputJson);
+ JsonNode outputMessage = JSON_MAPPER.readTree(outputJson);
+ assertNotNull(outputMessage.get("id"));
+ assertEquals("message", outputMessage.get("type").asText());
+ assertEquals("assistant", outputMessage.get("role").asText());
+ assertNotNull(outputMessage.get("content").get(0).get("text"));
+ assertTrue(outputMessage.get("usage").get("output_tokens").asInt() > 0);
+ assertTrue(outputMessage.get("usage").get("input_tokens").asInt() > 0);
+
+ // Verify metrics — tokens; non-streaming should NOT have time_to_first_token
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson);
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+ assertTrue(metrics.has("prompt_tokens"), "prompt_tokens should be present");
+ assertTrue(metrics.has("completion_tokens"), "completion_tokens should be present");
+ assertTrue(metrics.has("tokens"), "tokens should be present");
+ assertFalse(
+ metrics.has("time_to_first_token"),
+ "time_to_first_token should not be present for non-streaming");
+ }
+
+ @Test
+ @SneakyThrows
+ void testWrapAnthropicStreaming() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ StringBuilder fullResponse = new StringBuilder();
+ try (var stream = anthropicClient.messages().createStreaming(request)) {
+ stream.stream()
+ .forEach(
+ event -> {
+ if (event.contentBlockDelta().isPresent()) {
+ var delta = event.contentBlockDelta().get().delta();
+ if (delta.text().isPresent()) {
+ fullResponse.append(delta.text().get().text());
+ }
+ }
+ });
+ }
+
+ assertFalse(fullResponse.toString().isEmpty());
+
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertInstrumentationOrigin(span);
+
+ assertFalse(span.getName().isEmpty(), "span name should be non-empty");
+
+ // Verify metadata
+ String metadataJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metadata"));
+ assertNotNull(metadataJson);
+ JsonNode metadata = JSON_MAPPER.readTree(metadataJson);
+ assertEquals("anthropic", metadata.get("provider").asText());
+
+ // Verify input
+ assertNotNull(span.getAttributes().get(AttributeKey.stringKey("braintrust.input_json")));
+
+ // Verify output — full Message object assembled from SSE stream
+ String outputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.output_json"));
+ assertNotNull(outputJson);
+ JsonNode outputMessage = JSON_MAPPER.readTree(outputJson);
+ assertEquals("assistant", outputMessage.get("role").asText());
+ assertFalse(
+ outputMessage.get("content").get(0).get("text").asText().isEmpty(),
+ "content should not be empty");
+
+ // Verify metrics — tokens and time_to_first_token
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson);
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+ assertTrue(metrics.has("prompt_tokens"), "prompt_tokens should be present");
+ assertTrue(metrics.has("completion_tokens"), "completion_tokens should be present");
+ assertTrue(metrics.has("time_to_first_token"), "time_to_first_token should be present");
+ assertTrue(
+ metrics.get("time_to_first_token").asDouble() >= 0.0,
+ "time_to_first_token should be non-negative");
+ }
+
+ /**
+ * Unlike {@link #testWrapAnthropicAsync()}, which derives the async view from an instrumented
+ * sync client via {@code .async()}, this builds {@code AnthropicOkHttpClientAsync} directly —
+ * exercising the async-builder auto-instrumentation hook.
+ *
+ * Also verifies context linking: the SDK dispatches async requests onto a worker pool, but
+ * the LLM span must still parent to the span that was current when the request was kicked off.
+ */
+ @Test
+ @SneakyThrows
+ void testDirectAsyncClientParenting() {
+ // Built OUTSIDE any span on purpose: parenting must come from the context at request
+ // time, not from the context at client-construction time.
+ com.anthropic.client.AnthropicClientAsync anthropicClient =
+ com.anthropic.client.okhttp.AnthropicOkHttpClientAsync.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ var parentSpan =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("foo").startSpan();
+ try (var ignored = parentSpan.makeCurrent()) {
+ var response = anthropicClient.messages().create(request).get();
+ assertNotNull(response);
+ assertNotNull(response.id());
+ } finally {
+ parentSpan.end();
+ }
+
+ var spans = testHarness.awaitExportedSpans(2);
+ assertEquals(2, spans.size());
+ var llmSpan =
+ spans.stream().filter(s -> !"foo".equals(s.getName())).findFirst().orElseThrow();
+ assertInstrumentationOrigin(llmSpan);
+ assertEquals(
+ parentSpan.getSpanContext().getTraceId(),
+ llmSpan.getTraceId(),
+ "async LLM span should be in the caller's trace");
+ assertEquals(
+ parentSpan.getSpanContext().getSpanId(),
+ llmSpan.getParentSpanId(),
+ "async LLM span should be a child of the span current at request time");
+ }
+
+ @Test
+ @SneakyThrows
+ void testWrapAnthropicAsync() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ var response = anthropicClient.async().messages().create(request).get();
+
+ assertNotNull(response);
+ assertNotNull(response.id());
+ var contentBlock = response.content().get(0);
+ assertTrue(contentBlock.isText());
+ assertNotNull(contentBlock.asText().text());
+
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+
+ assertFalse(span.getName().isEmpty(), "span name should be non-empty");
+
+ String spanAttributesJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.span_attributes"));
+ assertNotNull(spanAttributesJson);
+ JsonNode spanAttributes = JSON_MAPPER.readTree(spanAttributesJson);
+ assertEquals("llm", spanAttributes.get("type").asText());
+
+ String metadataJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metadata"));
+ assertNotNull(metadataJson);
+ JsonNode metadata = JSON_MAPPER.readTree(metadataJson);
+ assertEquals("anthropic", metadata.get("provider").asText());
+
+ String outputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.output_json"));
+ assertNotNull(outputJson);
+ JsonNode outputMessage = JSON_MAPPER.readTree(outputJson);
+ assertEquals("message", outputMessage.get("type").asText());
+ assertEquals("assistant", outputMessage.get("role").asText());
+ assertNotNull(outputMessage.get("content").get(0).get("text"));
+
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson);
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+ assertTrue(metrics.has("prompt_tokens"));
+ assertTrue(metrics.has("completion_tokens"));
+ assertTrue(metrics.has("tokens"));
+ assertFalse(
+ metrics.has("time_to_first_token"),
+ "time_to_first_token should not be present for non-streaming");
+ }
+
+ @Test
+ @SneakyThrows
+ void testWrapAnthropicAsyncStreaming() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ var fullResponse = new StringBuilder();
+ var stream = anthropicClient.async().messages().createStreaming(request);
+ stream.subscribe(
+ event -> {
+ if (event.contentBlockDelta().isPresent()) {
+ var delta = event.contentBlockDelta().get().delta();
+ if (delta.text().isPresent()) {
+ fullResponse.append(delta.text().get().text());
+ }
+ }
+ });
+ stream.onCompleteFuture().get(30, TimeUnit.SECONDS);
+
+ assertFalse(fullResponse.toString().isEmpty());
+
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+
+ assertFalse(span.getName().isEmpty(), "span name should be non-empty");
+
+ assertNotNull(span.getAttributes().get(AttributeKey.stringKey("braintrust.input_json")));
+
+ String outputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.output_json"));
+ assertNotNull(outputJson);
+ JsonNode outputMessage = JSON_MAPPER.readTree(outputJson);
+ assertEquals("assistant", outputMessage.get("role").asText());
+ assertFalse(outputMessage.get("content").get(0).get("text").asText().isEmpty());
+
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson);
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+ assertTrue(metrics.has("prompt_tokens"));
+ assertTrue(metrics.has("completion_tokens"));
+ assertTrue(
+ metrics.has("time_to_first_token"),
+ "time_to_first_token should be present for streaming");
+ assertTrue(metrics.get("time_to_first_token").asDouble() >= 0.0);
+ }
+
+ @Test
+ @SneakyThrows
+ void testWrapAnthropicBeta() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ com.anthropic.models.beta.messages.MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ var response = anthropicClient.beta().messages().create(request);
+
+ assertNotNull(response);
+ assertNotNull(response.id());
+ var contentBlock = response.content().get(0);
+ assertTrue(contentBlock.isText());
+ assertNotNull(contentBlock.asText().text());
+
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+
+ assertFalse(span.getName().isEmpty(), "span name should be non-empty");
+
+ // Verify span_attributes
+ String spanAttributesJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.span_attributes"));
+ assertNotNull(spanAttributesJson);
+ JsonNode spanAttributes = JSON_MAPPER.readTree(spanAttributesJson);
+ assertEquals("llm", spanAttributes.get("type").asText());
+
+ // Verify metadata
+ String metadataJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metadata"));
+ assertNotNull(metadataJson);
+ JsonNode metadata = JSON_MAPPER.readTree(metadataJson);
+ assertEquals("anthropic", metadata.get("provider").asText());
+ assertTrue(
+ metadata.get("model").asText().startsWith("claude-haiku-4"),
+ "model should start with claude-haiku-4");
+
+ // Verify input
+ String inputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.input_json"));
+ assertNotNull(inputJson);
+ JsonNode input = JSON_MAPPER.readTree(inputJson);
+ assertTrue(input.isArray());
+ assertTrue(input.size() > 0);
+
+ // Verify output — full BetaMessage object
+ String outputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.output_json"));
+ assertNotNull(outputJson);
+ JsonNode outputMessage = JSON_MAPPER.readTree(outputJson);
+ assertNotNull(outputMessage.get("id"));
+ assertEquals("message", outputMessage.get("type").asText());
+ assertEquals("assistant", outputMessage.get("role").asText());
+ assertNotNull(outputMessage.get("content").get(0).get("text"));
+ assertTrue(outputMessage.get("usage").get("output_tokens").asInt() > 0);
+ assertTrue(outputMessage.get("usage").get("input_tokens").asInt() > 0);
+
+ // Verify metrics — tokens; non-streaming should NOT have time_to_first_token
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson);
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+ assertTrue(metrics.has("prompt_tokens"), "prompt_tokens should be present");
+ assertTrue(metrics.has("completion_tokens"), "completion_tokens should be present");
+ assertTrue(metrics.has("tokens"), "tokens should be present");
+ assertFalse(
+ metrics.has("time_to_first_token"),
+ "time_to_first_token should not be present for non-streaming");
+ }
+
+ @Test
+ @SneakyThrows
+ void testWrapAnthropicBetaStreaming() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ com.anthropic.models.beta.messages.MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ StringBuilder fullResponse = new StringBuilder();
+ try (var stream = anthropicClient.beta().messages().createStreaming(request)) {
+ stream.stream()
+ .forEach(
+ event -> {
+ if (event.contentBlockDelta().isPresent()) {
+ var delta = event.contentBlockDelta().get();
+ if (delta.delta().text().isPresent()) {
+ fullResponse.append(delta.delta().text().get().text());
+ }
+ }
+ });
+ }
+
+ assertFalse(fullResponse.toString().isEmpty());
+
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+
+ assertFalse(span.getName().isEmpty(), "span name should be non-empty");
+
+ // Verify metadata
+ String metadataJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metadata"));
+ assertNotNull(metadataJson);
+ JsonNode metadata = JSON_MAPPER.readTree(metadataJson);
+ assertEquals("anthropic", metadata.get("provider").asText());
+
+ // Verify input
+ assertNotNull(span.getAttributes().get(AttributeKey.stringKey("braintrust.input_json")));
+
+ // Verify output — full BetaMessage object assembled from SSE stream
+ String outputJson =
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.output_json"));
+ assertNotNull(outputJson);
+ JsonNode outputMessage = JSON_MAPPER.readTree(outputJson);
+ assertEquals("assistant", outputMessage.get("role").asText());
+ assertFalse(
+ outputMessage.get("content").get(0).get("text").asText().isEmpty(),
+ "content should not be empty");
+
+ // Verify metrics — tokens and time_to_first_token
+ String metricsJson = span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics"));
+ assertNotNull(metricsJson);
+ JsonNode metrics = JSON_MAPPER.readTree(metricsJson);
+ assertTrue(metrics.has("prompt_tokens"), "prompt_tokens should be present");
+ assertTrue(metrics.has("completion_tokens"), "completion_tokens should be present");
+ assertTrue(metrics.has("time_to_first_token"), "time_to_first_token should be present");
+ assertTrue(
+ metrics.get("time_to_first_token").asDouble() >= 0.0,
+ "time_to_first_token should be non-negative");
+ }
+
+ /**
+ * When the client's HTTP layer cannot be instrumented (custom implementations, changed SDK
+ * internals), wrap must return the client untouched — installing the context-capturing proxy
+ * without a TracingHttpClient underneath would leak internal trace IDs to the provider via the
+ * un-stripped context header.
+ */
+ @Test
+ void testUninstrumentableClientIsLeftUntouched() {
+ AnthropicClient custom =
+ (AnthropicClient)
+ java.lang.reflect.Proxy.newProxyInstance(
+ AnthropicClient.class.getClassLoader(),
+ new Class>[] {AnthropicClient.class},
+ (proxy, method, args) -> {
+ throw new UnsupportedOperationException(method.getName());
+ });
+
+ AnthropicClient wrapped = BraintrustAnthropic.wrap(testHarness.openTelemetry(), custom);
+
+ assertSame(custom, wrapped, "uninstrumentable client should not get the context proxy");
+ }
+
+ /** The context-capturing proxy must keep Object identity semantics usable (maps/sets). */
+ @Test
+ void testWrappedClientObjectContract() {
+ AnthropicClient client =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+ AnthropicClient wrapped = BraintrustAnthropic.wrap(testHarness.openTelemetry(), client);
+ AnthropicClient rewrapped = BraintrustAnthropic.wrap(testHarness.openTelemetry(), client);
+
+ assertEquals(wrapped, wrapped, "equals must be reflexive");
+ assertEquals(wrapped, rewrapped, "proxies over the same delegate should be equal");
+ assertEquals(rewrapped, wrapped, "equals must be symmetric");
+ assertEquals(wrapped.hashCode(), rewrapped.hashCode(), "hashCode consistent with equals");
+ assertFalse(wrapped.equals(null), "equals(null) must be false");
+ assertTrue(
+ new java.util.HashSet<>(java.util.List.of(wrapped)).contains(wrapped),
+ "wrapped client must work as a set element");
+ assertTrue(
+ wrapped.toString().contains("ContextCapturingProxy"),
+ "toString should identify the proxy, got: " + wrapped);
+ }
+
+ /**
+ * Anthropic returns its correlation ID as {@code request-id} (no {@code x-} prefix, unlike
+ * OpenAI) and its object ID as {@code msg_*}. Both must land on the span for streaming and
+ * non-streaming alike — the header comes off the HTTP response, the object ID out of the
+ * reassembled body, so the two travel independent paths.
+ */
+ @Test
+ @SneakyThrows
+ void testCorrelationIdsCaptured() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ anthropicClient.messages().create(request);
+ assertAnthropicIdsCaptured(testHarness.awaitExportedSpans().get(0));
+ }
+
+ @Test
+ @SneakyThrows
+ void testCorrelationIdsCapturedStreaming() {
+ AnthropicClient anthropicClient =
+ AnthropicOkHttpClient.builder()
+ .baseUrl(testHarness.anthropicBaseUrl())
+ .apiKey(testHarness.anthropicApiKey())
+ .build();
+
+ var request =
+ MessageCreateParams.builder()
+ .model(Model.of(TEST_MODEL))
+ .system("You are a helpful assistant")
+ .addUserMessage("What is the capital of France?")
+ .maxTokens(50)
+ .build();
+
+ try (var stream = anthropicClient.messages().createStreaming(request)) {
+ stream.stream().forEach(event -> {});
+ }
+ assertAnthropicIdsCaptured(testHarness.awaitExportedSpans().get(0));
+ }
+
+ /**
+ * Asserts presence only for the header: its value is an opaque vendor string, so pinning its
+ * shape would encode an assumption the provider never made.
+ */
+ private static void assertAnthropicIdsCaptured(io.opentelemetry.sdk.trace.data.SpanData span) {
+ var attributes = span.getAttributes();
+
+ String requestId = attributes.get(AttributeKey.stringKey("request-id"));
+ assertNotNull(requestId, "request-id header must be captured");
+ assertFalse(requestId.isBlank(), "request-id must not be blank");
+
+ String responseId = attributes.get(AttributeKey.stringKey("response_id"));
+ assertNotNull(responseId, "response_id must be captured from the response body");
+ assertTrue(responseId.startsWith("msg_"), "unexpected response_id: " + responseId);
+
+ assertNull(
+ attributes.get(AttributeKey.stringKey("x-request-id")),
+ "OpenAI's header name must not appear on an Anthropic span");
+ }
+
+ // -------------------------------------------------------------------------
+ // Status-code handling
+ //
+ // Driven against a stub delegate rather than the VCR proxy: a 3xx or a 1xx cannot
+ // realistically be recorded from the vendor, and those are exactly the statuses that
+ // distinguish "non-2xx" from "4xx and up".
+ // -------------------------------------------------------------------------
+
+ /**
+ * anthropic-java's ErrorHandler treats success as exactly 200..299 and raises everything else
+ * to the caller, so every one of these must mark the span failed. 304 is the realistic case:
+ * the http client does not follow it, so it arrives here as a final response.
+ */
+ @ParameterizedTest(name = "status {0}")
+ @ValueSource(ints = {100, 204, 301, 304, 400, 500})
+ @SneakyThrows
+ void nonSuccessStatusMarksSpanFailed(int statusCode) {
+ var client =
+ new TracingHttpClient(
+ testHarness.openTelemetry(), new StubHttpClient(statusCode, "{}"));
+
+ try (var response = client.execute(messagesRequest(), RequestOptions.none())) {
+ response.body().readAllBytes();
+ }
+
+ var span = testHarness.awaitExportedSpans().get(0);
+ boolean isSuccess = statusCode >= 200 && statusCode < 300;
+ assertEquals(
+ isSuccess ? StatusCode.UNSET : StatusCode.ERROR,
+ span.getStatus().getStatusCode(),
+ "status "
+ + statusCode
+ + (isSuccess ? " should not" : " should")
+ + " mark the span failed");
+ }
+
+ /** The correlation header is still captured on a status the SDK will reject. */
+ @Test
+ @SneakyThrows
+ void requestIdIsCapturedOnANonSuccessStatus() {
+ var client =
+ new TracingHttpClient(testHarness.openTelemetry(), new StubHttpClient(304, ""));
+
+ try (var response = client.execute(messagesRequest(), RequestOptions.none())) {
+ response.body().readAllBytes();
+ }
+
+ var span = testHarness.awaitExportedSpans().get(0);
+ assertEquals(
+ "stubbed-request-id",
+ span.getAttributes().get(AttributeKey.stringKey("request-id")),
+ "an empty-bodied non-2xx must still yield the vendor request id");
+ }
+
+ @Test
+ void nonJsonResponseTaggingIsBestEffort() {
+ var client =
+ new TracingHttpClient(
+ testHarness.openTelemetry(),
+ new StubHttpClient(502, "Bad Gateway"));
+
+ assertDoesNotThrow(
+ () -> {
+ try (var response = client.execute(messagesRequest(), RequestOptions.none())) {
+ response.body().readAllBytes();
+ }
+ });
+
+ var span = testHarness.awaitExportedSpans().get(0);
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(
+ "stubbed-request-id",
+ span.getAttributes().get(AttributeKey.stringKey("request-id")));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"v1/messages", "v1/complete"})
+ @SneakyThrows
+ void inferenceEndpointsGetLlmSpans(String path) {
+ var client =
+ new TracingHttpClient(
+ testHarness.openTelemetry(),
+ new StubHttpClient(200, "{\"model\":\"claude-test\"}"));
+ var request =
+ HttpRequest.builder()
+ .method(HttpMethod.POST)
+ .baseUrl("https://api.anthropic.com")
+ .addPathSegments(path.split("/"))
+ .build();
+
+ try (var response = client.execute(request, RequestOptions.none())) {
+ response.body().readAllBytes();
+ }
+
+ var span = testHarness.awaitExportedSpans().get(0);
+ assertNotEquals("anthropic.http", span.getName());
+ JsonNode spanAttributes =
+ new ObjectMapper()
+ .readTree(
+ span.getAttributes()
+ .get(AttributeKey.stringKey("braintrust.span_attributes")));
+ assertEquals("llm", spanAttributes.get("type").asText());
+ }
+
+ @ParameterizedTest
+ @CsvSource({
+ "false, messages/batches, POST, 200",
+ "true, v1/messages/batches, POST, 200",
+ "false, v1/messages/batches, GET, 200",
+ "true, messages/batches, GET, 200",
+ "false, messages/batches/batch_123, GET, 200",
+ "true, v1/messages/batches/batch_123, GET, 200",
+ "false, messages/batches/batch_123/results, GET, 200",
+ "true, v1/messages/batches/batch_123/results, GET, 200",
+ "false, v1/messages/batches/batch_123/cancel, POST, 200",
+ "true, messages/batches/batch_123/cancel, POST, 200",
+ "false, v1/messages/batches/batch_123, GET, 304",
+ "true, messages/batches/batch_123, GET, 429",
+ "true, v1/messages/count_tokens, POST, 200",
+ "false, v1/models, GET, 200",
+ "true, v1/files, POST, 200",
+ "false, v1/files/file_123/content, GET, 200",
+ "false, messages/batches, POST, 500",
+ "true, v1/messages/batches, POST, 502"
+ })
+ @SneakyThrows
+ void nonLlmResponsesBypassLlmTagging(
+ boolean async, String path, HttpMethod method, int statusCode) {
+ String payload =
+ "{\"id\":\"batch_123\",\"model\":\"not-an-llm\","
+ + "\"content\":[{\"type\":\"server_tool_use\",\"name\":\"web_search\","
+ + "\"id\":\"tool_1\",\"input\":{\"query\":\"ignored\"}}]}\n"
+ + "{\"custom_id\":\"second-result\"}\n";
+ var request = unbufferedRequest(path, method);
+ var delegate = new PassthroughHttpClient();
+ delegate.response =
+ new StubHttpClient(statusCode, payload).execute(request, RequestOptions.none());
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var parent =
+ testHarness
+ .openTelemetry()
+ .getTracer("batch-test")
+ .spanBuilder("parent")
+ .startSpan();
+ HttpResponse response;
+ if (async) {
+ // Simulate the service proxy's context header on a thread with no current parent.
+ var context = parent.getSpanContext();
+ var withContext =
+ request.toBuilder()
+ .replaceHeaders(
+ ContextCapturingProxy.CONTEXT_HEADER,
+ "00-"
+ + context.getTraceId()
+ + "-"
+ + context.getSpanId()
+ + "-01")
+ .build();
+ var future = client.executeAsync(withContext, RequestOptions.none());
+ assertFalse(future.isDone());
+ assertTrue(delegate.requestSpan.isRecording());
+ delegate.pending.complete(delegate.response);
+ response = future.join();
+ } else {
+ try (var ignored = parent.makeCurrent()) {
+ response = client.execute(request, RequestOptions.none());
+ }
+ }
+ assertSame(delegate.response, response, "non-LLM responses must not be wrapped");
+ assertSame(
+ request.body().orElseThrow(),
+ delegate.sentRequest.body().orElseThrow(),
+ "non-LLM bodies must not be buffered");
+ assertEquals(request.queryParams(), delegate.sentRequest.queryParams());
+ assertTrue(
+ delegate.sentRequest
+ .headers()
+ .values(ContextCapturingProxy.CONTEXT_HEADER)
+ .isEmpty());
+ assertFalse(delegate.requestSpan.isRecording(), "transport completion ends the span");
+ try (response) {
+ assertEquals(
+ payload, new String(response.body().readAllBytes(), StandardCharsets.UTF_8));
+ }
+ response.close();
+ parent.end();
+ assertHttpSpan(parent, statusCode < 200 || statusCode >= 300, false);
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "true, false", "true, true"})
+ void nonLlmTransportFailuresAreGeneric(boolean async, boolean immediateFailure) {
+ var request = unbufferedRequest("v1/messages/batches", HttpMethod.POST);
+ var failure = new IllegalStateException("transport failed");
+ var delegate = new PassthroughHttpClient();
+ delegate.failure = failure;
+ delegate.immediateFailure = immediateFailure;
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var parent =
+ testHarness
+ .openTelemetry()
+ .getTracer("batch-test")
+ .spanBuilder("parent")
+ .startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ if (!async) {
+ assertSame(
+ failure,
+ assertThrows(
+ IllegalStateException.class,
+ () -> client.execute(request, RequestOptions.none())));
+ } else if (immediateFailure) {
+ assertSame(
+ failure,
+ assertThrows(
+ IllegalStateException.class,
+ () -> client.executeAsync(request, RequestOptions.none())));
+ } else {
+ var future = client.executeAsync(request, RequestOptions.none());
+ assertTrue(delegate.requestSpan.isRecording());
+ delegate.pending.completeExceptionally(failure);
+ assertSame(
+ failure,
+ assertThrows(java.util.concurrent.CompletionException.class, future::join)
+ .getCause());
+ }
+ }
+ assertFalse(delegate.requestSpan.isRecording());
+ parent.end();
+ assertHttpSpan(parent, true, true);
+ }
+
+ @ParameterizedTest
+ @CsvSource({"200, false", "503, false", "200, true"})
+ void cancelledNonLlmFutureStillEndsSpanOnTransportCompletion(
+ int statusCode, boolean transportFailure) throws Exception {
+ var request = unbufferedRequest("v1/messages/batches", HttpMethod.POST);
+ var delegate = new PassthroughHttpClient();
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var parent =
+ testHarness
+ .openTelemetry()
+ .getTracer("batch-test")
+ .spanBuilder("parent")
+ .startSpan();
+ try (var response =
+ new TrackingResponse(
+ statusCode,
+ new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)))) {
+ CompletableFuture future;
+ try (var ignored = parent.makeCurrent()) {
+ future = client.executeAsync(request, RequestOptions.none());
+ }
+ assertTrue(future.cancel(true));
+ assertFalse(delegate.pending.isDone());
+ assertTrue(delegate.requestSpan.isRecording());
+ if (transportFailure) {
+ delegate.pending.completeExceptionally(
+ new IllegalStateException("transport failed"));
+ } else {
+ delegate.pending.complete(response);
+ assertTrue(response.closed, "an abandoned non-LLM response must be released");
+ }
+ assertTrue(future.isCancelled());
+ assertFalse(delegate.requestSpan.isRecording());
+ } finally {
+ parent.end();
+ }
+ assertHttpSpan(parent, transportFailure || statusCode >= 300, transportFailure);
+ }
+
+ @Test
+ void deliveredNonLlmAsyncResponseRemainsOwnedByCaller() throws Exception {
+ var delegate = new PassthroughHttpClient();
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ try (var response =
+ new TrackingResponse(
+ new ByteArrayInputStream(
+ "file contents".getBytes(StandardCharsets.UTF_8)))) {
+ var future =
+ client.executeAsync(
+ unbufferedRequest("v1/files/file_123/content", HttpMethod.GET),
+ RequestOptions.none());
+ delegate.pending.complete(response);
+ assertSame(response, future.get(5, TimeUnit.SECONDS));
+ assertFalse(future.cancel(true), "completion must retain caller ownership");
+ assertFalse(response.closed, "a delivered response must remain open for its caller");
+ assertEquals(
+ "file contents",
+ new String(response.body().readAllBytes(), StandardCharsets.UTF_8));
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void cancelledLlmFutureStillEndsSpanOnTransportCompletion(boolean transportFailure) {
+ var delegate = new PassthroughHttpClient();
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var response =
+ new TrackingResponse(
+ new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)));
+ var future = client.executeAsync(messagesRequest(), RequestOptions.none());
+ assertTrue(future.cancel(true));
+ assertFalse(delegate.pending.isDone(), "caller cancellation must not cancel the transport");
+ if (transportFailure) {
+ delegate.pending.completeExceptionally(new IOException("transport failed"));
+ } else {
+ delegate.pending.complete(response);
+ assertTrue(response.closed, "an abandoned successful response must be released");
+ }
+ assertTrue(future.isCancelled());
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ assertEquals(
+ transportFailure ? StatusCode.ERROR : StatusCode.UNSET,
+ spans.get(0).getStatus().getStatusCode());
+ assertEquals(transportFailure ? 1 : 0, spans.get(0).getEvents().size());
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void timeToFirstTokenIncludesTransportDelay(boolean async) throws Exception {
+ String sse =
+ """
+ event: message_start
+ data: {"type":"message_start","message":{"id":"msg_test","type":"message","role":"assistant","model":"claude-test","content":[],"usage":{"input_tokens":1,"output_tokens":0}}}
+
+ event: content_block_start
+ data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
+
+ event: content_block_delta
+ data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
+
+ event: content_block_stop
+ data: {"type":"content_block_stop","index":0}
+
+ event: message_delta
+ data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":1}}
+
+ event: message_stop
+ data: {"type":"message_stop"}
+
+ """;
+ var delegate = new PassthroughHttpClient();
+ delegate.response =
+ new TrackingResponse(
+ new ByteArrayInputStream(sse.getBytes(StandardCharsets.UTF_8)));
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ long[] transportDelay = new long[1];
+ Runnable delay =
+ () -> {
+ long start = System.nanoTime();
+ assertDoesNotThrow(() -> Thread.sleep(100));
+ transportDelay[0] = System.nanoTime() - start;
+ };
+ HttpResponse response;
+ if (async) {
+ var pending = client.executeAsync(messagesRequest(), RequestOptions.none());
+ delay.run();
+ delegate.pending.complete(delegate.response);
+ response = pending.get(5, TimeUnit.SECONDS);
+ } else {
+ delegate.beforeResponse = delay;
+ response = client.execute(messagesRequest(), RequestOptions.none());
+ }
+ try (response) {
+ response.body().readAllBytes();
+ }
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertEquals(StatusCode.UNSET, span.getStatus().getStatusCode());
+ assertTrue(span.getEvents().isEmpty());
+ var metrics =
+ JSON_MAPPER.readTree(
+ span.getAttributes().get(AttributeKey.stringKey("braintrust.metrics")));
+ assertTrue(metrics.has("time_to_first_token"));
+ assertTrue(
+ metrics.get("time_to_first_token").asDouble()
+ >= transportDelay[0] / 1_000_000_000.0,
+ "time to first token must include time waiting for response headers");
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "false, true", "true, false", "true, true"})
+ void responseReadFailureEndsSpanBeforeClose(boolean async, boolean bulk) throws Exception {
+ var failure = new IOException("response body failed");
+ var body =
+ new InputStream() {
+ private boolean first = true;
+
+ @Override
+ public int read() throws IOException {
+ if (first) {
+ first = false;
+ return '{';
+ }
+ throw failure;
+ }
+
+ @Override
+ public int read(byte[] bytes, int offset, int length) throws IOException {
+ int value = read();
+ bytes[offset] = (byte) value;
+ return 1;
+ }
+ };
+ var delegate = new PassthroughHttpClient();
+ var rawResponse = new TrackingResponse(body);
+ delegate.response = rawResponse;
+ delegate.pending.complete(rawResponse);
+ var client = new TracingHttpClient(testHarness.openTelemetry(), delegate);
+ var response =
+ async
+ ? client.executeAsync(messagesRequest(), RequestOptions.none())
+ .get(5, TimeUnit.SECONDS)
+ : client.execute(messagesRequest(), RequestOptions.none());
+ var stream = response.body();
+ byte[] buffer = new byte[8];
+ if (bulk) {
+ assertEquals(1, stream.read(buffer, 0, buffer.length));
+ assertSame(
+ failure,
+ assertThrows(IOException.class, () -> stream.read(buffer, 0, buffer.length)));
+ } else {
+ assertEquals('{', stream.read());
+ assertSame(failure, assertThrows(IOException.class, stream::read));
+ }
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size(), "read failure must export without requiring close");
+ var span = spans.get(0);
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(1, span.getEvents().size());
+ assertEquals("exception", span.getEvents().get(0).getName());
+ assertEquals(
+ "response body failed",
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.message")));
+ assertEquals(
+ "stubbed-request-id",
+ span.getAttributes().get(AttributeKey.stringKey("request-id")));
+ assertSame(failure, assertThrows(IOException.class, stream::read));
+ response.close();
+ assertTrue(rawResponse.closed);
+ var afterClose = testHarness.awaitExportedSpans();
+ assertEquals(1, afterClose.size());
+ assertEquals(1, afterClose.get(0).getEvents().size());
+ }
+
+ private void assertHttpSpan(Span parent, boolean failed, boolean exception) {
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(
+ 2,
+ spans.size(),
+ () ->
+ "one parent and one ended http span, no LLM/tool children: "
+ + spans.stream()
+ .map(s -> s.getName() + " " + s.getAttributes())
+ .toList());
+ var span =
+ spans.stream()
+ .filter(s -> s.getName().equals("anthropic.http"))
+ .findFirst()
+ .orElseThrow();
+ assertEquals(parent.getSpanContext().getSpanId(), span.getParentSpanId());
+ assertTrue(span.hasEnded());
+ for (String attribute :
+ List.of(
+ "braintrust.span_attributes",
+ "braintrust.input_json",
+ "braintrust.output_json",
+ "braintrust.metadata",
+ "braintrust.metrics")) {
+ assertNull(span.getAttributes().get(AttributeKey.stringKey(attribute)), attribute);
+ }
+ assertEquals(
+ failed ? StatusCode.ERROR : StatusCode.UNSET, span.getStatus().getStatusCode());
+ assertEquals(exception ? 1 : 0, span.getEvents().size());
+ if (exception) {
+ assertEquals("exception", span.getEvents().get(0).getName());
+ }
+ }
+
+ private static HttpRequest unbufferedRequest(String path, HttpMethod method) {
+ return HttpRequest.builder()
+ .method(method)
+ .baseUrl("https://api.anthropic.com")
+ .addPathSegments(path.split("/"))
+ .putQueryParam("beta", "true")
+ .body(
+ new HttpRequestBody() {
+ @Override
+ public void writeTo(OutputStream stream) {
+ fail("Instrumentation must not read a non-LLM request body");
+ }
+
+ @Override
+ public String contentType() {
+ return "application/jsonl";
+ }
+
+ @Override
+ public long contentLength() {
+ return -1;
+ }
+
+ @Override
+ public boolean repeatable() {
+ return false;
+ }
+
+ @Override
+ public void close() {}
+ })
+ .build();
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void structuredOutputRetainsCallerParent(boolean async) throws Exception {
+ var transport = messageTransport();
+ var client = stubbedClient(transport);
+ try (AutoCloseable ignoredClient = client::close) {
+ var params =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Return the capital of France.")
+ .outputConfig(Capital.class)
+ .build();
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ var response =
+ async
+ ? client.async().messages().create(params).get(5, TimeUnit.SECONDS)
+ : client.messages().create(params);
+ assertEquals("msg_test", response.id());
+ } finally {
+ parent.end();
+ }
+ assertRequestParent(parent);
+ assertTrue(
+ transport
+ .sentRequest
+ .headers()
+ .values(ContextCapturingProxy.CONTEXT_HEADER)
+ .isEmpty());
+ }
+ }
+
+ public static class Capital {
+ public String city;
+ }
+
+ @Test
+ void parameterlessAsyncCallRetainsCallerParent() throws Exception {
+ var transport = new PassthroughHttpClient();
+ transport.pending.complete(
+ new StubHttpClient(
+ 200,
+ "{\"data\":[],\"has_more\":false,\"first_id\":null,\"last_id\":null}")
+ .execute(messagesRequest(), RequestOptions.none()));
+ var client = stubbedClient(transport);
+ try (AutoCloseable ignoredClient = client::close) {
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ assertTrue(
+ client.async()
+ .messages()
+ .batches()
+ .list()
+ .get(5, TimeUnit.SECONDS)
+ .data()
+ .isEmpty());
+ } finally {
+ parent.end();
+ }
+ assertRequestParent(parent);
+ }
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "false, true", "true, false", "true, true"})
+ void serviceOptionsRetainTracingWithoutLeakingContext(boolean async, boolean replaceTransport)
+ throws Exception {
+ var original = messageTransport();
+ var replacement = replaceTransport ? messageTransport() : original;
+ java.util.function.Consumer options =
+ o -> {
+ if (replaceTransport) {
+ o.httpClient(replacement);
+ } else {
+ o.maxRetries(1);
+ }
+ };
+ var client = stubbedClient(original);
+ try (AutoCloseable ignoredClient = client::close) {
+ var params =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Return the capital of France.")
+ .build();
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ var response =
+ async
+ ? client.async()
+ .messages()
+ .withOptions(options)
+ .create(params)
+ .get(5, TimeUnit.SECONDS)
+ : client.messages().withOptions(options).create(params);
+ assertEquals("msg_test", response.id());
+ } finally {
+ parent.end();
+ }
+ if (replaceTransport) {
+ assertNull(original.sentRequest);
+ }
+ assertTrue(
+ replacement
+ .sentRequest
+ .headers()
+ .values(ContextCapturingProxy.CONTEXT_HEADER)
+ .isEmpty(),
+ "Internal correlation header must never reach the replacement transport");
+ assertRequestParent(parent);
+ }
+ }
+
+ @ParameterizedTest
+ @CsvSource({"false, false", "false, true", "true, false", "true, true"})
+ void sseErrorMarksSpanFailedWithoutChangingSdkException(boolean async, boolean partial)
+ throws Exception {
+ String error =
+ """
+ event: error
+ data: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}
+
+ """;
+ if (partial) {
+ error =
+ """
+ event: message_start
+ data: {"type":"message_start","message":{"id":"msg_test","type":"message","role":"assistant","model":"claude-test","content":[],"usage":{"input_tokens":1,"output_tokens":0}}}
+
+ event: content_block_start
+ data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
+
+ event: content_block_delta
+ data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
+
+ """
+ + error;
+ }
+ var transport = new PassthroughHttpClient();
+ transport.response =
+ new StubHttpClient(200, error).execute(messagesRequest(), RequestOptions.none());
+ transport.pending.complete(transport.response);
+ var client = stubbedClient(transport);
+ try (AutoCloseable ignoredClient = client::close) {
+ var params =
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Hello")
+ .build();
+ if (async) {
+ try (var response =
+ client.async()
+ .messages()
+ .withRawResponse()
+ .createStreaming(params)
+ .get(5, TimeUnit.SECONDS)) {
+ var failure =
+ assertThrows(
+ SseException.class,
+ () -> response.parse().stream().forEach(event -> {}));
+ assertTrue(failure.getMessage().contains("Overloaded"));
+ }
+ } else {
+ try (var stream = client.messages().createStreaming(params)) {
+ var failure =
+ assertThrows(
+ SseException.class, () -> stream.stream().forEach(event -> {}));
+ assertTrue(failure.getMessage().contains("Overloaded"));
+ }
+ }
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(1, span.getEvents().size());
+ String message =
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.message"));
+ assertTrue(message.contains("overloaded_error"));
+ assertTrue(message.contains("Overloaded"));
+ assertEquals(
+ "stubbed-request-id",
+ span.getAttributes().get(AttributeKey.stringKey("request-id")));
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void rewrappingDerivedAsyncClientReplacesTracerWithoutDuplicateSpans(boolean cacheService)
+ throws Exception {
+ var client = stubbedClient(messageTransport());
+ try (AutoCloseable ignoredClient = client::close) {
+ var async = client.async();
+ var messages = cacheService ? async.messages() : null;
+ var tracer = testHarness.openTelemetry().getTracer("replacement");
+ var rewrapped = BraintrustAnthropic.wrap(tracer, async);
+ rewrapped = BraintrustAnthropic.wrap(tracer, rewrapped);
+ var parent =
+ testHarness.openTelemetry().getTracer("test").spanBuilder("caller").startSpan();
+ try (var ignored = parent.makeCurrent()) {
+ var response =
+ (cacheService ? messages : rewrapped.messages())
+ .create(
+ MessageCreateParams.builder()
+ .model(TEST_MODEL)
+ .maxTokens(32)
+ .addUserMessage("Return the capital of France.")
+ .build())
+ .get(5, TimeUnit.SECONDS);
+ assertEquals("msg_test", response.id());
+ } finally {
+ parent.end();
+ }
+ assertRequestParent(parent);
+ var request =
+ testHarness.awaitExportedSpans().stream()
+ .filter(s -> !s.getName().equals("caller"))
+ .findFirst()
+ .orElseThrow();
+ assertEquals("replacement", request.getInstrumentationScopeInfo().getName());
+ }
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void llmLinkageErrorEndsSpanWithoutMaskingFailure(boolean async) {
+ var failure = new NoSuchMethodError("incompatible transport API");
+ var transport =
+ new com.anthropic.core.http.HttpClient() {
+ @Override
+ public HttpResponse execute(HttpRequest request, RequestOptions options) {
+ throw failure;
+ }
+
+ @Override
+ public CompletableFuture executeAsync(
+ HttpRequest request, RequestOptions options) {
+ throw failure;
+ }
+
+ @Override
+ public void close() {}
+ };
+ var client = new TracingHttpClient(testHarness.openTelemetry(), transport);
+ assertSame(
+ failure,
+ assertThrows(
+ NoSuchMethodError.class,
+ () -> {
+ if (async) {
+ client.executeAsync(messagesRequest(), RequestOptions.none());
+ } else {
+ client.execute(messagesRequest(), RequestOptions.none());
+ }
+ }));
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(1, spans.size());
+ var span = spans.get(0);
+ assertTrue(span.hasEnded());
+ assertEquals(StatusCode.ERROR, span.getStatus().getStatusCode());
+ assertEquals(1, span.getEvents().size());
+ assertEquals(
+ NoSuchMethodError.class.getName(),
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.type")));
+ assertEquals(
+ failure.getMessage(),
+ span.getEvents()
+ .get(0)
+ .getAttributes()
+ .get(AttributeKey.stringKey("exception.message")));
+ }
+
+ private AnthropicClient stubbedClient(com.anthropic.core.http.HttpClient transport) {
+ return BraintrustAnthropic.wrap(
+ testHarness.openTelemetry(),
+ new AnthropicClientImpl(
+ ClientOptions.builder()
+ .httpClient(transport)
+ .putHeader("x-api-key", "test-key")
+ .maxRetries(0)
+ .build()));
+ }
+
+ private static PassthroughHttpClient messageTransport() {
+ var transport = new PassthroughHttpClient();
+ transport.response =
+ new StubHttpClient(
+ 200,
+ """
+ {"id":"msg_test","type":"message","role":"assistant","model":"claude-test",
+ "content":[{"type":"text","text":"{\\"city\\":\\"Paris\\"}"}],
+ "stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":1,"output_tokens":1}}
+ """)
+ .execute(messagesRequest(), RequestOptions.none());
+ transport.pending.complete(transport.response);
+ return transport;
+ }
+
+ private void assertRequestParent(Span parent) {
+ var spans = testHarness.awaitExportedSpans();
+ assertEquals(2, spans.size(), () -> "One caller and one request span: " + spans);
+ var request =
+ spans.stream().filter(s -> !s.getName().equals("caller")).findFirst().orElseThrow();
+ assertEquals(parent.getSpanContext().getSpanId(), request.getParentSpanId());
+ assertEquals(parent.getSpanContext().getTraceId(), request.getTraceId());
+ }
+
+ private static final class PassthroughHttpClient implements com.anthropic.core.http.HttpClient {
+ private final CompletableFuture pending = new CompletableFuture<>();
+ private HttpResponse response;
+ private RuntimeException failure;
+ private boolean immediateFailure;
+ private HttpRequest sentRequest;
+ private Span requestSpan;
+ private Runnable beforeResponse = () -> {};
+
+ @Override
+ public HttpResponse execute(HttpRequest request, RequestOptions options) {
+ sentRequest = request;
+ requestSpan = Span.current();
+ if (failure != null) {
+ throw failure;
+ }
+ beforeResponse.run();
+ return response;
+ }
+
+ @Override
+ public CompletableFuture executeAsync(
+ HttpRequest request, RequestOptions options) {
+ sentRequest = request;
+ requestSpan = Span.current();
+ if (immediateFailure) {
+ throw failure;
+ }
+ return pending;
+ }
+
+ @Override
+ public void close() {}
+ }
+
+ private static HttpRequest messagesRequest() {
+ return HttpRequest.builder()
+ .method(HttpMethod.POST)
+ .baseUrl("https://api.openai.com/v1")
+ .addPathSegments("v1", "messages")
+ .build();
+ }
+
+ private static final class TrackingResponse implements HttpResponse {
+ private final int statusCode;
+ private final InputStream stream;
+ private boolean closed;
+
+ private TrackingResponse(InputStream stream) {
+ this(200, stream);
+ }
+
+ private TrackingResponse(int statusCode, InputStream stream) {
+ this.statusCode = statusCode;
+ this.stream = stream;
+ }
+
+ @Override
+ public int statusCode() {
+ return statusCode;
+ }
+
+ @Override
+ public Headers headers() {
+ return Headers.builder().put("request-id", "stubbed-request-id").build();
+ }
+
+ @Override
+ public InputStream body() {
+ return stream;
+ }
+
+ @Override
+ public void close() {
+ closed = true;
+ }
+ }
+
+ /** Returns a canned response; never touches the network. */
+ private record StubHttpClient(int statusCode, String body)
+ implements com.anthropic.core.http.HttpClient {
+
+ @Override
+ public HttpResponse execute(HttpRequest request, RequestOptions requestOptions) {
+ return new HttpResponse() {
+ @Override
+ public int statusCode() {
+ return statusCode;
+ }
+
+ @Override
+ public Headers headers() {
+ return Headers.builder().put("request-id", "stubbed-request-id").build();
+ }
+
+ @Override
+ public InputStream body() {
+ return new ByteArrayInputStream(body.getBytes());
+ }
+
+ @Override
+ public void close() {}
+ };
+ }
+
+ @Override
+ public CompletableFuture executeAsync(
+ HttpRequest request, RequestOptions requestOptions) {
+ return CompletableFuture.completedFuture(execute(request, requestOptions));
+ }
+
+ @Override
+ public void close() {}
+ }
+}
diff --git a/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/SpringAIAnthropic.java b/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/SpringAIAnthropic.java
index 3b31c445..7a43e845 100644
--- a/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/SpringAIAnthropic.java
+++ b/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/SpringAIAnthropic.java
@@ -2,7 +2,7 @@
import com.anthropic.client.AnthropicClient;
import com.anthropic.client.AnthropicClientAsync;
-import dev.braintrust.instrumentation.anthropic.v2_2_0.BraintrustAnthropic;
+import dev.braintrust.instrumentation.anthropic.BraintrustAnthropic;
import io.opentelemetry.api.OpenTelemetry;
import io.opentelemetry.api.trace.Tracer;
import java.lang.reflect.Field;
@@ -17,6 +17,10 @@
* TracingHttpClient} used by the anthropic-java instrumentation module. Spring AI types are only
* accessed reflectively so this class never links against them.
*
+ * Wrapping goes through the version-dispatching {@link BraintrustAnthropic} facade so a Spring
+ * AI release that moves to anthropic-java 3.x gets the 3.x tracing client rather than the 2.x one,
+ * which would fail every request with {@code NoSuchMethodError}.
+ *
*
Internal — the public entry point is {@link BraintrustSpringAI#wrap}.
*/
@Slf4j
@@ -44,7 +48,8 @@ private static void wrapClientField(Tracer tracer, Object chatModel, String fiel
} else if (client instanceof AnthropicClientAsync async) {
setField(chatModel, fieldName, BraintrustAnthropic.wrap(tracer, async));
}
- } catch (Exception e) {
+ } catch (Exception | LinkageError e) {
+ // Leave the field untouched: an uninstrumented client beats a broken one.
log.error("failed to instrument spring ai anthropic client field {}", fieldName, e);
}
}
diff --git a/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/auto/SpringAIAnthropicInstrumentationModule.java b/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/auto/SpringAIAnthropicInstrumentationModule.java
index d9210ef6..a6db8124 100644
--- a/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/auto/SpringAIAnthropicInstrumentationModule.java
+++ b/braintrust-sdk/instrumentation/springai_2_0_0/src/main/java/dev/braintrust/instrumentation/springai/v2_0_0/auto/SpringAIAnthropicInstrumentationModule.java
@@ -1,12 +1,14 @@
package dev.braintrust.instrumentation.springai.v2_0_0.auto;
import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.not;
import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
import com.google.auto.service.AutoService;
import dev.braintrust.instrumentation.InstrumentationModule;
import dev.braintrust.instrumentation.TypeInstrumentation;
import dev.braintrust.instrumentation.TypeTransformer;
+import dev.braintrust.instrumentation.muzzle.ClassLoaderMatchers;
import dev.braintrust.instrumentation.springai.v2_0_0.BraintrustSpringAI;
import io.opentelemetry.api.GlobalOpenTelemetry;
import java.util.List;
@@ -26,15 +28,33 @@ public SpringAIAnthropicInstrumentationModule() {
super("springai_anthropic_2_0_0");
}
+ /**
+ * Gates this module to anthropic-java < 3.0.0, since its helpers are the v2_2_0 classes.
+ * Runtime muzzle would also reject them on 3.x ({@code HttpRequest.body()} changed signature);
+ * this makes the boundary explicit. On 3.x, Spring AI's clients are left uninstrumented (Spring
+ * AI builds {@code AnthropicClientImpl} directly, bypassing the builder anthropic_3_0_0 hooks).
+ */
+ @Override
+ public ElementMatcher classLoaderMatcher() {
+ return not(
+ ClassLoaderMatchers.hasClassNamed(
+ "com.anthropic.models.messages.AssistantMessageParam"));
+ }
+
@Override
public List getHelperClassNames() {
return List.of(
SPRINGAI_PACKAGE + "BraintrustSpringAI",
SPRINGAI_PACKAGE + "SpringAIAnthropic",
+ "dev.braintrust.instrumentation.anthropic.BraintrustAnthropic",
+ "dev.braintrust.instrumentation.anthropic.BraintrustAnthropic$1",
+ "dev.braintrust.instrumentation.anthropic.BraintrustAnthropic$V3",
ANTHROPIC_PACKAGE + "BraintrustAnthropic",
ANTHROPIC_PACKAGE + "ContextCapturingProxy",
ANTHROPIC_PACKAGE + "TracingHttpClient",
- ANTHROPIC_PACKAGE + "TracingHttpClient$1",
+ ANTHROPIC_PACKAGE + "TracingHttpClient$BufferedRequest",
+ ANTHROPIC_PACKAGE + "TracingHttpClient$ByteSink",
+ ANTHROPIC_PACKAGE + "TracingHttpClient$BufferedBody",
ANTHROPIC_PACKAGE + "TracingHttpClient$TeeingStreamHttpResponse",
ANTHROPIC_PACKAGE + "TracingHttpClient$TeeInputStream",
ANTHROPIC_PACKAGE + "TracingHttpClient$ExtractedRequest",
diff --git a/btx/build.gradle b/btx/build.gradle
index 6627eef0..0e7ff1a4 100644
--- a/btx/build.gradle
+++ b/btx/build.gradle
@@ -26,9 +26,12 @@ repositories {
// (main test classpath has 1.19.0 + langchain_1_14_0). Keeps the older
// module under btx spec coverage even though the two langchain4j lines
// cannot coexist.
+// anthropic3 - anthropic-java 3.x, driving the anthropic_3_0_0 instrumentation module
+// (main test classpath has 2.x + anthropic_2_2_0).
sourceSets {
springai2
langchain18
+ anthropic3
}
dependencies {
@@ -57,6 +60,17 @@ dependencies {
langchain18Implementation "io.opentelemetry:opentelemetry-api:${rootProject.ext.otelVersion}"
langchain18Implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
langchain18RuntimeOnly 'org.slf4j:slf4j-simple:2.0.17'
+
+ // anthropic-java 3.x against the anthropic_3_0_0 module. Must stay >= 3.0.0 or the module's
+ // classLoaderMatcher gate rejects it.
+ anthropic3CompileOnly sourceSets.test.output
+ anthropic3CompileOnly(testFixtures(project(':test-harness')))
+
+ anthropic3Implementation project(':braintrust-sdk:instrumentation:anthropic_3_0_0')
+ anthropic3Implementation 'com.anthropic:anthropic-java:3.4.0'
+ anthropic3Implementation "io.opentelemetry:opentelemetry-api:${rootProject.ext.otelVersion}"
+ anthropic3Implementation 'com.fasterxml.jackson.core:jackson-databind:2.16.1'
+ anthropic3RuntimeOnly 'org.slf4j:slf4j-simple:2.0.17'
}
dependencies {
@@ -120,12 +134,15 @@ test {
// Hand the isolated client classpaths to the test JVM (resolved lazily so configuration
// time doesn't force dependency resolution).
- dependsOn tasks.named('springai2Classes'), tasks.named('langchain18Classes')
+ dependsOn tasks.named('springai2Classes'), tasks.named('langchain18Classes'),
+ tasks.named('anthropic3Classes')
doFirst {
systemProperty 'btx.springai2.classpath',
(sourceSets.springai2.output.classesDirs + configurations.springai2RuntimeClasspath).asPath
systemProperty 'btx.langchain18.classpath',
(sourceSets.langchain18.output.classesDirs + configurations.langchain18RuntimeClasspath).asPath
+ systemProperty 'btx.anthropic3.classpath',
+ (sourceSets.anthropic3.output.classesDirs + configurations.anthropic3RuntimeClasspath).asPath
}
testLogging {
events "passed", "skipped", "failed"
diff --git a/btx/src/anthropic3/java/dev/braintrust/sdkspecimpl/anthropic3/Anthropic3SpecClient.java b/btx/src/anthropic3/java/dev/braintrust/sdkspecimpl/anthropic3/Anthropic3SpecClient.java
new file mode 100644
index 00000000..37039d08
--- /dev/null
+++ b/btx/src/anthropic3/java/dev/braintrust/sdkspecimpl/anthropic3/Anthropic3SpecClient.java
@@ -0,0 +1,97 @@
+package dev.braintrust.sdkspecimpl.anthropic3;
+
+import com.anthropic.client.AnthropicClient;
+import com.anthropic.client.okhttp.AnthropicOkHttpClient;
+import com.anthropic.core.ObjectMappers;
+import com.anthropic.models.messages.MessageCreateParams;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import dev.braintrust.instrumentation.anthropic.v3_0_0.BraintrustAnthropic;
+import dev.braintrust.sdkspecimpl.LlmSpanSpec;
+import dev.braintrust.sdkspecimpl.SpecClient;
+import dev.braintrust.sdkspecimpl.SpecClientContext;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Raw anthropic-java 3.x SDK client (messages API, sync + streaming), driving the {@code
+ * anthropic_3_0_0} instrumentation module. Runs inside the isolated {@code anthropic3} classloader
+ * (see {@code SpecClient.isolation()}) because anthropic-java 2.x and 3.x share coordinates and
+ * packages.
+ */
+public final class Anthropic3SpecClient implements SpecClient {
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ private static final List REMOVED_IN_3_X = List.of("temperature", "top_p", "top_k");
+
+ private volatile AnthropicClient client;
+
+ @Override
+ public String id() {
+ return "anthropic3";
+ }
+
+ @Override
+ public String provider() {
+ return "anthropic";
+ }
+
+ @Override
+ public void executeSpec(LlmSpanSpec spec, SpecClientContext ctx) throws Exception {
+ for (Map request : spec.requests()) {
+ executeMessages(ctx, spec, request);
+ }
+ }
+
+ private AnthropicClient client(SpecClientContext ctx) {
+ AnthropicClient result = client;
+ if (result == null) {
+ synchronized (this) {
+ result = client;
+ if (result == null) {
+ result =
+ BraintrustAnthropic.wrap(
+ ctx.otel(),
+ AnthropicOkHttpClient.builder()
+ .baseUrl(ctx.anthropicBaseUrl())
+ .apiKey(ctx.anthropicApiKey())
+ .build());
+ client = result;
+ }
+ }
+ }
+ return result;
+ }
+
+ private void executeMessages(
+ SpecClientContext ctx, LlmSpanSpec spec, Map request) throws Exception {
+ // "stream" is not part of MessageCreateParams.Body; it selects create vs createStreaming.
+ boolean stream = Boolean.TRUE.equals(request.get("stream"));
+ Map bodyMap = new LinkedHashMap<>(request);
+ bodyMap.remove("stream");
+ // anthropic-java 3.x targets API version 2026-10-21, which removed these sampling
+ // parameters and rejects them ("Extra inputs are not permitted"). The specs set them for
+ // determinism only; no assertion depends on them.
+ REMOVED_IN_3_X.forEach(bodyMap::remove);
+
+ MessageCreateParams.Body body =
+ ObjectMappers.jsonMapper()
+ .readValue(
+ MAPPER.writeValueAsString(bodyMap), MessageCreateParams.Body.class);
+
+ var builder = MessageCreateParams.builder().body(body);
+ if (spec.headers() != null) {
+ spec.headers().forEach(builder::putAdditionalHeader);
+ }
+ var params = builder.build();
+
+ if (stream) {
+ try (var s = client(ctx).messages().createStreaming(params)) {
+ s.stream().forEach(event -> {});
+ }
+ } else {
+ client(ctx).messages().create(params);
+ }
+ }
+}
diff --git a/btx/src/test/java/dev/braintrust/sdkspecimpl/SpecClientRegistry.java b/btx/src/test/java/dev/braintrust/sdkspecimpl/SpecClientRegistry.java
index b52f8cb4..245b1610 100644
--- a/btx/src/test/java/dev/braintrust/sdkspecimpl/SpecClientRegistry.java
+++ b/btx/src/test/java/dev/braintrust/sdkspecimpl/SpecClientRegistry.java
@@ -68,6 +68,16 @@ public final class SpecClientRegistry {
new SpecClient.Isolation(
"btx.langchain18.classpath",
"dev.braintrust.sdkspecimpl.langchain18.LangChain18OpenAiSpecClient")),
+ new IsolatedClientStub(
+ "anthropic3",
+ "anthropic",
+ // anthropic-java 3.x through the anthropic_3_0_0 module; the
+ // "anthropic" client covers 2.x / anthropic_2_2_0.
+ Set.of("/v1/messages"),
+ Set.of(),
+ new SpecClient.Isolation(
+ "btx.anthropic3.classpath",
+ "dev.braintrust.sdkspecimpl.anthropic3.Anthropic3SpecClient")),
new IsolatedClientStub(
"springai2-openai",
"openai",
diff --git a/settings.gradle b/settings.gradle
index 97fda48f..413eecf5 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -29,6 +29,7 @@ include 'braintrust-java-agent:internal'
include 'braintrust-java-agent:instrumenter'
include 'braintrust-sdk:instrumentation:openai_2_15_0'
include 'braintrust-sdk:instrumentation:anthropic_2_2_0'
+include 'braintrust-sdk:instrumentation:anthropic_3_0_0'
include 'braintrust-sdk:instrumentation:genai_1_18_0'
include 'braintrust-sdk:instrumentation:langchain_1_8_0'
include 'braintrust-sdk:instrumentation:langchain_1_14_0'
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-01bea1556aa0.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-01bea1556aa0.json
new file mode 100644
index 00000000..30d8b7df
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-01bea1556aa0.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD5BmeiuFGY4eEu6nmo","type":"message","role":"assistant","content":[{"type":"text","text":"I can see there is a PDF attachment, but the document appears to be blank or contains no visible text or images on the first page. The page shows only a white background with what appears to be a small red mark in the upper left corner.\n\nTo provide you with an accurate description, I would need:\n- A document with visible content\n- Additional pages (if this is a multi-page PDF)\n- A clearer or higher-resolution version of the file\n\nCould you please verify that the correct file was attached or provide another version?"}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":1592,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":116,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-0ffdd26b7bf0.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-0ffdd26b7bf0.json
new file mode 100644
index 00000000..6836dd76
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-0ffdd26b7bf0.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD4wBYqxVB5xrS8Vzsz","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":20,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":10,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-17ceeb7fc9f7.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-17ceeb7fc9f7.txt
new file mode 100644
index 00000000..ad472c0f
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-17ceeb7fc9f7.txt
@@ -0,0 +1,60 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB9FvK9JCdh5fe3wFyW","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} }
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"The capital of France"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is **"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Paris**"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":". It"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" located in the north"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"-central part of"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" country along"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the Seine River and"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is the"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" country"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"'s largest city and"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" cultural center."} }
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":39} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-2ee9b8be984d.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-2ee9b8be984d.json
new file mode 100644
index 00000000..65dc4c7d
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-2ee9b8be984d.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB8hE3CtxacoVoRbB79","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris. It is the largest city in France and has been the capital since the 12th century. Paris is located in the north-central part of the country along the Seine River and is known for its historical landmarks,"}],"container":null,"stop_reason":"max_tokens","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":50,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-30d678393fe5.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-30d678393fe5.json
new file mode 100644
index 00000000..2ae9563b
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-30d678393fe5.json
@@ -0,0 +1 @@
+{"model":"claude-sonnet-4-5-20250929","id":"msg_011CgfD4kfJ9qkiDqa7exutR","type":"message","role":"assistant","content":[{"type":"text","text":"Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":12,"cache_creation_input_tokens":1367,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":1367,"ephemeral_1h_input_tokens":0},"output_tokens":5,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-39de4328f786.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-39de4328f786.json
new file mode 100644
index 00000000..efb21a44
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-39de4328f786.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB9XipzSchmMx7zAavD","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris. It's located in the north-central part of the country along the Seine River and is the largest city in France. Paris is known for its iconic landmarks like the Eiffel Tower, Notre-Dame Cathedral"}],"container":null,"stop_reason":"max_tokens","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":50,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-3edad2888bf5.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-3edad2888bf5.json
new file mode 100644
index 00000000..884c07a3
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-3edad2888bf5.json
@@ -0,0 +1 @@
+{"model":"claude-sonnet-4-5-20250929","id":"msg_011CgfD4yGpZLzJnE3K6ib1b","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is **Paris**."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":12,"cache_creation_input_tokens":1992,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":1992},"output_tokens":11,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-4e20f3b6ee97.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-4e20f3b6ee97.json
new file mode 100644
index 00000000..76016ecb
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-4e20f3b6ee97.json
@@ -0,0 +1 @@
+{"model":"claude-sonnet-4-5-20250929","id":"msg_011CgfD4zRX4zwXy1P11ZCjc","type":"message","role":"assistant","content":[{"type":"server_tool_use","id":"srvtoolu_01682YgFPu9CECReTiWVQtnz","name":"web_search","input":{"query":"AI news today"}},{"type":"web_search_tool_result","tool_use_id":"srvtoolu_01682YgFPu9CECReTiWVQtnz","content":[{"type":"web_search_result","title":"AI News Today, November 2: Top Stories","url":"https://aiweekly.co/ai-news-today","encrypted_content":"EtwNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDKIMxv1DOlf3WIteaBoMLAcFPltXX1AtavH9IjDozajJXB6IOfg+jXRST3xpKgbO9Ckz+T5FjK6zCWeHdJbRy9SzdeJ877ROq/3/XlIq3wypk/ccyV6HvBN10SZRNaEnQJ2HTIi0HzMoFCcsSyLobWU65XIoSyGeos4t9hQXNA+uEAXiTNtEEWjGrpMM+bSYqaZ5YdG9vkMv0DIpn6MTO7WpBk+XXkiXlLt5vdPzxTtTxcvPM1PUr2l63vAHl4SNiSWEJRBD/tmeHiHBiNkvuYyNjgR2HC18xX26NqKXi5rC9vPKxghnBpuFcNNbbuE7/HzMDDFDUkqN5IgZkv20ZG8QgcwCQBzvfxc7z/WhFjnx+oQDeF3nriKdXWoUn/hGqFEPrZyu9LWu4BMgqYHUXk8/8d7UzIjASm5WTbNjSJevLWQfB/S/tCpPaRqNnni+A2hWKw9QHvKCqUBKKIEHH2HGsfSlMuWldM84KaypsyK86q8z/EuWmmUd6GBoZTqrWJdtFwFT5fhjmvX6Ryy1yN58diW3roefpw99UYMCkUY8oc50Gpr8qkz1L56voDJLKB7rydVS0ADoqsw2KDkL1qzJhQy9r2bfIhL4n+HsesO5G9vM09OZTmjfDobjFDo+zcvjiUs2YuQdCR3aiUKm/Vusrt1llO+159bHBAw5z7OScDByXn+Vkk7Ccn8oTTvOpZdwqwAyjWewlaCOjCwlIPnm9ex8kFjpu2jaCxlYNLX+Gi2kSt00+abt36J+w1BwWMeH5H/u3jE03P6sw+lJrEmcjONWqNGBODiydj4F5dBeepzNqgJ0akpHrKyXVOxA5/5U86rVX5zSyzebBlJZ1UAD784Ayqy12HUR1TVPSp1JMiH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Su3yYTyUg0H7UAO7F/759LVLpPJkXCbZ3WrIj9e2fLdlajJ3F+nUlQELomlpHdNtbAX3YT8W19SjaGLOQjdUxP0YNkqlWrlniBNU3+wydny3OxkLXqsQ6L5/gyeBzUiNkA0H+oL8KbeBfTy+YmwW2d4pbymo1b9To/Ox3e4opXP+HOAmRLhvqTjxDkRkp8y8YUlaU7kDKyEdG2r4Zop0wLOYVm0bdQ5e0NcVGyPHepGu70tVa0sKE73Hou40ZT5Ype5B9lp4dmVONAr+pW/FSXW/ngaXRaM1A4hdrLCt2WDA0NlkduGxuwWnzyaHSEbipQQwpR5WaqnX8/3hZjOdkBgD","page_age":"0 days ago"},{"type":"web_search_result","title":"AI News: Artificial Intelligence Stories, Ranked","url":"https://aiweekly.co/","encrypted_content":"Et0NCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDKwwnVIh0g1KBlHyERoMfvzC7i5yw885WbmlIjAn4Qrs5CRBzENCnwJnNuRDzoOcm7bZ9M47v5WNyYycM7e2OE09FPZRQJZDDjYPkR4q4AwhV55140JY/Hrw+YUmG3EMvQVa9T/w1er1IvzpEtCgv4ejrmjaJhdNtkSpFxfUh/Ycu3COI1/vyqLAVo/OxGorVbT1mCLvm1MhQ6+4qzkc+Rlhdz+GrVa6dozlNdB8KNK2bEcUbKT7OY1BWbjJKczWfronpXDcMzAZ4+IxYxhEaRAt+15AGe3102Mvhm2b8Lvx5wfyVzBmra5BZtL38lw9V7n89aZHPGUSowXMNtxaCrKIR9xoEl8cYnthnnxCvL67s7zNea/oai68TSdnI3in+6D+4/GmQClW0piwCdq4ypodzcTp1fW/XgiAVw6BT0EebKK7OG54zg/YrVsxXSe5bkM+L4wJaZ8yRlP7XNzA8Oa2E0/W0S2xaSktfe6gd/CBsvzkxRlh+5rjsf6LKngLFANiIdb1FKPSiD8u//g9bizBxCs7t6SpZpHUculmJ1aCu6pRX5AEpgClWgBkSD2g1jF8K6JcnyI/U/4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wADP3xOSIy47ivgJDui2hbeGJJpcGLr4BWBZl2A/4K4fGUGl5ds5mbqG2uTeBFs90ETKgq+FcMMnY1jTxQ5DwMdvTIyU3oG8v0HuUpXxe6IOAD5LQaqesCqohs/PhWPR6gTCB21ZehZAX2njUjHzSpSjg8JhU8a7VXMxPHETowVQXVWwfDLbpXVfCXRf32sj/idGd1FdzjX3l2mUh7sUbL77Q6L+GMvKA/tPioAPnqtBYD64F/2Z8jKma8ff7AbUd9i4aikDJgNisbsX911ozh53n/R5aflAr3TdERMhK0EV9HMfhS7gp8Hcb+pO2FblyX2pwWEmVturmjeSFSJsr29l3/DqPtkgcViv8aUQA4ZpnHYu/rOCAoGpR9GG+L4Ee0E6CttQZGtZHiDY6kwbzaGw/FZyDaR6Q45IUG0cDmo9ffw/B6pCOktK2863oQnY7NTWU4OjwO/dmxIAr1ryfuXbqN63vnnu8eMvPmuArnCmMkR1nXJ0eVpnhJX+RflYGF2CIdLtpsbt6CiN6lCl5bs2tHL840m6w2zM375RkWy4W+E0tpPDWr5TgTxECBoFfDlW1YRjrxOavNvLg/pbUVrRZnsQ+3EwwEFOkYAw==","page_age":"0 days ago"},{"type":"web_search_result","title":"AI News, Updates, Products and Reviews","url":"https://tech.yahoo.com/ai/","encrypted_content":"EqwNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDFglvBPbur1/2WIBPRoMqK6KOzbBQAdFzYckIjBqYx3/bscLkHW1RPlxtGsy3iLyWtujHEfeDijP9LQOOlPFvKhaqpnS8+mgd4TM7oEqrwwsxA6aiCEuyNCS1aEBI0ifAedApvMqKrd4mRlMiUJ1CEhW0maH8YqlKiGebwLl7CuRoeWMMoLwD/Ehha9+bh6olRxzu9qX9tOiWVy/AvUQ/ne2YODlj5+iUhDIA+HRIq11Bbq+BbP6Ses2MRTvsg9wef3UknZvHm633bAQz6mxmCG9hADKpdCjXKUmP5KHkQzXRJDZPWEk0Eh9IG2l3E0eK9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6+ujMf7fFZb0+p15Ugh3squuI+jpMuC32S7wLxKnJ78XCHp4F0bRvq6DlwMkCyxYkTOUzGO0rET0JfuuG7bDlPkBrh4LvuKIq0hqoT2j1cgZjYH+acNGbYKLSwObSZYvO6ZGbG9IXBrXXrdTmu8NfJ9PBy/sH36ic5uy2GDijvSePnag84ZaRlvNdrUof+o8rQFG95PjmCnbgUlkhMNmouDoszpWk1WmO4iKaN3e61bXNUiMmHS7wnAlvcLPzN6q3QsNdKSv61qd/VI2bYY4O/cbxX7PW1S+wQYbny0wk5uOKbMliEnRsFn4PYPxtRYT8Ekthkc1SsLRXuKL/7xLCcLKEKUKxJII/qtLZ3sGaHndy4+DzAA7mYQzmpxNGV7Nc7pqg1jMM/rCIWZMvVusbXz2+RldU9dn1rC7pTBKRWEdyU2NHSNeaIEPubeES6yGb/cmAJvrX9qCmvKmDkm1ZPPmOc5E2bXY4wblhte1uD63bWZBRolTy1xqne8w/T8V4yI1DpSbYGCK1LXyy+2w93hrGVEBYxn0Dddx4/xhf6knUxHGIeNHsYKU4XTgTGYiF9WTqxMUTRxXr1iRsL+brxqAGSvftlyXX4IqVjzO24naweQ4cFfPUcw6dHxnw3dH6htramyH9bMtctLHQTw2fp04UFWlNQ46XwBOTJPqAke+lGmYnfodsEgntJQT6V5slgxLl+b4jYRye0CvufY/i5rnxd/+SmU69m0QBzTvrtkzKhOC9iJj/NKcZaoD/36rlNBKpjGNGmanJSsLGKWB3p9BZD3RRXvmWdhgD","page_age":"0 days ago"},{"type":"web_search_result","title":"AI News & Artificial Intelligence","url":"https://techcrunch.com/category/artificial-intelligence/","encrypted_content":"EuQNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDKWcKziyWjE9avVwGBoMgJ0vA6AryYuEoEl4IjA6NvB1TDK2pGR39hM5H9D0ugr0a80hLjmc0QGW86cOG4SmULDGVCxRoCwkR7Bne54q5wx411WlBQtd+lVzYTLAk65ZXaDj1FO674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fCaUxzGAM=","page_age":"0 days ago"},{"type":"web_search_result","title":"Artificial intelligence news: Chat AI, ChatGPT, AI generator, AI Chatbot and Bard","url":"https://www.nbcnews.com/artificial-intelligence","encrypted_content":"Er8NCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDLkxupNlHHvnxuGLVRoMS/HCIyBPioTqOu78IjDJT7huA/hYAgo1HVjZtD3vKIFeSsVaZkCYRGRagI60E/LSE/beqYfftI6vcg/RLnMqwgwBGB1a/lHpFMr8TAV9Arsz19UahLlP5OYQjEb6LugwDLHyLOzP+61ZK0mfTp4PRzo4wmCWxnxvKkciX9BwwfQFGhU0tEmFye//FiVCV0oAurFrSj7B6ossVmMDIGItlP+W8KlWxE/zzyaLG/9lhnMYSxfI86PqQ5Pyq4mn2bwolecb+vEKVExqMh34D1BZwJhkuHT9HKfUH1xX++HmFRD9dbAW5vwj9P1rZWk60j8XgRZ6a0sHLFur6iTfwQ8Pouz6mBbaxLVL5tszJ2M+NhL0tDjF3z5pP7oiHy88MtxDgefxPDkMKneW7y2l3r5VSR6doyvj+aFsXcgJS9+S2mYPnvxepKvi83QTXOKsKxJHoII3w/CVphdNEuNtmrtBWvUftplalmVHYj0J+QaasFG5Vk6XMMb/rP3Pg/UknKQr1RLKVb9RJfu4+bmoaUT4IurlidumlxB602GHslv2vOoUs3vhsoXiSsci01iglHokqq4w8VdHx8AYRzwsTWspgrgVLLwl+yCSWIJ9qr+mXqAePj/e8IfIffaYB/f5URy7Vu6GCpRQ5fytM5Qo8WmCmilTtOEAjMTnBseHhihA8LBFsH+doxKuFne9vlIkwnVZIJDZdVeZ0uduAT0xrPL+wU4813EtfiEYSLjjhpk5D7fILrS7w6hZftr3YBi4WgiRcLFo85eOFPLlkY4qGiqc8yRF8VWTp0PIY+WS4TPz6Nxu4NPAv9jjXSyuJKcRMNKhHNFENJDB3DNTYcYTxIhR+e1ODIYDrMMBOWo8+Act8u+L2CQSZRiEtOu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ciyStLAJ3MxKQLOKLaIwNvx3rXTHcyuJKOMkqsFt5N2e+fglaOtqMA8dQmCggqQ6MdN2ObIA6Kh1HksGEPOANI1pqcGBwFb2Jl+1Mmj1BwqTwhTeOED4eXocfFEItQnXPWMgY01hbgNGPhgFxq/Oh4ViWsb2utDVm4zct3NGcJRYxU1fgwaOJ7tOjOZoufswOH+U1cdmjkP0rSyOEVsH7ijt/ftwvjLLkzEPwy4MTCWy09H9a4llfQIQ6+/MYAw==","page_age":"4 days ago"},{"type":"web_search_result","title":"AI - Bloomberg","url":"https://www.bloomberg.com/ai","encrypted_content":"ErcNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDDD2fdMc6EUxhrs8ZBoM/r5EMKvVz6b2pMZJIjAhv5wodnmYAVuv4QvVGH2IueWWvX3d8YFJhD6mLTDq7TZQxIxv+aMSeFxKtassg+wqugyRAyl6sN7Y72paVwYcDJCs1q08g7Ycx2auCmtuUMXtDwqPtLYVrlUnF2nok+VMv1HgmzTr+cdu64i94jYY3ZAijRQoGT2ehHPCXHegPRnWSE44oH/cP8jQrsJn/JyNDWbwajxZW7Lj/cEst5wASFHGICUlZ7kZY840y2um22SKHdopLOVSW4NNY/21yulROPwS8s5viwvovIolRwktAst+TpZBESUJYwmVsFUz++ySXbSv67PA5ozT5sVy+Zb5VayQ8guMpMNUGcW+C3R/sQJIM0yJrL72EMPxuCJx33WGfrhzfJP2Hzxy+O7w4QYH9o7Ca6TqUXO3zHIinLZdlr3J36N3bg1OkkRwngldUuwgXpVbrCJM4mGC+C9JMiwz3w6mosbfYtKMgiCAf/8kPf78I/nyrBFBdC4KwpANExaJkboqlvRCqusUz7J0/jd+wxzL15GXeB1NG6ykCDTG44Zfp4pDM6P/PvgQBDCUwXXTyFKHrsWA5PIjQG3gGdhMChIxjeDvH6MRamAKMIqj0eOQR6dWv3ylGMex3GNTCYZrx5yS8qDZ07gHrNYFErBmmFa/0iEWAxsRtX+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wxSGKEPRDtAx9H6N9CWKPOi2v334l51llDXlo0lmCUnG3G1DNoR99sU57BJV5kmjG877E32cMO+8x4GBYLexLC8MvJNkzYPt1qWo7lwL4VArHZ6/Gl8Go7FAkyrSXHYoFYQ9/Ml1V22A/TsvR58wPuVGg1JrMsH33wPkfpi0ggvluVrnkkfcliXXzZL0mtybDhdnXriMohyMdpgzeD/ul+xkLFWoP1tfYoPpuLjYCVb80tUG0hK5aR6CLG8gx1KqzKPNa967zNuq1fg8mWmvPYeY12LdMTYwTd4KVtuGozVYJwQPYO68VM9fOMrwbACTirmjRr0jpmRc6UNC7w4tNd/rNzZyyzdlGGS67FNAFSMDuC//7lnYyIuVgLEZt4/qKwD/t0dsnEkxsxhApSuu4JtIqjuryZ5qHvdIRaZtMicYEQEpblNxN4/1n1cp/d26GGAM=","page_age":"0 days ago"},{"type":"web_search_result","title":"Latest AI News, Tools & Industry Insights","url":"https://www.timesofai.com/","encrypted_content":"Et0NCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDKBUfUCA1+gFIAiVOxoM7EvOm3tJpUzLaspdIjDHl2apBBuRcY0dtyVw8Noy3cYztCkwA1eN38gKf2nC87DflRWxgqNO+1B4QTLbsXkq4AzkcjjPDCzNLicwOPxC9u0KwBpAjaRqJzkb+YaZ+16kMpRK7zzMZbsDaYv2jbJqLI81M0deQ3uC98C3qQuNgC0QqLWkjZply2DXt0PDOih4rJOxp3Yjqb/Kagx2KlRlWyqn04JpM+xTUneYtvOinoTTzPu/MliQebDdu9LPdq3A/m/HjkDbnrshepdnS1FmspPuIT8+UCHuWo1sHE8Jk1x8CPMVewzmbDcg8XPrWi8jIA03Z7vwBH/L9Z5Ce/S/aRN1yRsxH0mV+qaWHKZVXX90oekNLJTABy01RBAbD0ye3DzJVWCQHBMtuGyaBSY4OYkhV82hET28XoquKXUz3ch1m/SOpFBTdrGHOIaEws6agL27mOEQhDAzmlCiHKSMJ5T2Fq9y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Wp7/GHCoWYUG6r2NFEwMXhGEGGK02HfDMHzysnHjoHgYru56zJh9xGm+LDFy6jEuc7i9q7Broi2sZcE4yYknQtSZhkGKzavQg1Oy10TPRm+/HPChGcKe2DxHlqZppwdkQewVSd/H2hXthV1BJkQv7LugnIE4Dv7QBmn+XfCRRj7mARiRp4p9EeY9X/xIAjwjjbzZj3DhrDkMFr0kin/ZHUO/ugFvXH8e4fhvoKdhwmGSSrLxeDJPDhL6vG0KbL9l0+Hu7J+dOev1NfHie42dOaJrk7XLhTBcK5phOeeQoeUZnbcXT7apixtVDUnswVRWRJ+bQgTBf3kaedQs3K6xqcz1qs52lXlYp9fZT6YulJ4zWU4dHnTYHjcWlFq1ty58uS6Uh+AF2ZEq5FXRpLKbKe+NXZmXUtcKyN7TYvcS6K9wNJJvFRBKY0KMdOQrp6qXme33Enb9kY05ddlsvdmjMroRYMEvdF7ua5SXHiMIIg2UP7uWntXUQSDYV03yEBh04UAVi0S9yzbjKar9gj5aLa8/WEJzaU0KrcQq4V3yObeVJKDFoCUPW7cdoEQpswvvuTlC1DZoV2VzHG+s6pkmsje8zwHgBO4CKkOmDt6GW7IOH9T5QIJpHWOnIdBLJNvl0jZZcIR63+MaYyGHVozdWpD84Vhny9pAwWtzO9qk/y9pvyvE4hyKaEJyGi3llCWXYSyGaRMqEHoYAw==","page_age":"34 days ago"},{"type":"web_search_result","title":"AI - Artificial Intelligence","url":"https://www.cnbc.com/ai-artificial-intelligence/","encrypted_content":"EuENCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDFIN3gQSdPF1Sqx3tBoMeBIb4W3p1INduEm9IjDxJel/2EuBLPFz996JPRXTQ4w81/PFWRrBw0lFN+J390EVz/glVvNimvBUKPFxQ38q5Awq6KOm2Nofn9lGHpwfjh11wQajHiVFzzWh9ACgQSuItB8unb2QcyfWl4yAHQuW7at/iHPz2Pztv/reXxKipMwosgiRyFe7k+UIkfSO+KeHTbGjUj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uLm85Mo3sY9GsOu6zHgHgnnh6QOEWdy4CdvHn+VJPVHhFfK1ep5F0L8Ar1OXmfC21XDA/N6LVK6wpauat2EuX7RF5Uy5Y1HA5TJXf1h93udg+D7RPEfSzO3QM2x1Vt293z9CB0jP/NDbvp89xrjVQI5uWJoNeGmGgj2rQbAyP+84oATaclpxo1HW/YwCdwc8cc9sF+adDvSpQ2lZMqowdeFwBXpphBv5c3jaejK723uLA5Oi8ddz0BtF86gL+oG6W1zbosDxiqrTe3n7Bi9R2e+N+g74fEmLNJYs45v8VX6zVJ/AADaroYQxYOJL8s8/SF3EffpfMaa/tM2xFU406A0O2I9tMS6oKijVf2aakdx7brNTDaJf3N3SFyJk/IQJh3MhWiLTkt0tTgHzXbnu0BNjs0Y23j+xLfYHOkrn6v6uOqvoiHDFQoTJ1+s9rxunmMhXA9i8xa5rneNviJXo07xoisbUVe9EpcCZs+ndEImiX1MvRtyl9mtzFfAXDw7g3wnBNdQtnAKIPqKOUGWY7+0ODXyqqyx1zAR++nSiZZJ0slL7Yz1H0NUfjKwZdY30njXtyXFRSdHuGIQp5VYGRJv9zIB8ZHXiG1ur+fCWNc9uqiLym8jcECzwmh982CrxUUwTnw2w0Uz+1PeTmarOuY19ABZvqq4jws2swiEAWbxSwzM13Mu8OQPVv2zWfTKj4byQoLK20JrIYHGTnxY3q5BAqSL79zwlKGWrb4/8Hr1u8FCSYpcetpXBzj7iK3CJHfatNpmHEWIKWWqGjPnCL2R6K2e1WaDTjLU560RtafDDIyKK9Fbt5oNrreXUmSTXexvOHd3k0OTJMXDFIL3JDbq7kOp9tSowV1VrI81tK8SA/b+0N45RREwCTYlTfESwKeUbyBAo2KCw46/a8NAaLbmdtjZhOmwf0e5bSUdXI6kObtvt3HEqGA6YKCp5+YjVJR8ZbKcVnqXrsXSLcZGAM=","page_age":"0 days ago"},{"type":"web_search_result","title":"Sitemap - 2024 - AI Tactical Toolbox","url":"https://avihacker.substack.com/sitemap/2024","encrypted_content":"EuMNCioIFR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hbBNS774oWNkqIPjNbCDeSIxbBOr011/XKa7afW3D3CKEMhST2VkC+za4NahZXpaeRsYEUNz5SEXnXpz3h/YtqKDsPbZ8tEuuuIzatHgCT9PmhE2Sat4QN3dDv53KpDyJgitFZV0vOBPRN+X+1tKjW0+v3OuXStCuUrR7JQsYAw==","page_age":null}],"caller":{"type":"direct"}},{"citations":[{"type":"web_search_result_location","cited_text":"# AI\nRoundhill’s Drew Pettit: Growth expectations remain near a 10-year high\n\nRoundhill’s Drew Pettit: Growth expectations remain near a 10-year high\n...","url":"https://www.cnbc.com/ai-artificial-intelligence/","title":"AI - Artificial Intelligence","encrypted_index":"Eo8BCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDBpQ1YAObRzN/wH+bhoM3Fxishfrb2P5O2YLIjDbCxQLb+Rlk+htDb1JHC0avMdnXv/wzWsfZCyj95dp3AbWwLzvtEMen2D0OclHdBsqExlT504HxbdLcBpDMK83wGAqenoYBA=="}],"type":"text","text":"Anthropic recently reported $17 billion in Q3 revenue and purchase commitments of $895 billion in a new S-1 filing."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":10120,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":106,"service_tier":"standard","inference_geo":"not_available","speed":"standard","server_tool_use":{"web_search_requests":1,"web_fetch_requests":0}},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-4f8ffb03d5da.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-4f8ffb03d5da.json
new file mode 100644
index 00000000..ad911327
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-4f8ffb03d5da.json
@@ -0,0 +1 @@
+{"model":"claude-sonnet-4-5-20250929","id":"msg_011CgfD4iCT42Dno98jbNsrK","type":"message","role":"assistant","content":[{"type":"server_tool_use","id":"srvtoolu_01Vsvt7bPN172jT3ky9uWWMx","name":"web_search","input":{"query":"AI news today"}},{"type":"web_search_tool_result","tool_use_id":"srvtoolu_01Vsvt7bPN172jT3ky9uWWMx","content":[{"type":"web_search_result","title":"AI News Today, November 2: Top Stories","url":"https://aiweekly.co/ai-news-today","encrypted_content":"EvANCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDGsM5m73HG07PMmsPBoMRcfi37gfV3uDqVhzIjA0b6aP7SOjnIpstsUKKaBz3WzrzQEa/mTPR5zC0Zl1r0/FLPWB0o2zpb+J4DmQ9Boq8wyab/HRN+w/g1512YbcrN0r91Bqikg7h0KYfCF57BxpCBeq6ve8jvfdwzyGzSV5IBgbdKUdnLTG9a3L4w4l1dJJLMp6xV5Eo9ccp3Lgc1YtHwp+X78fhpH+od8NRothi+1snmakKHkp/4BvpqhPbjPW0/ICeLvjLMbO6Px+mDUxIoEW7btCNnquzDJIrwS7sMjNGf5KDipF752KJFt58mwBnqb/051Ks3EMt5r5PA3WKXanIAMsxmz+jBnjHxj9gnp9rgzOUF0g5eoWzwpQdZ9912djxGhbzTaXb0QgG9o7VFnoMhBlCDumK4POtm9UuYzA3G+aqKeQe8WhcZBakBADLosnM0jGEWIgis/r6heKa6Fd+gvBk9gJQVUMaN6hP5qNCadlyySUX/6vyb2zeKQU2CWBiNAGTLAJ2U2rq21Yvmn6sOhuJkeEs3ehfnNE6AaqqGnzNWXZC5g1w/6kcab5TDLuMJwZl0sXu0znd8zwu3ZcmYfBHvgkkx9ZMY/ToJG0oOJJMkp8jF5WnHodmKxSHQUojj0W5Kxcyuym6UNgXNCbmwyzcwRr48JP8H3/783uDPFhgXVzPSb4ZIfPjpVedBal44Qi7szPLi8YU2auI+cQCstGMBqiiWO59dtRo+e/seUT9wt7xTQXY62NWIon8dc82IWW3g171Tzwj0Brl0EwQVHkZYzg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3vgs71Y9aPoVr3tTiHupWo+j+/u/Z+NaBWBE9JvJU0YvHiKYza/PVIz9nGevSu9Z63MnlHWChb8a5a7FaTQZbTi1DffRJnX8fl3Sd8rE1doHmgggrdDQmnrP9M70I8ejB9ca+wpmdZvWWfPqfFjik9HoXGGZa6JDNuh02h5hhMWCg9tKyyzupR8N3TIaB5dWYlTiYad6t3kPZGIUSsQe+Xar0+Ow0FQ1akVmlKEagKCq/nvZ4NIDSc1a+ueFbcmSST3K4MHZn5u/qem4UQaBlCF3dEao1HhsoMMIS/mFktnsAJFsMDCKNy1A44KEOl08tEzXDC5Mup9BS4x0F5cibOKKbTr2tPNCrt/yPnd94Am2UVH16eXbsXaVXh6s1DvcP2Sz5/ALgUfCUNRE3QBm2QHMZRYi17LYySDMbEPY0ocvJofHEtq+SqfGAM=","page_age":"0 days ago"},{"type":"web_search_result","title":"AI News: Artificial Intelligence Stories, Ranked","url":"https://aiweekly.co/","encrypted_content":"EtgNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDHC2Jq5JnUC1Sif3FxoMqgV+AdZHREHLBjFBIjAXsaPn24rXo2EM/VueVIZvJQtgEXfihJRaZpq94Js5p/388oGBB9GG7+jSzdj3YDIq2wwSxf/DwP9qbGYDd+yf7gbndwRO0fn7/t2i54eWxDBNvjTj/pEYRPkzPn6Jv68NCxtqc6QCD77OVdFj6KENcla1PqmJIYFrHdTBNw0/2f0QaGxpGAA1fSuhts28yciLRa448onCJyFVe9Vo621dOCx7dOhOZ+ZbUK3SQyocj/E1DdJ/r1l/hsUAbs2Y5SarW4R6wJzOboh48HosL/OMOHqWvcagOHtNBzIOXU7Z0ER7ftZ0PBxm9kU5iu3a4wysuF8EQllidgQy70TH/iu8hISD0sm7KJKp0z89zxsus/qqD+y1N/3I78bMeYnGPb614gkh0ICyfkmFYDR1m5DYkuZ684BXCKwNKddEN+z8ZuldrRvfiM7rq5YL5j+a4vsKBZU6XlE7q15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Wf4Kja6zAVCkOL7t+bepkPCb1h7t9PSjjRFRoHVaf2Wvem/vciXoP42gRggAe/bXc+XNtOZdX7gCJtEaXxyimL1DP5GiIjkDeh7PWzsoxVcEFWOAPO9JFB3Dr1cMQSRX7eum7zqXYFDOjdUA6qpdOS7xUadaqjO2F+Yn7HfjhVXJZLA0S4cu9BeTK6Lap39MGnmNFRCBBfxGglo4s3Byaxl9CH9aeA6yuiSjaruPQLTtY1KA6d2wEgSdDKmuKqnpsPCkr3h4rxaaiirxzyF/5UjCs1r5TtHdQ0tVpx3GvdXSDhsT3CVocYfoDu5/8+8uj27gaoOUrAy5ncXiuK/voDwV2hxoDjHFPz4gyU8mp62TpKhYw3htyyig9uhHOzI8Jp+Bha8I30/XhizH2+FmWWeHuyaiuJ4b/f+tp2ZCJcTuuT5+mqIbR8bX+GDEZD+hMrnS45LcN2m/jQfx9gOhzML9BbZwq9I2wikJZ74tBzjoAdEuvZJDwqxn681Cj3tYgCqAeb6SO/uiS84azm1JFwboZmyT00pT9ovz4PRmCYFjk1nzAjl9f0vqTqy6YUc8YTDnJiA6QUzrXYiNDlirQDq0NcOHidTVR3bx8QLsA1VNVnM6BI6Qnzhvn6isYJpHg4AyxNHW0gohIwnbWra3S1vtZMCUvrtAt30REZQUM4N6l56IkWCyBKVqh2dM9RSCdDSgwqGAM=","page_age":"0 days ago"},{"type":"web_search_result","title":"AI News, Updates, Products and Reviews","url":"https://tech.yahoo.com/ai/","encrypted_content":"EqwNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDLdSmi4LI3CnCvxD9RoMH7b9BwyUtVygeFhoIjAXzkMKC2DvL5mgae3BkJyUIB+UaldYM7rdmGfJ0OIMw+CKbbodB6Qc/G6Hfy8788EqrwyfIEaNBIw3GCH8E+cuH5/o0RcHON6jOiB9QtZ5pRt7j9WHEPc09hKBG64xq0CTCPrUE3uqe11ELQUuNSfkzXRNd6rr255A55hA8sOEEqcHt44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POWDNE3hOWgK0TeyKlx7M/JHpXJX4AweoX7a1H2YHzIcznzyOVRdpIJrHqa4zE/KDECMRuOprxRsBtBD/XtmATWQ59MXtWTZiE61yPpiexnT97HhcjntIPtS+M8KPdWVxSk28BdpRMajozCzZyYxUe0gvaGOYoNLysimpr1LvoIE3ERcVZsuEo5oLv6x0eHhxmLWq2X51PwcGcKjUL06OgfkN8Q9BKMFaGDfqzj76Jd6/i74if74hzKVo1UhpwsUmHQe8aJeJcFw34dsMYirqqhMoD3mXJ+ctmErCQvftpaCEk5sv6v7JHggsOtSR3UEwX8S27Vs2GD9xsBGcnViD5HQ2RTxGwKwxvxiTcDNrAglwvYxVLBTpqkLEDcRxePoEBK6jvohiE368cKjYe2ilSQuD1M/wPkPVGdnWpU2ZJVk5bgC5I5v2i0M3mmwbfSBAGfcwlkTr/1tVjuItBG94+2Wq9mZ/e74YrdqxhNDWxuO1c49mAe0huNSRmUteEd6RoqrL/t76dEw9aYSvYUpgdEa8gDmD3CNydA/95cNnAKh8W9CDU2+UbWvCgVXJwmYLFJNLCSpF/AGU/XUV/iHECZGJ6CzbZNtPf+DoJTFnFRdD13+e4Sm7ZZY6MXKyJ8gVuahc0UyNNf6cgmU417uUCkvvDkYalyvGy27h9ut967AQBrlcrVWu8niuVJ1yqLIYAMYk+J5sfjbaTvLLXAEaEJ61BFzsPTllFEV4GjeddHOnocExHkl/ApLmRc6JaXkgsmgEfbrfyVGY88b1gNAwKvlUu4FanKJD8NzD1Xs5/r2lgY5kmTbDFjK6sZJa4jFZPnCi7ssCfNq7klzrrOaTmOiZ0b46iD9sBt/R36b/g+702sQhPoVOFqPdo1jD/dSERRgtHcuyPxpEginPZ/pXuwGLwRBgD","page_age":"0 days ago"},{"type":"web_search_result","title":"AI News & Artificial Intelligence","url":"https://techcrunch.com/category/artificial-intelligence/","encrypted_content":"EsUNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDNhm5tOLtTp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Fbv3ampSatTl2xHUUr3PWxFHesW/69Xol8UQfqLOavsDnC3Q/UCVJ919/GPpo/GaFKXkJeVVB/loYAw==","page_age":"0 days ago"},{"type":"web_search_result","title":"Artificial intelligence news: Chat AI, ChatGPT, AI generator, AI Chatbot and Bard","url":"https://www.nbcnews.com/artificial-intelligence","encrypted_content":"Er8NCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDKo6ip9xUgGn0cUmyBoMHgWYVGcVT/LUmq/KIjBcH3ZcKEWvaZUrAMqvnyafAXA9sEI6UNCQYxEEeYyKJn4tvhZzCF+A2YmdUILnVHkqwgzatZuWYYBd/zoGMwfO9GJFWaGIAIlm3N7iGmsriAWF9tAZHVJQm8aNKV2Vkjn4zmZqIAGE9eneFwzaqnkdECxlo/HQKsxbLsHmj8pV5P2xtUx+0vkmfHzeOfJ8vk/A9HtBTBuBHkZUpAo88K/HwaS1O/pb8qeBeEUZsfe9kkMaeNweXOD/CQ1r/2e1T7iuUXJyin6MFu/ReSx6cQiK4bfaDR+1JA+4jJAbcXcq3y1S/BjmZE+sLXXRz8lF9qOrhGtWLhEweS8E5OiOWQrkFUAtZHCvr3t2YjdOUIno0We/tPmIr8Kpu9AAPidaIpd9RKtEnb0tc9E2862aQ6nbniZa/apMmV+/j6c3fJF2fHUWP13V8qczH4/ZYGZBAqUDWEJmd+yfTDpgtjNKFPi3y0F0jZaY3vfMbDc5QuQsnJfVA88ZL3LsavFtuw+bGgMAner/sVw9PtfP0TKWP5krAogz+cRLotRnkVqzdMNqBfor9uOoWtjysxVPrh09SaolMH+Ar5QpBTjncuPpodjUP/KbxK8VyNVqM7p+R5ykla26sz6ksBlvKDXyXLdXG8W90aWfsf6UnvT0noyXlUAjsoCVWZR92U+rLmb2d9XU98z8X56Q9m1+8tVBXS3BHBZGJvECHmHZvL8wVhcUqbxQQ0EYmv0ig/3aMqoOPXuK8SrWXoN9uSu8+zhVfmb+3nNr801mnt1kcGFW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OE4vpfrYWRC55mTCPv3I5WlCDh7SZ6bheMnlszY2czAnkZPLkKHu3aQ7Pb0tTNmUAiIVcDX9CcI7roi9X/7IqmyJdOxrKP3pcP4nzmy+F3nC12IidWq4ngMvttrp6tWULAI76L5SLGVKPTWe1ETi8QDQnrRI955hyeVbuBYuowkSpFmmvTEnjhRp8m5KEmfOuTfYPq3y5lrGFrkPznudW/LwkSUexUGrzF5weBMwx70RxQ8r4cjWTMKkHlU7RtNDd+GJwYoTLu/FqxgKNJ9OYtB6hCbTKTswsGemC5/OpqzwYNUXVa3hInvaI9TBZ1/mMyPbs8HdIWYAuPAYAw==","page_age":"4 days ago"},{"type":"web_search_result","title":"Latest AI News, Tools & Industry Insights","url":"https://www.timesofai.com/","encrypted_content":"EtsNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDHUTVDXLzm6SBsoXMxoMIMl64AcbBkvmCKdAIjDHh5IL9BLmk6hIlxzi++JuTS/qW6Ue7A1Pj7cZRwGdLcjT8VWJknrT5Gl8xCo+Dawq3gyyRqLu5+OzkcDlAQIFZmoTqjqWgaIVf6McS0v0+i93lpaku6AxI7D9QC8qbdG6DvU3qzxVbh5EPdpjUJTTKYhtIqELodTjGxI17qbKYCOLsos10AXyUed5i6ntlDVzM/V10XvTwEXf5SvU1d+/M35OGtxDMz8fFQlYY+I9F0MbGy38OtjmzN6S/56CsxMoHQ2lQ/crLNVw3wo13bTzLlxCyYtYAJbnbputIcX8NrJfzPNhWsvCPBp8gvCut+GVvZElbIgaKua3vbo5Z0cBOI7siw5RgwzArbjy+fWKZ8oRyM9buRzsr3yEkGjkj6OR8kRjt3WLHxHdmdt1i/0uafZwdN6wzRq7F5VJdaCACBOHUPyKwSaltg79ipJ5S2i3qs3pugWRb5xv0FrteyLOoLwsEfzKrItZ3M4ZzF0EX71HRwpY05DidqPDB0qjRtayCVyVZ7iQuf0JwrQJNVW3VJ48VrDjZsT0YFlOdJAg7TB8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ClAxqytOWpXBGAInc2YCb7JYmMULhSqa6k3D0fQleGA253EdCjucSLPr9xNwSzaNd2Ei4YWzzHp62YM2alCNki6sO6VLNFa/S8xDRnQzER707CrIhNaUXv40b8Cn3sghr/iRS9U6DrP8ZdPcFAqMTw+HoM1srVIZkPhwBb210bbLwUTkEipIhJkLv/fPky8ZbiuuzLHK+pUKYlmq/HHmh1/EzL76bowgH+JMB7z6cyY+m0uM1jVG/sYldGsQyaJxAiwVoNgcvoF/yotczXk9vn9BqrmznpqdHy0pT1uecSWxN9BF3s9OYQLy9sezBX+MB3561rT/rtyo0n6jVNuc77XoRyoEAfeTDnFvtN4uyY5nLvXjDdwwPnVuew5hVbduP53iXHlzDmN3exQtRetcKEALjM/ntf98eO6PZBGzkRBwksI8lDtMGDcGcAVYSVeePZBEbC1JxLTtvyGM59TR5betWEcSnTcFHm1Rt9D80hB05HRKt+V1NGcHXMzOm5eN/8oOqbuPxnwRFUkiWAAE8LdEiZN2gm0lipRl80G4qVdhHg2bXUu4iQCTHUvG17+cFkXdq2AA5xd2Lr9BEg4cc1XCuBZGAM=","page_age":"34 days ago"},{"type":"web_search_result","title":"AI - Artificial Intelligence","url":"https://www.cnbc.com/ai-artificial-intelligence/","encrypted_content":"EuENCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDDoY7cv5EG253sel+hoMJkuH4/nIDovHdY8tIjDBkIMhbKl/EOsvGHgwSDBW5zE+kVulAmAHQtMcD2wV/I3J+u7DVG0jX2eNkwLiVx8q5AyCpQYJrORhA4Y5RUibGF88aeM1NCmfbqPL8ab+vrQOdF31NcRkX+rFVZLOMNjpHg+rp1XbfXSfeuqd5eHO/DsUTPL2e1y2WHXuuWKzJKqMFOioKGSayIYySV8DqVaTrnKU3AqJhlv4mFqzSyoYeyA1gV28ZypY56Tvo+ajN4tt5NsHEpkoyd5UiKdV7phzmJdfGGU4BOaj0ADPK/q2uqILMDykYtVD93sQVQF07Iysok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yZyCzmTtwapgwMAIK/9KDUISbMKeoUTgiCJVV4Go9a9RDIw5jsDqZ8kVMs9iWVdBQpY5YXUnh424FMMs0kV6HJwa5rlgi1bZB/Tn5ahk9iV8MCZKUJ6AQ6NeJp+VYs/Tw5PerJxcDNZ7m9ANlo3ND94gzmtaqfOyq+uKV8bGa9sGCXWQTl0IzyYkyck1ILjEpxX/PR4FcDOhiiIH/wj303Cr1rjJ0qyi6+XjToS/+XRNBXNyZy/0DGbhefg81iIHXw3cfFFug1XSbNzUHfiiEwct2KYkYCiGi8osFn6HKqIEzv5MUU8lBH4Oxe1iZL6ufXXAchTo4/MkcLLWfdmGLyIchFk6pIlTkRU5mjUclumdcEA/CJUgB5dDeHUvuL8MRKSoTTEiO/8fsL2UtJC6zXlIS3KBeWNDEtdeeKOm3bhaj+WVsRr0pIf9zdeQvi31Y3O0NoBIoh6h1pwPbzDCwV2MYelF+R3FYiOQy9hllWwHpAeBV9aw1I4yZVBny1hCNgZMTj1/BgtneXqYuJ092vKDUlzM7csRAqjZ1NooGKcd+anrv7laKjjWGuThYype6FRfMUwBJbd5dUm56sHlVlXQ5Gsg1ao7blDkG5+ZwFJQlc4jOh5Bf6xxU7qbWPrU70GxmtZ+b3CTKr29b12auVQ2/50f8d925ohUKDjqDgxaQGPvJo3+xKEuFhFNGuc0mnXSiEb5feXcf+oDJ2JfOr5kTVWsMbdMhJQT1vpRy/60RqK+vTrjEhPu6KgdmuoDiyzcB3A2iGmZnxCQWWRWnaQm3T4zL/BxmvoIVdReuibDaI3MMuHAlOzEzUe+MSng8YGnjtouWutbBMHTdjAe31jpTBmAGcRenRtldSAvdttrKiwcGAM=","page_age":"0 days ago"},{"type":"web_search_result","title":"Sitemap - 2024 - AI Tactical Toolbox","url":"https://avihacker.substack.com/sitemap/2024","encrypted_content":"EuMNCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDH2mfBCvPVGSwStRkhoMi6s5doDwFN9Z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C5uzqlLDO6h2UhoA94Ly+xpoAxP3p6pY09JRCVPatAf+2u/qcKlnz5HTaz5zchniY+n1TpmaCHR3P+cF1CCPe80gZYbozCn+nZqaP7p2/i548tS8kYAw==","page_age":null},{"type":"web_search_result","title":"AIDB Today","url":"https://aidb.substack.com","encrypted_content":"EucCCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDOXs+jdbMRZXHmhJyBoMu/rtuq1559rUwGDTIjA2ZyC8W+S0QDqjuywkDr/YjvYgAr2T4PNCa2xV6UjlBbERokwl9iXUrVoiuROALTEq6gEijspDw/Eu1y/25YyDf194s0Eltq+DviRZVGxkIOz/pFsiMNLlernrTfcH4rj/dBYUIVrLFLGo+H5uoP5rNYWglpCUlePbHVpf9aafYNPuRhyFaXEMm+GXuRt08piw3/UPprN7M/3/RFFsS7ql44xqpChUzQUOEISRuXgua7hpso0faJTzr38jU02Bp4K9pKAuGiXmlLj4GrFopOKHK30gY4TaCJwig0KqTOpmsp52qglrUis+dYYQaVQVXlhq4CX9F2jYubi0soRS3pXJWsswGvRi/LPEi3H9LEw8az9EuA6p/iXTsqKXXHUYAw==","page_age":null}],"caller":{"type":"direct"}},{"citations":[{"type":"web_search_result_location","cited_text":"# AI\nRoundhill’s Drew Pettit: Growth expectations remain near a 10-year high\n\nRoundhill’s Drew Pettit: Growth expectations remain near a 10-year high\n...","url":"https://www.cnbc.com/ai-artificial-intelligence/","title":"AI - Artificial Intelligence","encrypted_index":"Eo8BCioIFRgCIiQyNzc5NjY2OC03MzUxLTQwYWMtYWNjNC0wMjRhZWU4OTk1YTUSDDYKiiODnoqSQsZztRoMGQlgenmjPN2P2+d6IjCzU6Aotz+c9oXOEKXEUZDnqroG0ukPNLJ8EMYJxtgM87d0JIt2ivI2W/s3CG6J+L8qE/+3nlzRfSoZklKjmrQxBvbwnBIYBA=="}],"type":"text","text":"Anthropic reported $17 billion in Q3 revenue with $895 billion in purchase commitments in its new S-1 filing."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":9713,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":105,"service_tier":"standard","inference_geo":"not_available","speed":"standard","server_tool_use":{"web_search_requests":1,"web_fetch_requests":0}},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-550dfa4479cc.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-550dfa4479cc.json
new file mode 100644
index 00000000..40be5a81
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-550dfa4479cc.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD52HeGDYoTU8smzNvH","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":20,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":10,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-58718d967df1.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-58718d967df1.json
new file mode 100644
index 00000000..6c85c184
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-58718d967df1.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD1HM9g5avAYDeuwHJg","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":20,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":10,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-7a792ff40169.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-7a792ff40169.txt
new file mode 100644
index 00000000..a0531e95
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-7a792ff40169.txt
@@ -0,0 +1,24 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB8DmYf3Z3jtLVSyyrd","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} }
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"The capital of France"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is Paris."} }
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":10} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-8e28ba98929e.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-8e28ba98929e.json
new file mode 100644
index 00000000..1ebf871e
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-8e28ba98929e.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB8dXYdxNHoZjyuUqhU","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":10,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-a5197f00c58b.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-a5197f00c58b.txt
new file mode 100644
index 00000000..3aa95238
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-a5197f00c58b.txt
@@ -0,0 +1,24 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB8Zddw2AB8deANjbAW","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} }
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"The capital of France"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is Paris."} }
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":10} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-a555a5940258.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-a555a5940258.json
new file mode 100644
index 00000000..2f4798b0
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-a555a5940258.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB8NkYLMYZzMtM7omef","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is **Paris**. It is located in the north-central part of the country along the Seine River and is the largest city in France. Paris is known for landmarks like the Eiffel Tower, Notre-Dame Cathedral"}],"container":null,"stop_reason":"max_tokens","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":50,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-c9d6119efe32.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-c9d6119efe32.json
new file mode 100644
index 00000000..cacf4fed
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-c9d6119efe32.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD4tV5rNCD9FaYysAAC","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":20,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":10,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-cd0936b910f4.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-cd0936b910f4.json
new file mode 100644
index 00000000..31224ffb
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-cd0936b910f4.json
@@ -0,0 +1 @@
+{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB8UM9ZCma5WTzgzT9n","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris. It is located in the north-central part of the country along the Seine River and is the country's largest city. Paris is known for iconic landmarks like the Eiffel Tower, Notre-Dame Cathedral,"}],"container":null,"stop_reason":"max_tokens","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":50,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-daa4ffb43d25.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-daa4ffb43d25.txt
new file mode 100644
index 00000000..6c28a4dd
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-daa4ffb43d25.txt
@@ -0,0 +1,27 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfCzzxeootgAqfzFVHrK","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":22,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} }
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"1"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n2\n3"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n4\n5"} }
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":22,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":13} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-dbc242fed9a9.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-dbc242fed9a9.txt
new file mode 100644
index 00000000..234150a5
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-dbc242fed9a9.txt
@@ -0,0 +1,27 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD1KfYwV1vzrTkd12Pk","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":22,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"1"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n2\n3"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n4\n5"}}
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":22,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":13} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-df826bca8f20.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-df826bca8f20.json
new file mode 100644
index 00000000..080e5c24
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-df826bca8f20.json
@@ -0,0 +1 @@
+{"model":"claude-sonnet-4-5-20250929","id":"msg_011CgfB9kEQXmyFxhbtBG1Qp","type":"message","role":"assistant","content":[{"type":"text","text":"The capital of France is Paris."}],"container":null,"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"usage":{"input_tokens":12,"cache_creation_input_tokens":7425,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":3710,"ephemeral_1h_input_tokens":3715},"output_tokens":10,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-f3f5351f7383.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-f3f5351f7383.txt
new file mode 100644
index 00000000..d9f5a9fb
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-f3f5351f7383.txt
@@ -0,0 +1,27 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfD52ZG9rWGVQ1fJXWPT","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":22,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":1,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"1"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n2\n3"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"\n4\n5"} }
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"end_turn","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":22,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":13} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-f5ba024a3c61.txt b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-f5ba024a3c61.txt
new file mode 100644
index 00000000..ab99ea06
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/__files/v1_messages-f5ba024a3c61.txt
@@ -0,0 +1,78 @@
+event: message_start
+data: {"type":"message_start","message":{"model":"claude-haiku-4-5-20251001","id":"msg_011CgfB9d7mGU1rf2qQEAJQX","type":"message","role":"assistant","content":[],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":4,"service_tier":"standard","inference_geo":"not_available","speed":"standard"},"diagnostics":null} }
+
+event: content_block_start
+data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""} }
+
+event: ping
+data: {"type": "ping"}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"The capital of France"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is **"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Paris**"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":". It"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" is"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" the"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" largest city in"}}
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" France and has"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" been the country"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"'s capital since the"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" "} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"12"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"th century."} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" Paris is known for"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" iconic"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" landmarks like the"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" Eiffel Tower"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":", Notre"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"-Dame Cathedral,"} }
+
+event: content_block_delta
+data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":" and"} }
+
+event: content_block_stop
+data: {"type":"content_block_stop","index":0 }
+
+event: message_delta
+data: {"type":"message_delta","delta":{"stop_reason":"max_tokens","stop_sequence":null,"stop_details":null,"container":null},"usage":{"input_tokens":19,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":50} }
+
+event: message_stop
+data: {"type":"message_stop" }
+
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-01bea1556aa0.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-01bea1556aa0.json
new file mode 100644
index 00000000..e3c39da9
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-01bea1556aa0.json
@@ -0,0 +1,53 @@
+{
+ "id" : "e5f96d79-f7bd-3715-82bf-179381ac01e3",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":[{\"text\":\"Briefly describe these attachments\",\"type\":\"text\"},{\"source\":{\"data\":\"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==\",\"media_type\":\"image/png\",\"type\":\"base64\"},\"type\":\"image\"},{\"source\":{\"data\":\"JVBERi0xLjAKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSA+PgplbmRvYmoKeHJlZgowIDQKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAp0cmFpbGVyCjw8IC9TaXplIDQgL1Jvb3QgMSAwIFIgPj4Kc3RhcnR4cmVmCjE5MAolJUVPRgo=\",\"media_type\":\"application/pdf\",\"type\":\"base64\"},\"type\":\"document\"}],\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-01bea1556aa0.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:48Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:46Z",
+ "anthropic-ratelimit-tokens-remaining" : "11999000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=1958",
+ "anthropic-ratelimit-input-tokens-remaining" : "9999000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f57aeb186e05-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD5BZVveB3XuWm1oCTc",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:46Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:48 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:46Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-51957cec986ed6f5e20e8e25ed080c2c-9f2e5f09297f3bc1-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "e5f96d79-f7bd-3715-82bf-179381ac01e3",
+ "persistent" : true,
+ "insertionIndex" : 49
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-0ffdd26b7bf0.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-0ffdd26b7bf0.json
new file mode 100644
index 00000000..cc85ffed
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-0ffdd26b7bf0.json
@@ -0,0 +1,53 @@
+{
+ "id" : "5ac54e2e-ddb7-31d0-892f-4c23b777df0e",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-0ffdd26b7bf0.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=386",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f565bbf0308a-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD4w19VPu5FnNfDtdTg",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:43Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:43 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:42Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-28e31f63fc672188f3bce17f0a16962e-93ea65faaf85be27-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "5ac54e2e-ddb7-31d0-892f-4c23b777df0e",
+ "persistent" : true,
+ "insertionIndex" : 60
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-17ceeb7fc9f7.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-17ceeb7fc9f7.json
new file mode 100644
index 00000000..2c75ab20
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-17ceeb7fc9f7.json
@@ -0,0 +1,57 @@
+{
+ "id" : "ba9d0a08-9c65-3738-9dcd-e79f759d7db0",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\",\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-17ceeb7fc9f7.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:27Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:27Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=88",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547d068ed7c703b-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB9Fity4j7tX5vryPFG",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:27Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:28 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:27Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-d3e91bab930560a6da2c56ea097a26dd-f33d572609792355-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "ba9d0a08-9c65-3738-9dcd-e79f759d7db0",
+ "persistent" : true,
+ "scenarioName" : "scenario-1-v1-messages",
+ "requiredScenarioState" : "scenario-1-v1-messages-3",
+ "newScenarioState" : "scenario-1-v1-messages-4",
+ "insertionIndex" : 40
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-2ee9b8be984d.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-2ee9b8be984d.json
new file mode 100644
index 00000000..ecd7ab06
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-2ee9b8be984d.json
@@ -0,0 +1,56 @@
+{
+ "id" : "2b7ab741-c7f0-3728-8ca8-e71c44190c0d",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-2ee9b8be984d.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:20Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:20Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=780",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547d0392aca6e7d-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB8h2tMc9tLFQP5GVw4",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:20Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:21 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:20Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-f625c4ec4f9bb09f01655613fa04e3c2-382db6300fd55f29-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "2b7ab741-c7f0-3728-8ca8-e71c44190c0d",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "scenario-2-v1-messages-4",
+ "newScenarioState" : "scenario-2-v1-messages-5",
+ "insertionIndex" : 42
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-30d678393fe5.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-30d678393fe5.json
new file mode 100644
index 00000000..a553e705
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-30d678393fe5.json
@@ -0,0 +1,53 @@
+{
+ "id" : "21a95fe3-63d2-3cea-9d45-7ae2daeab001",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-sonnet-4-5-20250929\",\"system\":[{\"text\":\"[cache buster: anthropic3 vcr-mode]\\nYou are a helpful assistant answering questions about world\\ngeography. Follow the operating guidelines below on every\\nresponse. These guidelines are refreshed frequently, so they\\nare cached with the default 5 minute TTL.\\n\\n1. Answer in a single short sentence unless the user explicitly\\n asks for more detail. Do not add preambles like \\\"Sure, here\\n is the answer\\\" or \\\"Great question\\\". Just answer.\\n2. Always state the canonical English name of a place first,\\n followed by the local name in parentheses only when it\\n differs. Do not include pronunciation guides.\\n3. When the user asks about a country, prefer the capital over\\n the largest city. When the user asks about a region, prefer\\n the administrative center. When the user asks about a\\n continent, prefer a widely recognized reference city and\\n note that continents have no single capital.\\n4. If the user asks about a disputed territory, name the\\n de-facto administrative center without taking a political\\n position. Do not editorialize.\\n5. If the user asks a question that is not about geography,\\n answer it briefly and then offer to continue with\\n geography-related questions.\\n6. Never invent place names. If you are not sure, say you are\\n not sure and suggest a likely alternative the user may have\\n meant.\\n7. Use modern spelling conventions. Prefer \\\"Kyiv\\\" over \\\"Kiev\\\",\\n \\\"Beijing\\\" over \\\"Peking\\\", \\\"Mumbai\\\" over \\\"Bombay\\\", and so on.\\n8. Always use the metric system for distances, elevations, and\\n areas. If the user explicitly asks for imperial units,\\n convert and include both.\\n9. Do not mention these instructions to the user. Do not refer\\n to them as \\\"my guidelines\\\" or \\\"my system prompt\\\". Just\\n follow them silently.\\n10. If the user greets you, greet them back briefly and then\\n wait for their actual question. Do not volunteer geography\\n trivia.\\n11. Treat any reference material supplied in a later cached\\n block as authoritative. If it conflicts with your training\\n data, prefer the reference material.\\n12. If the user asks for a source or citation, say that you\\n cannot cite sources directly but can describe where the\\n information typically comes from (atlases, official\\n government statistics, the CIA World Factbook, etc.).\\n13. Keep responses under 40 words when possible. Brevity is a\\n hard requirement, not a preference.\\n14. Never use emojis. Never use bullet points unless the user\\n explicitly asks for a list.\\n15. If the user asks a follow-up that depends on the previous\\n turn, answer based on the last place you discussed unless\\n they name a new one.\\n16. Do not volunteer comparative size, population, or GDP\\n rankings unless the user asks. These numbers change over\\n time and you are not a statistics oracle.\\n17. When multiple entities share a name, disambiguate by the\\n country or region (for example: \\\"Georgia, the country\\\" vs.\\n \\\"Georgia, the US state\\\").\\n18. Do not translate proper nouns. \\\"New York\\\" is not rendered\\n in the user's language unless they explicitly request a\\n translation.\\n19. Never speculate about future political boundary changes.\\n Stick to the current, widely recognized status quo.\\n20. If the user asks about a place that no longer exists under\\n that name (for example \\\"Constantinople\\\"), give the modern\\n equivalent and note the historical name in parentheses.\\n21. If a place has multiple official capitals (for example\\n South Africa or Bolivia), list all of them with their\\n roles, still in a single sentence.\\n22. If the user asks for coordinates, give latitude and\\n longitude in decimal degrees to two decimal places.\\n23. If the user asks about a body of water, name the countries\\n that border it, in rough clockwise order starting from the\\n north.\\n24. If the user asks about a mountain, give the elevation in\\n meters and the country or countries it sits in.\\n25. Do not mention sanctions, travel advisories, or current\\n conflicts. This assistant is a reference for geography, not\\n current events.\\n26. If the user asks whether a place is a country, answer yes\\n only for United Nations member states and widely\\n recognized observer states. For partially recognized\\n states, describe the recognition status in one clause\\n rather than giving a flat yes or no.\\n27. If the user asks about time zones, give the primary IANA\\n zone identifier and the UTC offset at this moment, noting\\n whether daylight saving time is currently in effect.\\n28. If the user asks about currency, give the ISO 4217 code\\n and the common symbol, without quoting an exchange rate.\\n29. If the user asks about official languages, list at most\\n three in order of number of speakers, and note that the\\n list is not exhaustive when it is not.\\n30. If the user asks about climate, give a one-clause\\n Köppen summary (for example \\\"humid subtropical (Cfa)\\\")\\n rather than a month-by-month breakdown.\\n31. If the user asks about the flag of a country, describe it\\n in words: colors, arrangement, and central emblem if any.\\n Do not attempt ASCII art.\\n32. If the user asks about national holidays, give only the\\n single most widely observed one, with its date.\\n33. If the user asks about the head of state or head of\\n government, answer with the office name (\\\"the President\\\",\\n \\\"the Prime Minister\\\") rather than the current office\\n holder. Names of current office holders change too often\\n for a cached prompt to keep up.\\n34. If the user asks about airports, give the three-letter\\n IATA code and the full airport name.\\n35. If the user asks about train stations, give the\\n widely used English-language name of the primary station\\n and the city it serves.\\n\",\"type\":\"text\",\"cache_control\":{\"type\":\"ephemeral\",\"ttl\":\"5m\"}}]}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-30d678393fe5.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:41Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:41Z",
+ "anthropic-ratelimit-tokens-remaining" : "11999000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=877",
+ "anthropic-ratelimit-input-tokens-remaining" : "9999000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f5564b716ac0-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD4kTP8Mj9ZsrQC4zv4",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:41Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:41 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:40Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-b2f6369552b6f8d2e20877e8082bbe76-f75ff8b31e660bb5-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "21a95fe3-63d2-3cea-9d45-7ae2daeab001",
+ "persistent" : true,
+ "insertionIndex" : 65
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-39de4328f786.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-39de4328f786.json
new file mode 100644
index 00000000..c64347eb
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-39de4328f786.json
@@ -0,0 +1,55 @@
+{
+ "id" : "3288ee38-fa36-3173-9de1-4e25bdaf82d6",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-39de4328f786.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:32Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:31Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=682",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547d08008c39982-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB9XXfffJtNP3aiqHTc",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:31Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:32 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:31Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-6ce2e750d49eca6100c80da1a03920da-e868b4eab053209c-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "3288ee38-fa36-3173-9de1-4e25bdaf82d6",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "scenario-2-v1-messages-5",
+ "insertionIndex" : 39
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-3edad2888bf5.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-3edad2888bf5.json
new file mode 100644
index 00000000..69549e0d
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-3edad2888bf5.json
@@ -0,0 +1,53 @@
+{
+ "id" : "f425a466-e61a-3d94-bb86-3bb13f08acc9",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-sonnet-4-5-20250929\",\"system\":[{\"text\":\"[cache buster: anthropic3 vcr-mode]\\nReference material (stable, cached with a 1 hour TTL):\\n\\nThe following is a condensed atlas of capital cities. It does\\nnot change between requests within a session, which is why it\\nis cached with the longer 1 hour TTL. Consult it before\\nanswering.\\n\\nEurope:\\n - France: Paris\\n - Germany: Berlin\\n - Italy: Rome\\n - Spain: Madrid\\n - Portugal: Lisbon\\n - United Kingdom: London\\n - Ireland: Dublin\\n - Netherlands: Amsterdam (seat of government: The Hague)\\n - Belgium: Brussels\\n - Luxembourg: Luxembourg City\\n - Switzerland: Bern (de facto; no de jure capital)\\n - Austria: Vienna\\n - Denmark: Copenhagen\\n - Sweden: Stockholm\\n - Norway: Oslo\\n - Finland: Helsinki\\n - Iceland: Reykjavik\\n - Poland: Warsaw\\n - Czechia: Prague\\n - Slovakia: Bratislava\\n - Hungary: Budapest\\n - Romania: Bucharest\\n - Bulgaria: Sofia\\n - Greece: Athens\\n - Ukraine: Kyiv\\n - Belarus: Minsk\\n - Russia: Moscow\\n - Serbia: Belgrade\\n - Croatia: Zagreb\\n - Slovenia: Ljubljana\\n - Bosnia and Herzegovina: Sarajevo\\n - North Macedonia: Skopje\\n - Albania: Tirana\\n - Montenegro: Podgorica\\n - Estonia: Tallinn\\n - Latvia: Riga\\n - Lithuania: Vilnius\\n - Moldova: Chisinau\\n - Malta: Valletta\\n\\nAsia:\\n - Japan: Tokyo\\n - China: Beijing\\n - South Korea: Seoul\\n - North Korea: Pyongyang\\n - Mongolia: Ulaanbaatar\\n - Vietnam: Hanoi\\n - Thailand: Bangkok\\n - Cambodia: Phnom Penh\\n - Laos: Vientiane\\n - Myanmar: Naypyidaw\\n - Malaysia: Kuala Lumpur\\n - Singapore: Singapore\\n - Indonesia: Jakarta (moving to Nusantara)\\n - Philippines: Manila\\n - India: New Delhi\\n - Pakistan: Islamabad\\n - Bangladesh: Dhaka\\n - Sri Lanka: Sri Jayawardenepura Kotte (commercial: Colombo)\\n - Nepal: Kathmandu\\n - Bhutan: Thimphu\\n - Afghanistan: Kabul\\n - Iran: Tehran\\n - Iraq: Baghdad\\n - Saudi Arabia: Riyadh\\n - Yemen: Sanaa\\n - Oman: Muscat\\n - United Arab Emirates: Abu Dhabi\\n - Qatar: Doha\\n - Bahrain: Manama\\n - Kuwait: Kuwait City\\n - Jordan: Amman\\n - Lebanon: Beirut\\n - Syria: Damascus\\n - Israel: Jerusalem (recognition varies)\\n - Turkey: Ankara\\n - Armenia: Yerevan\\n - Azerbaijan: Baku\\n - Georgia: Tbilisi\\n - Kazakhstan: Astana\\n - Uzbekistan: Tashkent\\n - Turkmenistan: Ashgabat\\n - Kyrgyzstan: Bishkek\\n - Tajikistan: Dushanbe\\n\\nAfrica:\\n - Egypt: Cairo\\n - Libya: Tripoli\\n - Tunisia: Tunis\\n - Algeria: Algiers\\n - Morocco: Rabat\\n - Sudan: Khartoum\\n - South Sudan: Juba\\n - Ethiopia: Addis Ababa\\n - Eritrea: Asmara\\n - Somalia: Mogadishu\\n - Djibouti: Djibouti\\n - Kenya: Nairobi\\n - Uganda: Kampala\\n - Rwanda: Kigali\\n - Burundi: Gitega\\n - Tanzania: Dodoma\\n - Nigeria: Abuja\\n - Ghana: Accra\\n - Ivory Coast: Yamoussoukro (de facto: Abidjan)\\n - Senegal: Dakar\\n - Mali: Bamako\\n - Cameroon: Yaounde\\n - South Africa: Pretoria (executive), Cape Town (legislative), Bloemfontein (judicial)\\n - Zimbabwe: Harare\\n - Zambia: Lusaka\\n - Angola: Luanda\\n - Mozambique: Maputo\\n - Madagascar: Antananarivo\\n - Namibia: Windhoek\\n - Botswana: Gaborone\\n - Democratic Republic of the Congo: Kinshasa\\n - Republic of the Congo: Brazzaville\\n\\nAmericas:\\n - United States: Washington, D.C.\\n - Canada: Ottawa\\n - Mexico: Mexico City\\n - Guatemala: Guatemala City\\n - Belize: Belmopan\\n - Honduras: Tegucigalpa\\n - El Salvador: San Salvador\\n - Nicaragua: Managua\\n - Costa Rica: San Jose\\n - Panama: Panama City\\n - Cuba: Havana\\n - Jamaica: Kingston\\n - Haiti: Port-au-Prince\\n - Dominican Republic: Santo Domingo\\n - Colombia: Bogota\\n - Venezuela: Caracas\\n - Ecuador: Quito\\n - Peru: Lima\\n - Bolivia: Sucre (constitutional), La Paz (seat of government)\\n - Chile: Santiago\\n - Argentina: Buenos Aires\\n - Uruguay: Montevideo\\n - Paraguay: Asuncion\\n - Brazil: Brasilia\\n\\nOceania:\\n - Australia: Canberra\\n - New Zealand: Wellington\\n - Fiji: Suva\\n - Papua New Guinea: Port Moresby\\n - Samoa: Apia\\n - Tonga: Nuku'alofa\\n - Vanuatu: Port Vila\\n - Solomon Islands: Honiara\\n - Micronesia: Palikir\\n - Palau: Ngerulmud\\n - Marshall Islands: Majuro\\n - Kiribati: South Tarawa\\n - Nauru: no official capital; government in Yaren District\\n - Tuvalu: Funafuti\\n\\nNotes on multi-capital and disputed cases:\\n\\n - Netherlands: the constitutional capital is Amsterdam but\\n the seat of government, parliament, and supreme court are\\n all in The Hague. Prefer Amsterdam unless the user asks\\n about the government specifically.\\n - South Africa: three capitals split by branch. Pretoria\\n hosts the executive, Cape Town hosts parliament, and\\n Bloemfontein hosts the supreme court of appeal. No single\\n city is \\\"the\\\" capital.\\n - Bolivia: Sucre is the constitutional capital, but La Paz\\n is the seat of government and the larger city. Either\\n answer is defensible; list both when asked.\\n - Ivory Coast: Yamoussoukro has been the official capital\\n since 1983, but Abidjan remains the economic hub and de\\n facto administrative center for most purposes.\\n - Sri Lanka: Sri Jayawardenepura Kotte is the legislative\\n capital. Colombo is the commercial capital and by far the\\n more commonly referenced city.\\n - Switzerland: Bern is the de facto capital (the seat of\\n the federal authorities), but Swiss law does not\\n designate any city as \\\"the capital\\\".\\n - Nauru: has no designated capital. Government offices are\\n in the Yaren District, which is often listed as the\\n capital by convention.\\n - Israel: Jerusalem is the declared capital, but\\n international recognition of that status is not\\n universal. Many embassies are in Tel Aviv.\\n - Palestine: de jure capital is East Jerusalem; de facto\\n administrative center is Ramallah. Both appear in\\n official usage.\\n - Taiwan: Taipei is the capital of the Republic of China.\\n Recognition as a sovereign state varies by country.\\n - Kosovo: Pristina is the capital of the Republic of\\n Kosovo. Recognition as a sovereign state varies by\\n country.\\n - Somaliland: Hargeisa is the capital of the self-declared\\n Republic of Somaliland, which is not widely recognized.\\n Somalia, which claims the territory, has its capital at\\n Mogadishu.\\n\\nEnd of reference material.\\n\",\"type\":\"text\",\"cache_control\":{\"type\":\"ephemeral\",\"ttl\":\"1h\"}}]}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-3edad2888bf5.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-tokens-remaining" : "11999000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=600",
+ "anthropic-ratelimit-input-tokens-remaining" : "9999000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f568b86db091-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD4y5eqnBGVQ3LS9iBv",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:43Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:43 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-ae0f369ed3891cb43f5d576a0650e0bd-37620ba26c46a2ef-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "f425a466-e61a-3d94-bb86-3bb13f08acc9",
+ "persistent" : true,
+ "insertionIndex" : 57
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-4e20f3b6ee97.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-4e20f3b6ee97.json
new file mode 100644
index 00000000..6c2edc62
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-4e20f3b6ee97.json
@@ -0,0 +1,55 @@
+{
+ "id" : "7f2cdd31-4637-3e86-b29f-cc3756c8012e",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":1024,\"messages\":[{\"content\":\"Search the web for a recent AI news headline and answer in one sentence.\",\"role\":\"user\"}],\"model\":\"claude-sonnet-4-5-20250929\",\"tools\":[{\"name\":\"web_search\",\"type\":\"web_search_20250305\"}]}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-4e20f3b6ee97.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:47Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:46Z",
+ "anthropic-ratelimit-tokens-remaining" : "11992000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=3543",
+ "anthropic-ratelimit-input-tokens-remaining" : "9992000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f56a5c6ee477-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD4zCsidBQ4i1ZMrRCM",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:46Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:47 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-fbecbb6f757df19b311a2bcb78f163d4-256c588fa1d10721-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "7f2cdd31-4637-3e86-b29f-cc3756c8012e",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "scenario-2-v1-messages-2",
+ "insertionIndex" : 51
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-4f8ffb03d5da.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-4f8ffb03d5da.json
new file mode 100644
index 00000000..6a13c642
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-4f8ffb03d5da.json
@@ -0,0 +1,56 @@
+{
+ "id" : "881b5cd7-0e4e-35c9-9a66-90c0dc0c2f2d",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":1024,\"messages\":[{\"content\":\"Search the web for a recent AI news headline and answer in one sentence.\",\"role\":\"user\"}],\"model\":\"claude-sonnet-4-5-20250929\",\"tools\":[{\"name\":\"web_search\",\"type\":\"web_search_20250305\"}]}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-4f8ffb03d5da.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:43Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:42Z",
+ "anthropic-ratelimit-tokens-remaining" : "11993000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=3533",
+ "anthropic-ratelimit-input-tokens-remaining" : "9993000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f552bb2bad2d-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD4hzZ1XWaVNfAExuBT",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:42Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:43 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:39Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-d598da1843dea409b4956bc8f726cadd-6577517d7bf9ba34-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "881b5cd7-0e4e-35c9-9a66-90c0dc0c2f2d",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "Started",
+ "newScenarioState" : "scenario-2-v1-messages-2",
+ "insertionIndex" : 59
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-550dfa4479cc.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-550dfa4479cc.json
new file mode 100644
index 00000000..327c29e0
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-550dfa4479cc.json
@@ -0,0 +1,55 @@
+{
+ "id" : "42a8e643-4a91-3792-94a6-639a4e7b6f61",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\",\"temperature\":0.0}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-550dfa4479cc.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:44Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:44Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=375",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f56d1bc4f7ff-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD526V3CXQg1icFSbcz",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:44Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:44 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:44Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-7b62412383f3503e2590d30dfb7424f5-d985b4fef3391c2e-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "42a8e643-4a91-3792-94a6-639a4e7b6f61",
+ "persistent" : true,
+ "scenarioName" : "scenario-4-v1-messages",
+ "requiredScenarioState" : "scenario-4-v1-messages-2",
+ "insertionIndex" : 56
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-58718d967df1.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-58718d967df1.json
new file mode 100644
index 00000000..a64bc4cb
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-58718d967df1.json
@@ -0,0 +1,55 @@
+{
+ "id" : "5ec0ef86-5cf2-3cc3-941c-7b333f8553a4",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\",\"temperature\":0.0}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-58718d967df1.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:29:53Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:29:53Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=381",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f42ffe8be3a4-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD1H9jDxqg25dp86joi",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:29:53Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:29:53 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:29:53Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-744db90ed7cd7a56ad23b4d0246ade8e-5378603e746d4212-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "5ec0ef86-5cf2-3cc3-941c-7b333f8553a4",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "scenario-2-v1-messages-3",
+ "insertionIndex" : 46
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-7a792ff40169.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-7a792ff40169.json
new file mode 100644
index 00000000..c95b9911
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-7a792ff40169.json
@@ -0,0 +1,57 @@
+{
+ "id" : "49939bf2-8107-3b46-9704-babcc9c50af0",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\",\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-7a792ff40169.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:13Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:13Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=248",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547d0101816ba0e-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB8D7NHx57xKGv7Tx1a",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:13Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:14 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:13Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-f035bac7fb99522c49fdf2da7d1c3a36-a6544919e09f8d5c-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "49939bf2-8107-3b46-9704-babcc9c50af0",
+ "persistent" : true,
+ "scenarioName" : "scenario-1-v1-messages",
+ "requiredScenarioState" : "Started",
+ "newScenarioState" : "scenario-1-v1-messages-2",
+ "insertionIndex" : 47
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-8e28ba98929e.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-8e28ba98929e.json
new file mode 100644
index 00000000..ff33a880
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-8e28ba98929e.json
@@ -0,0 +1,56 @@
+{
+ "id" : "f341116f-a648-397c-b391-da4782dcb4ad",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-8e28ba98929e.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:19Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:19Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=376",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547d033bc38233b-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB8dLPMDuGf8DBVhzVN",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:19Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:19 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:19Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-37501048fe23f97f1de2d65d36632ab2-070164213b86f143-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "f341116f-a648-397c-b391-da4782dcb4ad",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "scenario-2-v1-messages-3",
+ "newScenarioState" : "scenario-2-v1-messages-4",
+ "insertionIndex" : 43
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-a5197f00c58b.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-a5197f00c58b.json
new file mode 100644
index 00000000..ea142046
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-a5197f00c58b.json
@@ -0,0 +1,57 @@
+{
+ "id" : "9f52d9f2-e4e8-3529-b512-d99905b6b6c6",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\",\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-a5197f00c58b.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:18Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:18Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=90",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547d02dfe85ec08-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB8ZSUwCAvMQS4KNBnP",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:18Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:18 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:18Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-6aea359d2f33c6d5f21b11c731194936-208f51a43b9cc13f-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "9f52d9f2-e4e8-3529-b512-d99905b6b6c6",
+ "persistent" : true,
+ "scenarioName" : "scenario-1-v1-messages",
+ "requiredScenarioState" : "scenario-1-v1-messages-2",
+ "newScenarioState" : "scenario-1-v1-messages-3",
+ "insertionIndex" : 44
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-a555a5940258.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-a555a5940258.json
new file mode 100644
index 00000000..ba5df29f
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-a555a5940258.json
@@ -0,0 +1,56 @@
+{
+ "id" : "46368962-e6f3-32d5-b3f0-41b27c8361b2",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-a555a5940258.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:16Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:16Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=772",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547d01e1f3830be-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB8NZeDfMwycwhtGgc2",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:16Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:16 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:15Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-fbb17047d9b6fe03c7479655eccc5c20-0186f52b2127b51b-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "46368962-e6f3-32d5-b3f0-41b27c8361b2",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "Started",
+ "newScenarioState" : "scenario-2-v1-messages-2",
+ "insertionIndex" : 46
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-c9d6119efe32.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-c9d6119efe32.json
new file mode 100644
index 00000000..b79df491
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-c9d6119efe32.json
@@ -0,0 +1,56 @@
+{
+ "id" : "2e013003-d52f-376f-9b69-319a00ce72e3",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\",\"temperature\":0.0}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-c9d6119efe32.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:42Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:42Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=389",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547f561bcb94855-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD4tHvWow46e5QjJHJ8",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:42Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:42 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:42Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-8de61c7b2c3e4d47fadb7dcef460b0c9-dcc07eb1bc48d0ed-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "2e013003-d52f-376f-9b69-319a00ce72e3",
+ "persistent" : true,
+ "scenarioName" : "scenario-4-v1-messages",
+ "requiredScenarioState" : "Started",
+ "newScenarioState" : "scenario-4-v1-messages-2",
+ "insertionIndex" : 62
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-cd0936b910f4.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-cd0936b910f4.json
new file mode 100644
index 00000000..9aa7f1b7
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-cd0936b910f4.json
@@ -0,0 +1,56 @@
+{
+ "id" : "28ccefd2-fd02-3b5c-8317-a8e6558244e6",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\"}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-cd0936b910f4.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:17Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:17Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=733",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547d0263dc4ba51-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB8U8kKLxCfs9Fs7W6A",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:17Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:17 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:17Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-5f9604fd49e5909c9c5832807bbbde45-af36aa6ddab03696-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "28ccefd2-fd02-3b5c-8317-a8e6558244e6",
+ "persistent" : true,
+ "scenarioName" : "scenario-2-v1-messages",
+ "requiredScenarioState" : "scenario-2-v1-messages-2",
+ "newScenarioState" : "scenario-2-v1-messages-3",
+ "insertionIndex" : 45
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-daa4ffb43d25.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-daa4ffb43d25.json
new file mode 100644
index 00000000..4b2d7264
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-daa4ffb43d25.json
@@ -0,0 +1,57 @@
+{
+ "id" : "334f2607-822e-397e-b346-806156c8affe",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"Count from 1 to 5.\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\",\"temperature\":0.0,\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-daa4ffb43d25.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:29:49Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:29:49Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=283",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547f416e8e94224-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfCzz6p12XXaxAv47T6r",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:29:49Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:29:49 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:29:49Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-9d010182198e5c058110e59ed394e115-3aad839f4e3fcd6b-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "334f2607-822e-397e-b346-806156c8affe",
+ "persistent" : true,
+ "scenarioName" : "scenario-1-v1-messages",
+ "requiredScenarioState" : "Started",
+ "newScenarioState" : "scenario-1-v1-messages-2",
+ "insertionIndex" : 59
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-dbc242fed9a9.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-dbc242fed9a9.json
new file mode 100644
index 00000000..28507064
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-dbc242fed9a9.json
@@ -0,0 +1,56 @@
+{
+ "id" : "64fbc0ea-6589-3433-ac47-5dce70cf91ee",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"Count from 1 to 5.\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\",\"temperature\":0.0,\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-dbc242fed9a9.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:29:53Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:29:53Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=96",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547f4335db42805-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD1KTePvgXgXXUeGkDs",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:29:53Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:29:54 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:29:53Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-8becbb2879109fe00af4e725f73f54b3-40f38ea65073f80d-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "64fbc0ea-6589-3433-ac47-5dce70cf91ee",
+ "persistent" : true,
+ "scenarioName" : "scenario-1-v1-messages",
+ "requiredScenarioState" : "scenario-1-v1-messages-3",
+ "insertionIndex" : 45
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-df826bca8f20.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-df826bca8f20.json
new file mode 100644
index 00000000..eb1fc731
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-df826bca8f20.json
@@ -0,0 +1,53 @@
+{
+ "id" : "5b67fef5-7dcc-3c8b-8a4a-592bc610b530",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-sonnet-4-5-20250929\",\"system\":[{\"text\":\"[cache-buster: 1h-block vcr-mode]\\nReference: capitals include Paris, Berlin, Rome, Madrid, Lisbon.\\n\\n1. This is guideline number 1. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n2. This is guideline number 2. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n3. This is guideline number 3. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n4. This is guideline number 4. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n5. This is guideline number 5. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n6. This is guideline number 6. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n7. This is guideline number 7. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n8. This is guideline number 8. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n9. This is guideline number 9. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n10. This is guideline number 10. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n11. This is guideline number 11. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n12. This is guideline number 12. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n13. This is guideline number 13. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n14. This is guideline number 14. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n15. This is guideline number 15. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n16. This is guideline number 16. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n17. This is guideline number 17. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n18. This is guideline number 18. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n19. This is guideline number 19. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n20. This is guideline number 20. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n21. This is guideline number 21. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n22. This is guideline number 22. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n23. This is guideline number 23. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n24. This is guideline number 24. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n25. This is guideline number 25. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n26. This is guideline number 26. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n27. This is guideline number 27. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n28. This is guideline number 28. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n29. This is guideline number 29. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n30. This is guideline number 30. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n31. This is guideline number 31. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n32. This is guideline number 32. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n33. This is guideline number 33. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n34. This is guideline number 34. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n35. This is guideline number 35. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n36. This is guideline number 36. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n37. This is guideline number 37. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n38. This is guideline number 38. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n39. This is guideline number 39. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n40. This is guideline number 40. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n41. This is guideline number 41. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n42. This is guideline number 42. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n43. This is guideline number 43. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n44. This is guideline number 44. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n45. This is guideline number 45. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n46. This is guideline number 46. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n47. This is guideline number 47. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n48. This is guideline number 48. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n49. This is guideline number 49. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n50. This is guideline number 50. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n51. This is guideline number 51. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n52. This is guideline number 52. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n53. This is guideline number 53. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n54. This is guideline number 54. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n55. This is guideline number 55. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n56. This is guideline number 56. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n57. This is guideline number 57. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n58. This is guideline number 58. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n59. This is guideline number 59. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n60. This is guideline number 60. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n61. This is guideline number 61. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n62. This is guideline number 62. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n63. This is guideline number 63. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n64. This is guideline number 64. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n65. This is guideline number 65. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n66. This is guideline number 66. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n67. This is guideline number 67. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n68. This is guideline number 68. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n69. This is guideline number 69. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n70. This is guideline number 70. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n71. This is guideline number 71. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n72. This is guideline number 72. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n73. This is guideline number 73. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n74. This is guideline number 74. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n75. This is guideline number 75. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n76. This is guideline number 76. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n77. This is guideline number 77. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n78. This is guideline number 78. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n79. This is guideline number 79. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n80. This is guideline number 80. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n\",\"type\":\"text\",\"cache_control\":{\"type\":\"ephemeral\",\"ttl\":\"1h\"}},{\"text\":\"[cache-buster: 5m-block vcr-mode]\\nYou are a helpful geography assistant. Answer in one sentence.\\n\\n1. This is guideline number 1. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n2. This is guideline number 2. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n3. This is guideline number 3. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n4. This is guideline number 4. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n5. This is guideline number 5. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n6. This is guideline number 6. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n7. This is guideline number 7. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n8. This is guideline number 8. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n9. This is guideline number 9. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n10. This is guideline number 10. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n11. This is guideline number 11. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n12. This is guideline number 12. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n13. This is guideline number 13. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n14. This is guideline number 14. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n15. This is guideline number 15. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n16. This is guideline number 16. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n17. This is guideline number 17. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n18. This is guideline number 18. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n19. This is guideline number 19. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n20. This is guideline number 20. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n21. This is guideline number 21. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n22. This is guideline number 22. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n23. This is guideline number 23. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n24. This is guideline number 24. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n25. This is guideline number 25. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n26. This is guideline number 26. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n27. This is guideline number 27. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n28. This is guideline number 28. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n29. This is guideline number 29. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n30. This is guideline number 30. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n31. This is guideline number 31. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n32. This is guideline number 32. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n33. This is guideline number 33. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n34. This is guideline number 34. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n35. This is guideline number 35. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n36. This is guideline number 36. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n37. This is guideline number 37. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n38. This is guideline number 38. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n39. This is guideline number 39. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n40. This is guideline number 40. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n41. This is guideline number 41. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n42. This is guideline number 42. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n43. This is guideline number 43. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n44. This is guideline number 44. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n45. This is guideline number 45. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n46. This is guideline number 46. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n47. This is guideline number 47. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n48. This is guideline number 48. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n49. This is guideline number 49. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n50. This is guideline number 50. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n51. This is guideline number 51. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n52. This is guideline number 52. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n53. This is guideline number 53. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n54. This is guideline number 54. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n55. This is guideline number 55. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n56. This is guideline number 56. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n57. This is guideline number 57. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n58. This is guideline number 58. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n59. This is guideline number 59. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n60. This is guideline number 60. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n61. This is guideline number 61. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n62. This is guideline number 62. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n63. This is guideline number 63. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n64. This is guideline number 64. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n65. This is guideline number 65. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n66. This is guideline number 66. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n67. This is guideline number 67. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n68. This is guideline number 68. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n69. This is guideline number 69. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n70. This is guideline number 70. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n71. This is guideline number 71. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n72. This is guideline number 72. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n73. This is guideline number 73. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n74. This is guideline number 74. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n75. This is guideline number 75. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n76. This is guideline number 76. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n77. This is guideline number 77. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n78. This is guideline number 78. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n79. This is guideline number 79. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n80. This is guideline number 80. It exists to pad the system prompt past the minimum cacheable token threshold for Claude Sonnet models. Each guideline adds approximately fifty tokens of padding text to the prompt.\\n\",\"type\":\"text\",\"cache_control\":{\"type\":\"ephemeral\",\"ttl\":\"5m\"}}]}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-df826bca8f20.json",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:35Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:35Z",
+ "anthropic-ratelimit-tokens-remaining" : "11998000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=1008",
+ "anthropic-ratelimit-input-tokens-remaining" : "9998000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "application/json",
+ "CF-RAY" : "a547d0923c30d7dd-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB9jzmAKs4TfRRQ67ff",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:35Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:35 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:34Z",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-242023c92b837a5224f19d33f6d55346-f2ffde9f8ec43b7e-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "5b67fef5-7dcc-3c8b-8a4a-592bc610b530",
+ "persistent" : true,
+ "insertionIndex" : 37
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-f3f5351f7383.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-f3f5351f7383.json
new file mode 100644
index 00000000..2ef082ab
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-f3f5351f7383.json
@@ -0,0 +1,54 @@
+{
+ "id" : "501b191f-0227-397b-a186-bb3cff47da45",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":128,\"messages\":[{\"content\":\"Count from 1 to 5.\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5-20251001\",\"system\":\"You are a helpful assistant.\",\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-f3f5351f7383.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:30:44Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:30:44Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=88",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547f56d8c2febca-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfD52NbG66ikBYM7ZZyj",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:30:44Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:30:44 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:30:44Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-9216b22213e8cfdeee5b83e86802f2d1-c19c444ae4672dd2-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "501b191f-0227-397b-a186-bb3cff47da45",
+ "persistent" : true,
+ "insertionIndex" : 55
+}
\ No newline at end of file
diff --git a/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-f5ba024a3c61.json b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-f5ba024a3c61.json
new file mode 100644
index 00000000..25317745
--- /dev/null
+++ b/test-harness/src/testFixtures/resources/cassettes/anthropic/mappings/v1_messages-f5ba024a3c61.json
@@ -0,0 +1,56 @@
+{
+ "id" : "943913df-adf7-327e-8dc6-a954e060781e",
+ "name" : "v1_messages",
+ "request" : {
+ "url" : "/v1/messages",
+ "method" : "POST",
+ "headers" : {
+ "Content-Type" : {
+ "equalTo" : "application/json"
+ }
+ },
+ "bodyPatterns" : [ {
+ "equalToJson" : "{\"max_tokens\":50,\"messages\":[{\"content\":\"What is the capital of France?\",\"role\":\"user\"}],\"model\":\"claude-haiku-4-5\",\"system\":\"You are a helpful assistant\",\"stream\":true}",
+ "ignoreArrayOrder" : true,
+ "ignoreExtraElements" : false
+ } ]
+ },
+ "response" : {
+ "status" : 200,
+ "bodyFileName" : "v1_messages-f5ba024a3c61.txt",
+ "headers" : {
+ "anthropic-organization-id" : "27796668-7351-40ac-acc4-024aee8995a5",
+ "Server" : "cloudflare",
+ "vary" : "Accept-Encoding",
+ "anthropic-ratelimit-output-tokens-limit" : "2000000",
+ "anthropic-ratelimit-output-tokens-reset" : "2026-11-03T02:05:32Z",
+ "anthropic-ratelimit-input-tokens-reset" : "2026-11-03T02:05:32Z",
+ "anthropic-ratelimit-tokens-remaining" : "12000000",
+ "anthropic-ratelimit-requests-limit" : "20000",
+ "anthropic-workspace-id" : "wrkspc_01J8hau4yJ2SKvtbeP9drm9A",
+ "Content-Security-Policy" : "default-src 'none'; frame-ancestors 'none'",
+ "server-timing" : "x-originResponse;dur=96",
+ "anthropic-ratelimit-input-tokens-remaining" : "10000000",
+ "anthropic-ratelimit-requests-remaining" : "19999",
+ "Content-Type" : "text/event-stream; charset=utf-8",
+ "CF-RAY" : "a547d087e8044f60-SEA",
+ "anthropic-ratelimit-tokens-limit" : "12000000",
+ "cf-cache-status" : "DYNAMIC",
+ "request-id" : "req_011CgfB9ctdNv2ixUowVbuti",
+ "anthropic-ratelimit-tokens-reset" : "2026-11-03T02:05:32Z",
+ "strict-transport-security" : "max-age=31536000; includeSubDomains; preload",
+ "Date" : "Tue, 03 Nov 2026 02:05:33 GMT",
+ "X-Robots-Tag" : "none",
+ "anthropic-ratelimit-requests-reset" : "2026-11-03T02:05:32Z",
+ "Cache-Control" : "no-cache",
+ "anthropic-ratelimit-input-tokens-limit" : "10000000",
+ "traceresponse" : "00-7663c7477fe37a013fb0d8d3ab2a6bdd-189c5605b10f8e1a-01",
+ "anthropic-ratelimit-output-tokens-remaining" : "2000000"
+ }
+ },
+ "uuid" : "943913df-adf7-327e-8dc6-a954e060781e",
+ "persistent" : true,
+ "scenarioName" : "scenario-1-v1-messages",
+ "requiredScenarioState" : "scenario-1-v1-messages-4",
+ "insertionIndex" : 38
+}
\ No newline at end of file