GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test(e2e): Cover Vercel AI decisions in node-openai-decisions-send-to-sentry by andreiborza · Pull Request #25458 · getsentry/sentry-javascript

test(e2e): Cover Vercel AI decisions in node-openai-decisions-send-to-sentry #25458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
andreiborza merged 1 commit into ab/vercel-ai-openai-decide-confidence from ab/e2e-vercel-ai-openai-decide
Oct 21, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

test(e2e): Cover Vercel AI decisions in node-openai-decisions-send-to-sentry #25458

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
58eaebe
test(e2e): Cover Vercel AI decisions in node-openai-decisions-send-to…
andreiborza Oct 16, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

9 changes: 6 additions & 3 deletions 9 dev-packages/e2e-tests/test-applications/node-openai-decisions-send-to-sentry/package.json
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-openai-decisions-send-to-sentry",
"description": "The OpenAI integration for the Decisions API as a user runs it: a plain Sentry.init on an express app, real decisions.create requests against OpenAI, and the gen_ai.decide spans read back from a real Sentry project",
"description": "The OpenAI Decisions API as a user runs it: a plain Sentry.init on an express app, real decisions requests against OpenAI through the openai client and the Vercel AI SDK, and the gen_ai.decide spans read back from a real Sentry project",
"version": "1.0.0",
"private": true,
"type": "module",
Expand All @@ -10,13 +10,16 @@
"test": "playwright test",
"clean": "npx rimraf node_modules dist pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
"test:build-latest": "pnpm install && pnpm add openai@latest && pnpm build",
"test:build-latest": "pnpm install && pnpm add openai@latest ai@latest @ai-sdk/openai@latest && pnpm build",
"test:assert": "pnpm test"
},
"dependencies": {
"@ai-sdk/openai": "4.0.95",
"@sentry/node": "file:../../packed/sentry-node-packed.tgz",
"ai": "7.0.142",
"express": "^4.21.2",
"openai": "7.32.0"
"openai": "7.32.0",
"zod": "^4.1.8"
},
"devDependencies": {
"@playwright/test": "1.64.1",
Expand Down
26 changes: 26 additions & 0 deletions 26 dev-packages/e2e-tests/test-applications/node-openai-decisions-send-to-sentry/src/app.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// `instrument.ts` is preloaded via `node --import`, so Sentry is already initialised here.
import { createOpenAI } from '@ai-sdk/openai';
import * as Sentry from '@sentry/node';
import { experimental_decide } from 'ai';
import express from 'express';
import OpenAI from 'openai';

Expand All @@ -11,6 +13,7 @@ if (!apiKey) {
}

const client = new OpenAI({ apiKey });
const aiSdkOpenAI = createOpenAI({ apiKey });

const MODEL = 'gpt-6-luna';

Expand Down Expand Up @@ -74,6 +77,29 @@ app.get('/decide-image', async (_req, res, next) => {
}
});

// The same decision through the Vercel AI SDK, which calls the Decisions API itself rather than through
// the `openai` client, so the Vercel AI integration records it.
app.get('/vercel-ai-decide', async (_req, res, next) => {
try {
const { answers } = await experimental_decide({
model: aiSdkOpenAI.decisionModel(MODEL),
state: 'I was charged twice this month and want a refund.',
questions: {
wantsRefund: { type: 'boolean', instructions: 'Is a refund requested?' },
department: {
type: 'choice',
instructions: 'Which team should handle this?',
criteria: { billing: 'Charges and refunds', other: 'Anything else' },
},
urgency: { type: 'score', instructions: 'How urgent is this ticket?', criteria: ['low', 'high'] },
},
});
res.send({ traceId: Sentry.getActiveSpan()?.spanContext().traceId, answers });
} catch (error) {
next(error);
}
});

app.use((error: Error, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
res.status(500).send({ message: error.message });
});
Expand Down
65 changes: 65 additions & 0 deletions 65 ...tests/test-applications/node-openai-decisions-send-to-sentry/tests/send-to-sentry.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,68 @@ test('records an image decision with its image data', async ({ baseURL }) => {
{ type: 'evaluation', answers: { is_red: { type: 'predicate', probability: expect.any(Number) } } },
]);
});

test('records a Vercel AI decision with the confidence of its answers', async ({ baseURL }) => {
const response = await fetch(`${baseURL}/vercel-ai-decide`);
const body = await response.json();
expect(response.status, JSON.stringify(body)).toBe(200);
const { traceId }: { traceId: string } = body;

console.log(`Polling for gen_ai.decide span: sentry trace view ${traceTarget(traceId)}`);

let spanId: string | undefined;
await expect
.poll(() => (spanId = findSpanInTrace(traceId, GEN_AI_DECIDE)?.event_id), EVENT_POLLING_OPTIONS)
.toBeDefined();

let attributes: Record<string, unknown> | undefined;
await expect
.poll(() => (attributes = fetchSpanAttributes(traceId, spanId!)), EVENT_POLLING_OPTIONS)
.toMatchObject({
'span.name': `decide ${MODEL}`,
Comment thread

@nicohrubec nicohrubec Oct 19, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

q: is there no attribute for this?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@andreiborza andreiborza Oct 21, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

For span.name? Nah, it's not really an attribute it's a field of a span.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@nicohrubec nicohrubec Oct 21, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

meant more a constant from conventions we could use but not important

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
[SEARCH_SPAN__OP]: GEN_AI_DECIDE,
[SEARCH_SPAN__STATUS]: 'ok',
[SEARCH_ORIGIN]: 'auto.vercelai.channel',
[SEARCH_GEN_AI__OPERATION__NAME]: 'decide',
[SEARCH_GEN_AI__PROVIDER__NAME]: 'openai.decision',
[SEARCH_GEN_AI__REQUEST__MODEL]: MODEL,
});

expect(JSON.parse(attributes![SEARCH_GEN_AI__INPUT__MESSAGES] as string)).toEqual([
{
type: 'evaluation',
state: 'I was charged twice this month and want a refund.',
questions: {
wantsRefund: { type: 'boolean', instructions: 'Is a refund requested?' },
department: {
type: 'choice',
instructions: 'Which team should handle this?',
criteria: { billing: 'Charges and refunds', other: 'Anything else' },
},
urgency: { type: 'score', instructions: 'How urgent is this ticket?', criteria: ['low', 'high'] },
},
},
]);

// The OpenAI provider moves `confidence` into its provider metadata; the span must keep it on the answers.
expect(JSON.parse(attributes![SEARCH_GEN_AI__OUTPUT__MESSAGES] as string)).toEqual([
{
type: 'evaluation',
answers: {
wantsRefund: { type: 'boolean', probability: expect.any(Number) },
department: {
type: 'choice',
choice: expect.stringMatching(/^(billing|other)$/),
probabilities: { billing: expect.any(Number), other: expect.any(Number) },
confidence: expect.any(Number),
},
urgency: {
type: 'score',
score: expect.any(Number),
probabilities: { 0: expect.any(Number), 1: expect.any(Number) },
confidence: expect.any(Number),
},
},
},
]);
});
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.