From 8884b4af47ae54822df69cc8ec72766232800898 Mon Sep 17 00:00:00 2001 From: lforst <8118419+lforst@users.noreply.github.com> Date: Mon, 3 Aug 2026 12:11:36 +0000 Subject: [PATCH] test(e2e): Test latest cohere provider version with ai sdk --- .../ai-sdk-v7-latest.cassette.json | 69 ++++++++++++++++ .../__cassettes__/ai-sdk-v7.cassette.json | 69 ++++++++++++++++ .../ai-sdk-v7-auto-hook.span-tree.json | 78 +++++++++++++++++++ .../ai-sdk-v7-auto-hook.span-tree.txt | 65 ++++++++++++++++ .../ai-sdk-v7-explicit.span-tree.json | 78 +++++++++++++++++++ .../ai-sdk-v7-explicit.span-tree.txt | 65 ++++++++++++++++ .../ai-sdk-v7-latest-auto-hook.span-tree.json | 78 +++++++++++++++++++ .../ai-sdk-v7-latest-auto-hook.span-tree.txt | 65 ++++++++++++++++ .../ai-sdk-v7-latest-explicit.span-tree.json | 78 +++++++++++++++++++ .../ai-sdk-v7-latest-explicit.span-tree.txt | 65 ++++++++++++++++ .../ai-sdk-instrumentation/assertions.ts | 12 ++- .../ai-sdk-instrumentation/package.json | 6 ++ .../ai-sdk-instrumentation/pnpm-lock.yaml | 59 ++++++++++++++ .../scenario.ai-sdk-v7-explicit.mjs | 6 +- .../scenario.ai-sdk-v7.mjs | 6 +- .../scenario.ai-sdk-v7.ts | 6 +- .../ai-sdk-instrumentation/scenario.impl.mjs | 4 +- 17 files changed, 800 insertions(+), 9 deletions(-) diff --git a/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7-latest.cassette.json b/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7-latest.cassette.json index 7c6f96655..561f7d8cb 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7-latest.cassette.json +++ b/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7-latest.cassette.json @@ -3298,6 +3298,75 @@ "status": 200, "statusText": "OK" } + }, + { + "callIndex": 0, + "id": "064d11f1077567e7", + "matchKey": "POST api.cohere.com/v2/rerank", + "recordedAt": "2026-08-03T11:57:14.820Z", + "request": { + "body": { + "kind": "json", + "value": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "model": "rerank-v3.5", + "query": "Which document is about France?", + "top_n": 2 + } + }, + "headers": {}, + "method": "POST", + "url": "https://api.cohere.com/v2/rerank" + }, + "response": { + "body": { + "kind": "json", + "value": { + "id": "c72e4ff2-1dca-4080-8254-f3b2c45b5068", + "meta": { + "api_version": { + "version": "2" + }, + "billed_units": { + "search_units": 1 + } + }, + "results": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ] + } + }, + "headers": { + "access-control-expose-headers": "X-Debug-Trace-ID", + "alt-svc": "h3=\":443\"; ma=2592000", + "cache-control": "no-cache, no-store, no-transform, must-revalidate, private, max-age=0", + "content-encoding": "gzip", + "content-type": "application/json", + "date": "Mon, 03 Aug 2026 11:57:14 GMT", + "expires": "Thu, 01 Jan 1970 00:00:00 GMT", + "pragma": "no-cache", + "server": "envoy", + "transfer-encoding": "chunked", + "vary": "Origin,Accept-Encoding", + "via": "1.1 google", + "x-accel-expires": "0", + "x-debug-trace-id": "3dec54a6353033a1af9760f8ad511989", + "x-envoy-upstream-service-time": "53" + }, + "status": 200, + "statusText": "OK" + } } ], "meta": { diff --git a/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7.cassette.json b/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7.cassette.json index 0e3a2ec15..e09ff626c 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7.cassette.json +++ b/e2e/scenarios/ai-sdk-instrumentation/__cassettes__/ai-sdk-v7.cassette.json @@ -4198,6 +4198,75 @@ "status": 200, "statusText": "OK" } + }, + { + "callIndex": 0, + "id": "064d11f1077567e7", + "matchKey": "POST api.cohere.com/v2/rerank", + "recordedAt": "2026-08-03T11:56:26.194Z", + "request": { + "body": { + "kind": "json", + "value": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "model": "rerank-v3.5", + "query": "Which document is about France?", + "top_n": 2 + } + }, + "headers": {}, + "method": "POST", + "url": "https://api.cohere.com/v2/rerank" + }, + "response": { + "body": { + "kind": "json", + "value": { + "id": "42b8d590-8594-488a-9b31-6d68f60ccb6c", + "meta": { + "api_version": { + "version": "2" + }, + "billed_units": { + "search_units": 1 + } + }, + "results": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ] + } + }, + "headers": { + "access-control-expose-headers": "X-Debug-Trace-ID", + "alt-svc": "h3=\":443\"; ma=2592000", + "cache-control": "no-cache, no-store, no-transform, must-revalidate, private, max-age=0", + "content-encoding": "gzip", + "content-type": "application/json", + "date": "Mon, 03 Aug 2026 11:56:26 GMT", + "expires": "Thu, 01 Jan 1970 00:00:00 GMT", + "pragma": "no-cache", + "server": "envoy", + "transfer-encoding": "chunked", + "vary": "Origin,Accept-Encoding", + "via": "1.1 google", + "x-accel-expires": "0", + "x-debug-trace-id": "454d4e41ac982f6df3cdf7a38dd09d48", + "x-envoy-upstream-service-time": "78" + }, + "status": 200, + "statusText": "OK" + } } ], "meta": { diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.json b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.json index 779d8f39d..23aa9efd7 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.json +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.json @@ -932,6 +932,84 @@ "testRunId": "" } }, + { + "name": "ai-sdk-rerank-operation", + "children": [ + { + "name": "rerank", + "type": "function", + "children": [ + { + "name": "doRerank", + "type": "llm", + "children": [], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "model": { + "modelId": "rerank-v3.5", + "provider": "cohere.reranking" + }, + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "metadata": { + "operation": "rerank", + "testRunId": "" + } + }, { "name": "ai-sdk-tool-operation", "children": [ diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.txt b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.txt index 738f555b6..defba901b 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.txt +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-auto-hook.span-tree.txt @@ -866,6 +866,71 @@ span_tree: │ metrics: { │ "tokens": 16 │ } + ├── ai-sdk-rerank-operation + │ metadata: { + │ "operation": "rerank", + │ "testRunId": "" + │ } + │ └── rerank [function] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "model": { + │ "modelId": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ }, + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } + │ └── doRerank [llm] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } ├── ai-sdk-tool-operation │ metadata: { │ "operation": "tool", diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.json b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.json index e126e3ed5..659533e9c 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.json +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.json @@ -932,6 +932,84 @@ "testRunId": "" } }, + { + "name": "ai-sdk-rerank-operation", + "children": [ + { + "name": "rerank", + "type": "function", + "children": [ + { + "name": "doRerank", + "type": "llm", + "children": [], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "model": { + "modelId": "rerank-v3.5", + "provider": "cohere.reranking" + }, + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "metadata": { + "operation": "rerank", + "testRunId": "" + } + }, { "name": "ai-sdk-tool-operation", "children": [ diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.txt b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.txt index 656496e68..6689a58a3 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.txt +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-explicit.span-tree.txt @@ -866,6 +866,71 @@ span_tree: │ metrics: { │ "tokens": 16 │ } + ├── ai-sdk-rerank-operation + │ metadata: { + │ "operation": "rerank", + │ "testRunId": "" + │ } + │ └── rerank [function] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "model": { + │ "modelId": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ }, + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } + │ └── doRerank [llm] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } ├── ai-sdk-tool-operation │ metadata: { │ "operation": "tool", diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.json b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.json index 096e62c03..5153cc5d5 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.json +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.json @@ -953,6 +953,84 @@ "testRunId": "" } }, + { + "name": "ai-sdk-rerank-operation", + "children": [ + { + "name": "rerank", + "type": "function", + "children": [ + { + "name": "doRerank", + "type": "llm", + "children": [], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "model": { + "modelId": "rerank-v3.5", + "provider": "cohere.reranking" + }, + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "metadata": { + "operation": "rerank", + "testRunId": "" + } + }, { "name": "ai-sdk-tool-operation", "children": [ diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.txt b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.txt index 61f1961d2..591125a75 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.txt +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-auto-hook.span-tree.txt @@ -886,6 +886,71 @@ span_tree: │ metrics: { │ "tokens": 16 │ } + ├── ai-sdk-rerank-operation + │ metadata: { + │ "operation": "rerank", + │ "testRunId": "" + │ } + │ └── rerank [function] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "model": { + │ "modelId": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ }, + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } + │ └── doRerank [llm] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } ├── ai-sdk-tool-operation │ metadata: { │ "operation": "tool", diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.json b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.json index 096e62c03..5153cc5d5 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.json +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.json @@ -953,6 +953,84 @@ "testRunId": "" } }, + { + "name": "ai-sdk-rerank-operation", + "children": [ + { + "name": "rerank", + "type": "function", + "children": [ + { + "name": "doRerank", + "type": "llm", + "children": [], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "input": { + "documents": [ + "Athens is in Greece.", + "Paris is in France.", + "Lima is in Peru." + ], + "model": { + "modelId": "rerank-v3.5", + "provider": "cohere.reranking" + }, + "query": "Which document is about France?", + "topN": 2 + }, + "output": [ + { + "index": 1, + "relevance_score": 0.06657539 + }, + { + "index": 0, + "relevance_score": 0.015062517 + } + ], + "metadata": { + "braintrust": { + "integration_name": "ai-sdk", + "sdk_language": "typescript" + }, + "model": "rerank-v3.5", + "provider": "cohere.reranking" + } + } + ], + "metadata": { + "operation": "rerank", + "testRunId": "" + } + }, { "name": "ai-sdk-tool-operation", "children": [ diff --git a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.txt b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.txt index 61f1961d2..591125a75 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.txt +++ b/e2e/scenarios/ai-sdk-instrumentation/__snapshots__/ai-sdk-v7-latest-explicit.span-tree.txt @@ -886,6 +886,71 @@ span_tree: │ metrics: { │ "tokens": 16 │ } + ├── ai-sdk-rerank-operation + │ metadata: { + │ "operation": "rerank", + │ "testRunId": "" + │ } + │ └── rerank [function] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "model": { + │ "modelId": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ }, + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } + │ └── doRerank [llm] + │ input: { + │ "documents": [ + │ "Athens is in Greece.", + │ "Paris is in France.", + │ "Lima is in Peru." + │ ], + │ "query": "Which document is about France?", + │ "topN": 2 + │ } + │ output: [ + │ { + │ "index": 1, + │ "relevance_score": 0.06657539 + │ }, + │ { + │ "index": 0, + │ "relevance_score": 0.015062517 + │ } + │ ] + │ metadata: { + │ "braintrust": { + │ "integration_name": "ai-sdk", + │ "sdk_language": "typescript" + │ }, + │ "model": "rerank-v3.5", + │ "provider": "cohere.reranking" + │ } ├── ai-sdk-tool-operation │ metadata: { │ "operation": "tool", diff --git a/e2e/scenarios/ai-sdk-instrumentation/assertions.ts b/e2e/scenarios/ai-sdk-instrumentation/assertions.ts index 30c85555b..b5ca56b71 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/assertions.ts +++ b/e2e/scenarios/ai-sdk-instrumentation/assertions.ts @@ -1086,10 +1086,14 @@ export function defineAISDKInstrumentationAssertions(options: { if (Array.isArray(input?.documents)) { expect(input.documents.length).toBeGreaterThanOrEqual(2); } - expect(trace.parent?.row.metadata).toMatchObject({ - document_count: expect.any(Number), - topN: 2, - }); + if (options.sdkMajorVersion >= 7) { + expect(input?.topN).toBe(2); + } else { + expect(trace.parent?.row.metadata).toMatchObject({ + document_count: expect.any(Number), + topN: 2, + }); + } expect(Array.isArray(trace.parent?.output)).toBe(true); expect( (trace.parent?.output as Array>)?.[0], diff --git a/e2e/scenarios/ai-sdk-instrumentation/package.json b/e2e/scenarios/ai-sdk-instrumentation/package.json index 1e26b8b3c..ae016f661 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/package.json +++ b/e2e/scenarios/ai-sdk-instrumentation/package.json @@ -59,6 +59,10 @@ "ai-sdk-openai-v7-latest": { "package": "@ai-sdk/openai", "range": "4" + }, + "ai-sdk-cohere-v7-latest": { + "package": "@ai-sdk/cohere", + "range": "4" } } } @@ -94,6 +98,8 @@ "ai-sdk-v7-latest": "npm:ai@7.0.0", "ai-sdk-openai-v7": "npm:@ai-sdk/openai@4.0.0", "ai-sdk-openai-v7-latest": "npm:@ai-sdk/openai@4.0.16", + "ai-sdk-cohere-v7": "npm:@ai-sdk/cohere@4.0.0", + "ai-sdk-cohere-v7-latest": "npm:@ai-sdk/cohere@4.0.16", "ai-sdk-workflow-v1": "npm:@ai-sdk/workflow@1.0.8" }, "pnpm": { diff --git a/e2e/scenarios/ai-sdk-instrumentation/pnpm-lock.yaml b/e2e/scenarios/ai-sdk-instrumentation/pnpm-lock.yaml index d2ae22069..3e560a919 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/pnpm-lock.yaml +++ b/e2e/scenarios/ai-sdk-instrumentation/pnpm-lock.yaml @@ -42,6 +42,12 @@ importers: ai-sdk-cohere-v6-latest: specifier: npm:@ai-sdk/cohere@3.0.49 version: '@ai-sdk/cohere@3.0.49(zod@3.25.76)' + ai-sdk-cohere-v7: + specifier: npm:@ai-sdk/cohere@4.0.0 + version: '@ai-sdk/cohere@4.0.0(zod@3.25.76)' + ai-sdk-cohere-v7-latest: + specifier: npm:@ai-sdk/cohere@4.0.16 + version: '@ai-sdk/cohere@4.0.16(zod@3.25.76)' ai-sdk-openai-v3: specifier: npm:@ai-sdk/openai@0.0.62 version: '@ai-sdk/openai@0.0.62(zod@3.25.76)' @@ -159,6 +165,18 @@ packages: peerDependencies: zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/cohere@4.0.0': + resolution: {integrity: sha512-yaUMuKbll4lZ+fU78Ci6h12bzxZUX1L7p97HkSyQZDYk7SHX4YdzIhzrkMXIUEccpTe45AHcZbwzBmdWydI7qQ==} + engines: {node: '>=22'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + + '@ai-sdk/cohere@4.0.16': + resolution: {integrity: sha512-qc1uGesoSnN4YiR8/XPgEPMQ1B4N2M+icJhfAELeKW9pNNhqFb2LN22lGuDlOzY9+LXWz+fsRp//iui/c2sXiQ==} + engines: {node: '>=22'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/gateway@2.0.115': resolution: {integrity: sha512-BLN5eLjzg6mKkbxAf6oP8Z7mEyRihrDzBJr7QlNPZTFvgZJ15peoflUJuskTCZFaisqelj1P4Se1pHY8QBBgBA==} engines: {node: '>=18'} @@ -339,6 +357,12 @@ packages: peerDependencies: zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@5.0.16': + resolution: {integrity: sha512-LWDrmYWkZoAJwMbToUglpR6AmgvtnNtCCGeU9MKlXiSV3Yiu4u73/pVA18sQAAe3kZtCRBY9P31lAfnPekWWyg==} + engines: {node: '>=22'} + peerDependencies: + zod: ^3.25.76 || ^4.1.8 + '@ai-sdk/provider-utils@5.0.2': resolution: {integrity: sha512-EcmdjJb7yggsZPCbS3MFBpvAUnKaPW+QvanU5GzF00XCq0bqqAmvJ3MN19ejlmOETbW8sJNiq6qam48wTcbUNw==} engines: {node: '>=22'} @@ -401,6 +425,10 @@ packages: resolution: {integrity: sha512-e0CpNWJUY7OxAFAnCZkw+ri9QOHWwTs1tXP42782KFGCU07qt8NiXCrCVowyCB5dP2r5/Uls+g2oPd8kOJn9dw==} engines: {node: '>=22'} + '@ai-sdk/provider@4.0.4': + resolution: {integrity: sha512-tbHKNLirllUNF3ZlkCsXnwab2ZV1Sl4b1H/Cp9ruCce15IBmskE8Gwkk0yo9xDWY+jho2of7lVXtwSsyrq7cwQ==} + engines: {node: '>=22'} + '@ai-sdk/react@0.0.70': resolution: {integrity: sha512-GnwbtjW4/4z7MleLiW+TOZC2M29eCg1tOUpuEiYFMmFNZK8mkrqM0PFZMo6UsYeUYMWqEOOcPOU9OQVJMJh7IQ==} engines: {node: '>=18'} @@ -792,6 +820,10 @@ packages: resolution: {integrity: sha512-nt6AMGKW1p/70DF/hGBdJB57B8Tspmbp5gfJ8ilhLnt7kkr2ye7hzD6NVG8GGErk2HWF34igrL2CXmNIkzKqKw==} engines: {node: '>=18'} + undici@7.29.0: + resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==} + engines: {node: '>=20.18.1'} + use-sync-external-store@1.6.0: resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==} peerDependencies: @@ -866,6 +898,18 @@ snapshots: '@ai-sdk/provider-utils': 4.0.7(zod@3.25.76) zod: 3.25.76 + '@ai-sdk/cohere@4.0.0(zod@3.25.76)': + dependencies: + '@ai-sdk/provider': 4.0.0 + '@ai-sdk/provider-utils': 5.0.0(zod@3.25.76) + zod: 3.25.76 + + '@ai-sdk/cohere@4.0.16(zod@3.25.76)': + dependencies: + '@ai-sdk/provider': 4.0.4 + '@ai-sdk/provider-utils': 5.0.16(zod@3.25.76) + zod: 3.25.76 + '@ai-sdk/gateway@2.0.115(zod@3.25.76)': dependencies: '@ai-sdk/provider': 2.0.3 @@ -1066,6 +1110,15 @@ snapshots: eventsource-parser: 3.0.8 zod: 3.25.76 + '@ai-sdk/provider-utils@5.0.16(zod@3.25.76)': + dependencies: + '@ai-sdk/provider': 4.0.4 + '@standard-schema/spec': 1.1.0 + '@workflow/serde': 4.1.0 + eventsource-parser: 3.0.8 + undici: 7.29.0 + zod: 3.25.76 + '@ai-sdk/provider-utils@5.0.2(zod@3.25.76)': dependencies: '@ai-sdk/provider': 4.0.1 @@ -1130,6 +1183,10 @@ snapshots: dependencies: json-schema: 0.4.0 + '@ai-sdk/provider@4.0.4': + dependencies: + json-schema: 0.4.0 + '@ai-sdk/react@0.0.70(react@19.2.6)(zod@3.25.76)': dependencies: '@ai-sdk/provider-utils': 1.0.22(zod@3.25.76) @@ -1519,6 +1576,8 @@ snapshots: throttleit@2.1.0: {} + undici@7.29.0: {} + use-sync-external-store@1.6.0(react@19.2.6): dependencies: react: 19.2.6 diff --git a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7-explicit.mjs b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7-explicit.mjs index 4ef5604db..2796520c6 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7-explicit.mjs +++ b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7-explicit.mjs @@ -1,4 +1,6 @@ const aiPackageName = process.env.AI_SDK_PACKAGE_NAME ?? "ai-sdk-v7-latest"; +const coherePackageName = + process.env.AI_SDK_COHERE_PACKAGE_NAME ?? "ai-sdk-cohere-v7-latest"; const openaiPackageName = process.env.AI_SDK_OPENAI_PACKAGE_NAME ?? "ai-sdk-openai-v7-latest"; const workflowPackageName = process.env.AI_SDK_WORKFLOW_PACKAGE_NAME; @@ -14,6 +16,7 @@ import { runAutoAISDKInstrumentation } from "./scenario.impl.mjs"; runMain(async () => { const ai = await import(aiPackageName); + const { cohere, createCohere } = await import(coherePackageName); const { createOpenAI, openai } = await import(openaiPackageName); const workflow = workflowPackageName ? workflowPackageName === "ai-sdk-workflow-v1" @@ -31,6 +34,8 @@ runMain(async () => { await runAutoAISDKInstrumentation({ agentClassExport: "ToolLoopAgent", ai, + cohere, + createCohere, createOpenAI, maxTokensKey: "maxOutputTokens", openai, @@ -45,7 +50,6 @@ runMain(async () => { supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: false, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, ...(workflow && workflowPackageName diff --git a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.mjs b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.mjs index 7cf47271d..c29f46e3a 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.mjs +++ b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.mjs @@ -1,4 +1,6 @@ const aiPackageName = process.env.AI_SDK_PACKAGE_NAME ?? "ai-sdk-v7-latest"; +const coherePackageName = + process.env.AI_SDK_COHERE_PACKAGE_NAME ?? "ai-sdk-cohere-v7-latest"; const openaiPackageName = process.env.AI_SDK_OPENAI_PACKAGE_NAME ?? "ai-sdk-openai-v7-latest"; const workflowPackageName = process.env.AI_SDK_WORKFLOW_PACKAGE_NAME; @@ -6,6 +8,7 @@ const workflowAIPackageName = process.env.AI_SDK_WORKFLOW_AI_PACKAGE_NAME; import * as pinnedWorkflowAI from "ai"; import * as pinnedWorkflow from "ai-sdk-workflow-v1"; const ai = await import(aiPackageName); +const { cohere, createCohere } = await import(coherePackageName); const { createOpenAI, openai } = await import(openaiPackageName); const workflow = workflowPackageName ? workflowPackageName === "ai-sdk-workflow-v1" @@ -23,6 +26,8 @@ import { runAutoAISDKInstrumentationOrExit } from "./scenario.impl.mjs"; runAutoAISDKInstrumentationOrExit({ agentClassExport: "ToolLoopAgent", ai, + cohere, + createCohere, createOpenAI, maxTokensKey: "maxOutputTokens", openai, @@ -34,7 +39,6 @@ runAutoAISDKInstrumentationOrExit({ supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: false, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, ...(workflow && workflowPackageName diff --git a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.ts b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.ts index 4fd5e7f03..4621bf245 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.ts +++ b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.ts @@ -1,4 +1,6 @@ const aiPackageName = process.env.AI_SDK_PACKAGE_NAME ?? "ai-sdk-v7-latest"; +const coherePackageName = + process.env.AI_SDK_COHERE_PACKAGE_NAME ?? "ai-sdk-cohere-v7-latest"; const openaiPackageName = process.env.AI_SDK_OPENAI_PACKAGE_NAME ?? "ai-sdk-openai-v7-latest"; import { braintrustAISDKTelemetry } from "braintrust"; @@ -10,6 +12,7 @@ import { runAutoAISDKInstrumentation } from "./scenario.impl.mjs"; runMain(async () => { const ai = await import(aiPackageName); + const { cohere, createCohere } = await import(coherePackageName); const { createOpenAI, openai } = await import(openaiPackageName); ai.registerTelemetry(braintrustAISDKTelemetry()); @@ -17,6 +20,8 @@ runMain(async () => { await runAutoAISDKInstrumentation({ agentClassExport: "ToolLoopAgent", ai, + cohere, + createCohere, createOpenAI, maxTokensKey: "maxOutputTokens", openai, @@ -31,7 +36,6 @@ runMain(async () => { supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: false, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, toolSchemaKey: "inputSchema", diff --git a/e2e/scenarios/ai-sdk-instrumentation/scenario.impl.mjs b/e2e/scenarios/ai-sdk-instrumentation/scenario.impl.mjs index 647ab3fe2..288583af5 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/scenario.impl.mjs +++ b/e2e/scenarios/ai-sdk-instrumentation/scenario.impl.mjs @@ -160,6 +160,7 @@ export const AI_SDK_SCENARIO_SPECS = [ { agentClassExport: "ToolLoopAgent", autoEntry: "scenario.ai-sdk-v7.mjs", + cohereModuleName: "ai-sdk-cohere-v7", dependencyName: "ai-sdk-v7", maxTokensKey: "maxOutputTokens", openaiModuleName: "ai-sdk-openai-v7", @@ -172,7 +173,6 @@ export const AI_SDK_SCENARIO_SPECS = [ supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: false, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, supportsWorkflowAgent: true, @@ -186,6 +186,7 @@ export const AI_SDK_SCENARIO_SPECS = [ { agentClassExport: "ToolLoopAgent", autoEntry: "scenario.ai-sdk-v7.mjs", + cohereModuleName: "ai-sdk-cohere-v7-latest", dependencyName: "ai-sdk-v7-latest", maxTokensKey: "maxOutputTokens", openaiModuleName: "ai-sdk-openai-v7-latest", @@ -198,7 +199,6 @@ export const AI_SDK_SCENARIO_SPECS = [ supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: false, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, toolSchemaKey: "inputSchema",