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 51d906594..d9d48d88f 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 @@ -3586,6 +3586,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 ed2858c5b..4f104ac6c 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 @@ -4486,6 +4486,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 f9da60d0d..d063363ed 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 b2a75c0ef..48848bccd 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 c6e9afd3c..8467f650d 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 7a8c5b62e..bd6500d55 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 5599b0883..2d9a12695 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 881b0fe6c..7872c5950 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 5599b0883..2d9a12695 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 881b0fe6c..7872c5950 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 509221f8c..173a6e393 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/package.json +++ b/e2e/scenarios/ai-sdk-instrumentation/package.json @@ -63,6 +63,10 @@ "ai-sdk-anthropic-v7-latest": { "package": "@ai-sdk/anthropic", "range": "4" + }, + "ai-sdk-cohere-v7-latest": { + "package": "@ai-sdk/cohere", + "range": "4" } } } @@ -100,6 +104,8 @@ "ai-sdk-openai-v7-latest": "npm:@ai-sdk/openai@4.0.16", "ai-sdk-anthropic-v7": "npm:@ai-sdk/anthropic@4.0.0", "ai-sdk-anthropic-v7-latest": "npm:@ai-sdk/anthropic@4.0.25", + "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 6d101726a..4c2f7e05a 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/pnpm-lock.yaml +++ b/e2e/scenarios/ai-sdk-instrumentation/pnpm-lock.yaml @@ -48,6 +48,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)' @@ -177,6 +183,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'} @@ -910,6 +928,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 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 284bbf821..b0734ec58 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,6 +1,8 @@ const aiPackageName = process.env.AI_SDK_PACKAGE_NAME ?? "ai-sdk-v7-latest"; const anthropicPackageName = process.env.AI_SDK_ANTHROPIC_PACKAGE_NAME ?? "ai-sdk-anthropic-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; @@ -17,6 +19,7 @@ import { runAutoAISDKInstrumentation } from "./scenario.impl.mjs"; runMain(async () => { const ai = await import(aiPackageName); const { anthropic, createAnthropic } = await import(anthropicPackageName); + const { cohere, createCohere } = await import(coherePackageName); const { createOpenAI, openai } = await import(openaiPackageName); const workflow = workflowPackageName ? workflowPackageName === "ai-sdk-workflow-v1" @@ -36,6 +39,8 @@ runMain(async () => { ai, anthropic, createAnthropic, + cohere, + createCohere, createOpenAI, maxTokensKey: "maxOutputTokens", openai, @@ -50,7 +55,6 @@ runMain(async () => { supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: true, - 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 0bd43ff07..7ff2df635 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.mjs +++ b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.mjs @@ -1,6 +1,8 @@ const aiPackageName = process.env.AI_SDK_PACKAGE_NAME ?? "ai-sdk-v7-latest"; const anthropicPackageName = process.env.AI_SDK_ANTHROPIC_PACKAGE_NAME ?? "ai-sdk-anthropic-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; @@ -9,6 +11,7 @@ import * as pinnedWorkflowAI from "ai"; import * as pinnedWorkflow from "ai-sdk-workflow-v1"; const ai = await import(aiPackageName); const { anthropic, createAnthropic } = await import(anthropicPackageName); +const { cohere, createCohere } = await import(coherePackageName); const { createOpenAI, openai } = await import(openaiPackageName); const workflow = workflowPackageName ? workflowPackageName === "ai-sdk-workflow-v1" @@ -28,6 +31,8 @@ runAutoAISDKInstrumentationOrExit({ ai, anthropic, createAnthropic, + cohere, + createCohere, createOpenAI, maxTokensKey: "maxOutputTokens", openai, @@ -39,7 +44,6 @@ runAutoAISDKInstrumentationOrExit({ supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: true, - 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 a44272f20..f80818e11 100644 --- a/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.ts +++ b/e2e/scenarios/ai-sdk-instrumentation/scenario.ai-sdk-v7.ts @@ -1,6 +1,8 @@ const aiPackageName = process.env.AI_SDK_PACKAGE_NAME ?? "ai-sdk-v7-latest"; const anthropicPackageName = process.env.AI_SDK_ANTHROPIC_PACKAGE_NAME ?? "ai-sdk-anthropic-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"; @@ -13,6 +15,7 @@ import { runAutoAISDKInstrumentation } from "./scenario.impl.mjs"; runMain(async () => { const ai = await import(aiPackageName); const { anthropic, createAnthropic } = await import(anthropicPackageName); + const { cohere, createCohere } = await import(coherePackageName); const { createOpenAI, openai } = await import(openaiPackageName); ai.registerTelemetry(braintrustAISDKTelemetry()); @@ -22,6 +25,8 @@ runMain(async () => { ai, anthropic, createAnthropic, + cohere, + createCohere, createOpenAI, maxTokensKey: "maxOutputTokens", openai, @@ -36,7 +41,6 @@ runMain(async () => { supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: true, - 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 df1b11d14..c369f8240 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", @@ -173,7 +174,6 @@ export const AI_SDK_SCENARIO_SPECS = [ supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: true, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, supportsWorkflowAgent: true, @@ -187,6 +187,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", @@ -200,7 +201,6 @@ export const AI_SDK_SCENARIO_SPECS = [ supportsOpenAICacheScenario: false, supportsOutputObjectScenario: true, supportsProviderCacheAssertions: true, - supportsRerank: false, supportsStreamObject: true, supportsToolExecution: true, toolSchemaKey: "inputSchema",