@@ -20,7 +20,7 @@ import {
2020 SENTRY_OP ,
2121 SENTRY_ORIGIN ,
2222} from '@sentry/conventions/attributes' ;
23- import { GEN_AI_EVALUATE } from '@sentry/conventions/op' ;
23+ import { GEN_AI_DECIDE } from '@sentry/conventions/op' ;
2424import { GEN_AI_RESPONSE_STOP_REASON_ATTRIBUTE } from '../../../../../../packages/server-utils/src/ai/core/gen-ai-attributes' ;
2525import { cleanupChildProcesses , createEsmAndCjsTests } from '../../../../utils/runner' ;
2626import { createEsmTests } from '../../../../utils/runner/createEsmAndCjsTests' ;
@@ -241,7 +241,7 @@ describe('LangChain integration (v1)', () => {
241241 'scenario-typesafe-classifier.mjs' ,
242242 'instrument-with-pii.mjs' ,
243243 ( createRunner , test ) => {
244- test ( 'records a TypeSafeClassifier run as a gen_ai.evaluate span' , async ( ) => {
244+ test ( 'records a TypeSafeClassifier run as a gen_ai.decide span' , async ( ) => {
245245 const runner = createRunner ( ) . ignore ( 'event' ) ;
246246 const spansPromise = runner . collectStreamedSpansUntilSegment ( 'main' ) ;
247247
@@ -250,34 +250,34 @@ describe('LangChain integration (v1)', () => {
250250 const spans = ( await spansPromise ) . filter (
251251 span => span . attributes [ SENTRY_ORIGIN ] ?. value === 'auto.ai.langchain' ,
252252 ) ;
253- expect ( spans . map ( span => span . name ) ) . toEqual ( [ 'evaluate jev-latest' , 'evaluate jev-latest' ] ) ;
254-
255- const [ evaluateSpan , messageEvaluateSpan ] = spans . sort ( ( a , b ) => a . start_timestamp - b . start_timestamp ) ;
256- expect ( evaluateSpan . attributes [ SENTRY_OP ] . value ) . toBe ( GEN_AI_EVALUATE ) ;
257- expect ( evaluateSpan . attributes [ SENTRY_ORIGIN ] . value ) . toBe ( 'auto.ai.langchain' ) ;
258- expect ( evaluateSpan . attributes [ GEN_AI_OPERATION_NAME ] . value ) . toBe ( 'evaluate ' ) ;
259- expect ( evaluateSpan . attributes [ GEN_AI_PROVIDER_NAME ] . value ) . toBe ( 'typesafe' ) ;
260- expect ( evaluateSpan . attributes [ GEN_AI_REQUEST_MODEL ] . value ) . toBe ( 'jev-latest' ) ;
261- expect ( evaluateSpan . attributes [ GEN_AI_RESPONSE_MODEL ] . value ) . toBe ( 'jev-1.13' ) ;
262- expect ( evaluateSpan . attributes [ GEN_AI_USAGE_INPUT_TOKENS ] . value ) . toBe ( 30 ) ;
263- expect ( evaluateSpan . attributes [ GEN_AI_USAGE_OUTPUT_TOKENS ] . value ) . toBe ( 2 ) ;
264- expect ( evaluateSpan . attributes [ GEN_AI_USAGE_TOTAL_TOKENS ] . value ) . toBe ( 32 ) ;
265- expect ( JSON . parse ( evaluateSpan . attributes [ GEN_AI_INPUT_MESSAGES ] . value ) ) . toEqual ( [
253+ expect ( spans . map ( span => span . name ) ) . toEqual ( [ 'decide jev-latest' , 'decide jev-latest' ] ) ;
254+
255+ const [ decideSpan , messageDecideSpan ] = spans . sort ( ( a , b ) => a . start_timestamp - b . start_timestamp ) ;
256+ expect ( decideSpan . attributes [ SENTRY_OP ] . value ) . toBe ( GEN_AI_DECIDE ) ;
257+ expect ( decideSpan . attributes [ SENTRY_ORIGIN ] . value ) . toBe ( 'auto.ai.langchain' ) ;
258+ expect ( decideSpan . attributes [ GEN_AI_OPERATION_NAME ] . value ) . toBe ( 'decide ' ) ;
259+ expect ( decideSpan . attributes [ GEN_AI_PROVIDER_NAME ] . value ) . toBe ( 'typesafe' ) ;
260+ expect ( decideSpan . attributes [ GEN_AI_REQUEST_MODEL ] . value ) . toBe ( 'jev-latest' ) ;
261+ expect ( decideSpan . attributes [ GEN_AI_RESPONSE_MODEL ] . value ) . toBe ( 'jev-1.13' ) ;
262+ expect ( decideSpan . attributes [ GEN_AI_USAGE_INPUT_TOKENS ] . value ) . toBe ( 30 ) ;
263+ expect ( decideSpan . attributes [ GEN_AI_USAGE_OUTPUT_TOKENS ] . value ) . toBe ( 2 ) ;
264+ expect ( decideSpan . attributes [ GEN_AI_USAGE_TOTAL_TOKENS ] . value ) . toBe ( 32 ) ;
265+ expect ( JSON . parse ( decideSpan . attributes [ GEN_AI_INPUT_MESSAGES ] . value ) ) . toEqual ( [
266266 {
267267 type : 'evaluation' ,
268268 state : 'My payouts have been failing.' ,
269269 questions : { urgent : { type : 'noul' , instructions : 'Is this urgent?' } } ,
270270 } ,
271271 ] ) ;
272272 // A message is recorded as the transcript line the classifier sends, not as LangChain's serialized form.
273- expect ( JSON . parse ( messageEvaluateSpan ! . attributes [ GEN_AI_INPUT_MESSAGES ] . value ) ) . toEqual ( [
273+ expect ( JSON . parse ( messageDecideSpan ! . attributes [ GEN_AI_INPUT_MESSAGES ] . value ) ) . toEqual ( [
274274 {
275275 type : 'evaluation' ,
276276 state : 'user: My card was charged twice.' ,
277277 questions : { urgent : { type : 'noul' , instructions : 'Is this urgent?' } } ,
278278 } ,
279279 ] ) ;
280- expect ( JSON . parse ( evaluateSpan . attributes [ GEN_AI_OUTPUT_MESSAGES ] . value ) ) . toEqual ( [
280+ expect ( JSON . parse ( decideSpan . attributes [ GEN_AI_OUTPUT_MESSAGES ] . value ) ) . toEqual ( [
281281 { type : 'evaluation' , answers : { urgent : { type : 'noul' , noul : 0.9 } } } ,
282282 ] ) ;
283283 } ) ;
@@ -305,7 +305,7 @@ describe('LangChain integration (v1)', () => {
305305 const spans = await spansPromise ;
306306 const segment = spans . find ( span => span . is_segment && span . name === 'main' ) ;
307307 expect ( segment ! . attributes [ 'test.recorded_runs' ] . value ) . toBe ( 'RunnableLambda:root,TypeSafeClassifier:child' ) ;
308- expect ( spans . filter ( span => span . attributes [ SENTRY_OP ] ?. value === GEN_AI_EVALUATE ) ) . toHaveLength ( 1 ) ;
308+ expect ( spans . filter ( span => span . attributes [ SENTRY_OP ] ?. value === GEN_AI_DECIDE ) ) . toHaveLength ( 1 ) ;
309309 } ) ;
310310 } ,
311311 {
@@ -330,15 +330,15 @@ describe('LangChain integration (v1)', () => {
330330 await runner . start ( ) . completed ( ) ;
331331
332332 const spans = await spansPromise ;
333- const evaluateSpan = spans . find ( span => span . attributes [ SENTRY_OP ] ?. value === GEN_AI_EVALUATE ) ! ;
333+ const decideSpan = spans . find ( span => span . attributes [ SENTRY_OP ] ?. value === GEN_AI_DECIDE ) ! ;
334334 const chatSpan = spans . find ( span => span . name === 'chat claude-3-5-haiku-20241022' ) ! ;
335335
336336 // The router classifies in `beforeAgent`, inside the agent run, where other chain steps are skipped.
337- expect ( evaluateSpan . name ) . toBe ( 'evaluate jev-latest' ) ;
338- expect ( evaluateSpan . attributes [ SENTRY_ORIGIN ] . value ) . toBe ( 'auto.ai.langchain' ) ;
339- expect ( evaluateSpan . attributes [ GEN_AI_AGENT_NAME ] . value ) . toBe ( 'support_agent' ) ;
340- expect ( evaluateSpan . parent_span_id ) . toBe ( chatSpan . parent_span_id ) ;
341- expect ( JSON . parse ( evaluateSpan . attributes [ GEN_AI_INPUT_MESSAGES ] . value ) ) . toEqual ( [
337+ expect ( decideSpan . name ) . toBe ( 'decide jev-latest' ) ;
338+ expect ( decideSpan . attributes [ SENTRY_ORIGIN ] . value ) . toBe ( 'auto.ai.langchain' ) ;
339+ expect ( decideSpan . attributes [ GEN_AI_AGENT_NAME ] . value ) . toBe ( 'support_agent' ) ;
340+ expect ( decideSpan . parent_span_id ) . toBe ( chatSpan . parent_span_id ) ;
341+ expect ( JSON . parse ( decideSpan . attributes [ GEN_AI_INPUT_MESSAGES ] . value ) ) . toEqual ( [
342342 {
343343 type : 'evaluation' ,
344344 // The router passes the latest human message, which the classifier sends as a transcript line.
@@ -352,7 +352,7 @@ describe('LangChain integration (v1)', () => {
352352 } ,
353353 } ,
354354 ] ) ;
355- expect ( JSON . parse ( evaluateSpan . attributes [ GEN_AI_OUTPUT_MESSAGES ] . value ) ) . toEqual ( [
355+ expect ( JSON . parse ( decideSpan . attributes [ GEN_AI_OUTPUT_MESSAGES ] . value ) ) . toEqual ( [
356356 {
357357 type : 'evaluation' ,
358358 answers : {
0 commit comments