Skip to content

test(e2e): Add gen-ai-libraries app covering AI libraries via OpenRouter - #24456

Open
mydea wants to merge 5 commits into
developfrom
feat/gen-ai-libraries-e2e
Open

mydea wants to merge 5 commits into
developfrom
feat/gen-ai-libraries-e2e

Conversation

@mydea

@mydea mydea commented Sep 17, 2026

Copy link
Copy Markdown
Member

Stacked on #24454.

Adds an optional gen-ai-libraries e2e app that drives every gen-AI library we instrument — OpenAI, Anthropic, Mistral, Together and the Vercel AI SDK — against a real model through the single E2E_OPENROUTER_API_KEY the other AI e2e apps use, with one chat-query route and one forced-tool-call route each.

node-mistral is folded in and removed; Mistral is now one of the covered libraries.

Structure

Shared, framework-agnostic handlers in src/libraries.ts are wired into two runtime entries, selected by a RUNTIME variant (tests/constants.ts), so both instrumentation paths get real-call coverage from one app:

  • node (default) — src/entry.node.ts, an express app with runtime channel injection preloaded via node --import ./src/instrument.node.ts.
  • cloudflare (optionalVariants, RUNTIME=cloudflare) — src/entry.cloudflare.ts, built with vite + @sentry/cloudflare/vite (build-time channel injection) and run on workerd via wrangler dev against the build's generated config (dist/gen_ai_libraries/wrangler.json).

playwright.config.ts picks the start command and port per RUNTIME; the tests (tests/chat.test.ts, tests/tools.test.ts) are runtime-agnostic — they hit baseURL and assert the streamed gen_ai spans, parametrized over the library list in tests/utils.ts.

Why these five

Every call uses openai/gpt-4o-mini. OpenRouter serves an OpenAI-compatible /api/v1/chat/completions and an Anthropic-compatible /api/v1/messages ("Anthropic skin"), so all five SDKs reach it (Together/Mistral via lenient OpenAI-shape parsing, the Vercel AI SDK via @openrouter/ai-sdk-provider). The model is incidental; each SDK's own request/response code path is what's under test.

Two instrumented libraries can't reach OpenRouter and are omitted with a code comment: Google GenAI (native Gemini generateContent format isn't served) and Groq (its SDK hardcodes a /openai/v1 request path OpenRouter doesn't expose). Groq shares Together's OpenAI-compatible instrumentation code path — exercised here — and is covered by the node-integration-tests in the base PR.

Notes

  • The node variant was verified end-to-end against real OpenRouter calls: all five libraries emit the expected gen_ai spans (together_ai, anthropic, mistralai, openai, plus the Vercel AI SDK's gen_ai.generate_content), including recorded tool calls. The Cloudflare variant runs the same suite in CI.
  • Folding in node-mistral drops its Mistral-specific stream-drain edge cases (tee/pipe, dataloader co-instrumentation) in favour of the uniform query+tool-call coverage across libraries.
  • The app is marked optional, so it only runs when the OpenRouter key is present.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.09 kB - -
@sentry/browser - with treeshaking flags 27.35 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.26 kB - -
@sentry/browser (incl. Tracing) 50.6 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.62 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.61 kB - -
@sentry/browser (incl. Tracing, Replay) 90.15 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.25 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.85 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.83 kB - -
@sentry/browser (incl. Feedback) 46.62 kB - -
@sentry/browser (incl. sendFeedback) 34.15 kB - -
@sentry/browser (incl. FeedbackAsync) 39.26 kB - -
@sentry/browser (incl. Metrics) 30.1 kB - -
@sentry/browser (incl. Logs) 30.35 kB - -
@sentry/browser (incl. Metrics & Logs) 31.02 kB - -
@sentry/react 30.84 kB - -
@sentry/react (incl. Tracing) 52.94 kB - -
@sentry/vue 36.34 kB - -
@sentry/vue (incl. Tracing) 52.91 kB - -
@sentry/svelte 29.11 kB - -
CDN Bundle 30.8 kB - -
CDN Bundle (incl. Tracing) 51.15 kB - -
CDN Bundle (incl. Logs, Metrics) 33.06 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 53.14 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.75 kB - -
CDN Bundle (incl. Tracing, Replay) 88.69 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.63 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.73 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.78 kB - -
CDN Bundle - uncompressed 91.16 kB - -
CDN Bundle (incl. Tracing) - uncompressed 152.66 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.73 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 158.61 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 227.14 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 272.23 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 278.17 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 285.93 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 291.86 kB - -
@sentry/nextjs (client) 55.27 kB - -
@sentry/sveltekit (client) 51.05 kB - -
@sentry/core/server 39.63 kB - -
@sentry/core/browser 13.66 kB - -
@sentry/node 133.29 kB +0.02% +25 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 82.11 kB - -
@sentry/node - without tracing 89.89 kB +0.03% +22 B 🔺
@sentry/node - without channel injection 112.15 kB +0.02% +15 B 🔺
@sentry/aws-serverless 98.15 kB +0.03% +20 B 🔺
@sentry/cloudflare (withSentry) - minified 204.69 kB - -
@sentry/cloudflare (withSentry) 509.25 kB - -

View base workflow run

@mydea
mydea added this pull request to stack #24458 September 17, 2026 11:50
@mydea
mydea force-pushed the feat/gen-ai-libraries-e2e branch from 0832515 to 69679f1 Compare September 17, 2026 11:59

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread dev-packages/e2e-tests/test-applications/gen-ai-libraries/tests/utils.ts Outdated
Comment thread dev-packages/e2e-tests/test-applications/gen-ai-libraries/tests/tools.test.ts Outdated
@mydea
mydea force-pushed the feat/gen-ai-libraries-e2e branch from 2771d43 to 48619f0 Compare September 17, 2026 12:21

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread dev-packages/e2e-tests/test-applications/gen-ai-libraries/tests/tools.test.ts Outdated
Comment thread dev-packages/e2e-tests/test-applications/gen-ai-libraries/tests/chat.test.ts Outdated
@mydea
mydea marked this pull request as ready for review September 17, 2026 12:51
@mydea
mydea force-pushed the feat/gen-ai-libraries-e2e branch from 478faed to e771719 Compare September 18, 2026 07:25

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e771719. Configure here.

Comment thread dev-packages/e2e-tests/test-applications/gen-ai-libraries/package.json Outdated
Base automatically changed from feat/groq-together-ai-integrations to develop September 18, 2026 08:15
@mydea
mydea requested review from a team as code owners September 18, 2026 08:15
@mydea
mydea requested review from andreiborza, isaacs and s1gr1d and removed request for a team September 18, 2026 08:15
mydea and others added 4 commits September 18, 2026 10:15
Adds an optional `gen-ai-libraries` e2e app that drives every instrumented gen-AI
*library* — OpenAI, Anthropic, Mistral, Together and the Vercel AI SDK — against
a real model through the single `E2E_OPENROUTER_API_KEY`, with a chat query and a
forced tool call each. Shared, framework-agnostic handlers (`src/libraries.ts`)
run in two runtimes selected by a `RUNTIME` variant (following `hono-4`):

  - node       - express + runtime channel injection (`--import`)
  - cloudflare - a worker built with `vite` + `@sentry/cloudflare/vite`, on workerd

Every call uses `openai/gpt-4o-mini`: OpenRouter serves an OpenAI-compatible
`/api/v1/chat/completions` and an Anthropic-compatible `/api/v1/messages`
("Anthropic skin"), so all five SDKs reach it; the model is incidental, the SDK
code path is what is under test.

Folds in and removes `node-mistral` — Mistral is now one of the covered libraries.

Google GenAI and Groq are omitted: OpenRouter serves neither the native Gemini
`generateContent` format nor Groq's `/openai/v1` request path. Groq shares
Together's OpenAI-compatible instrumentation code path (exercised here) and is
covered by the node-integration-tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Scope every test to its own request's trace with `collectStreamedSpans` and a
provider-aware span match, so a late-arriving span from another request (the four
direct SDKs all report `gen_ai.chat`) can no longer satisfy the wait and flake the
suite.

Assert tool-call capture concretely instead of scanning span JSON for a substring
that also appears in the prompt: the direct SDKs must carry `gen_ai.response.tool_calls`
with the tool, and the Vercel AI case — split into its own test rather than hidden
behind a conditional — must emit a `gen_ai.execute_tool` span whose `gen_ai.tool.name`
is the tool. The prompt no longer names the tool, so the string only appears in a real
tool call.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea
mydea force-pushed the feat/gen-ai-libraries-e2e branch from e771719 to 4b6da1c Compare September 18, 2026 08:15
Comment thread dev-packages/e2e-tests/test-applications/gen-ai-libraries/src/entry.cloudflare.ts Outdated

@chargome chargome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants