Summary
When using Cohere SDK v7's recommended v2 API via client.v2.chat(), client.v2.chatStream(), client.v2.embed(), or client.v2.rerank(), all calls bypass both the wrapCohere() wrapper and auto-instrumentation, producing zero Braintrust spans. This affects any v7 user following Cohere's recommendation to use the v2 API.
The v8 SDK is unaffected — its V2Client is correctly handled by both instrumentation paths.
What instrumentation is missing
1. Wrapper: wrapCohere() does not wrap the .v2 sub-object
In js/src/wrappers/cohere.ts, the cohereProxy (lines 52–77) intercepts chat, chatStream, embed, and rerank at the top level. When client.v2 is accessed, it hits the default case and returns the raw, unwrapped V2 sub-client via Reflect.get():
function cohereProxy(cohere: CohereClient): CohereClient {
return new Proxy(cohere, {
get(target, prop, receiver) {
switch (prop) {
case "chat": return wrapChat(...);
case "chatStream": return wrapChatStream(...);
case "embed": return wrapEmbed(...);
case "rerank": return wrapRerank(...);
default:
return Reflect.get(target, prop, receiver); // v2 passes through unwrapped
}
},
});
}
The V2 sub-client has its own chat, chatStream, embed, and rerank methods, but they are never wrapped. Since isSupportedCohereClient() checks for exactly these methods, the fix could recursively wrap client.v2 when accessed.
Note: wrapCohere(new CohereClientV2()) works correctly because CohereClientV2 exposes chat/chatStream/embed/rerank directly at the top level. The gap only affects CohereClient instances where the v2 API is accessed via the .v2 namespace.
2. Auto-instrumentation: V2/V2Client class not patched for v7
In js/src/auto-instrumentations/configs/cohere.ts, the v7 configs (lines 4–56) only target CohereClient in Client.js. The internal V2 client class at api/resources/v2/client/Client.js is not patched for v7, even though it is patched for v8 (lines 36–43, 70–82, etc.):
| SDK Version |
CohereClient patched |
V2Client patched |
| v7 (>=7.0.0 <8.0.0) |
Yes (Client.js) |
No |
| v8 (>=8.0.0 <9.0.0) |
Yes (Client.js) |
Yes (api/resources/v2/client/Client.js) |
The v7 SDK has the V2 client at the same file path as v8, but the class name differs by version:
- v7.14.0 through v7.20.x: Class is named
V2
- v7.21.0: Class is renamed to
V2Client (matching v8)
Adding auto-instrumentation configs for v7 would require entries for both class names.
Impact
Cohere's official migration guide recommends v2 API usage. Users on v7 who follow this guidance and call client.v2.chat() get no Braintrust spans, while client.chat() (v1 API) is traced. This creates a silent instrumentation gap where upgrading API usage patterns causes loss of observability.
Braintrust docs status
not_found — Cohere is not listed on the Braintrust wrap-providers page at https://www.braintrust.dev/docs/instrument/wrap-providers.
Upstream references
Local files inspected
js/src/wrappers/cohere.ts (lines 52–77: proxy only intercepts top-level methods, default case passes .v2 through unwrapped)
js/src/auto-instrumentations/configs/cohere.ts (v7 configs at lines 4–56 only target CohereClient; v8 configs at lines 36–43 target V2Client)
js/src/instrumentation/plugins/cohere-channels.ts
js/src/instrumentation/plugins/cohere-plugin.ts
e2e/scenarios/cohere-instrumentation/scenario.impl.mjs (v7 tests only exercise client.chat() v1 API, not client.v2.chat())
Summary
When using Cohere SDK v7's recommended v2 API via
client.v2.chat(),client.v2.chatStream(),client.v2.embed(), orclient.v2.rerank(), all calls bypass both thewrapCohere()wrapper and auto-instrumentation, producing zero Braintrust spans. This affects any v7 user following Cohere's recommendation to use the v2 API.The v8 SDK is unaffected — its
V2Clientis correctly handled by both instrumentation paths.What instrumentation is missing
1. Wrapper:
wrapCohere()does not wrap the.v2sub-objectIn
js/src/wrappers/cohere.ts, thecohereProxy(lines 52–77) interceptschat,chatStream,embed, andrerankat the top level. Whenclient.v2is accessed, it hits thedefaultcase and returns the raw, unwrapped V2 sub-client viaReflect.get():The V2 sub-client has its own
chat,chatStream,embed, andrerankmethods, but they are never wrapped. SinceisSupportedCohereClient()checks for exactly these methods, the fix could recursively wrapclient.v2when accessed.Note:
wrapCohere(new CohereClientV2())works correctly becauseCohereClientV2exposeschat/chatStream/embed/rerankdirectly at the top level. The gap only affectsCohereClientinstances where the v2 API is accessed via the.v2namespace.2. Auto-instrumentation: V2/V2Client class not patched for v7
In
js/src/auto-instrumentations/configs/cohere.ts, the v7 configs (lines 4–56) only targetCohereClientinClient.js. The internal V2 client class atapi/resources/v2/client/Client.jsis not patched for v7, even though it is patched for v8 (lines 36–43, 70–82, etc.):Client.js)Client.js)api/resources/v2/client/Client.js)The v7 SDK has the V2 client at the same file path as v8, but the class name differs by version:
V2V2Client(matching v8)Adding auto-instrumentation configs for v7 would require entries for both class names.
Impact
Cohere's official migration guide recommends v2 API usage. Users on v7 who follow this guidance and call
client.v2.chat()get no Braintrust spans, whileclient.chat()(v1 API) is traced. This creates a silent instrumentation gap where upgrading API usage patterns causes loss of observability.Braintrust docs status
not_found— Cohere is not listed on the Braintrust wrap-providers page at https://www.braintrust.dev/docs/instrument/wrap-providers.Upstream references
api/resources/v2/client/Client.js(same in both v7 and v8)Local files inspected
js/src/wrappers/cohere.ts(lines 52–77: proxy only intercepts top-level methods,defaultcase passes.v2through unwrapped)js/src/auto-instrumentations/configs/cohere.ts(v7 configs at lines 4–56 only targetCohereClient; v8 configs at lines 36–43 targetV2Client)js/src/instrumentation/plugins/cohere-channels.tsjs/src/instrumentation/plugins/cohere-plugin.tse2e/scenarios/cohere-instrumentation/scenario.impl.mjs(v7 tests only exerciseclient.chat()v1 API, notclient.v2.chat())