Skip to content

Commit 44cc789

Browse files
committed
.
1 parent 59d181c commit 44cc789

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export {
170170
export * as metrics from './metrics/public-api';
171171
export type { MetricOptions } from './metrics/public-api';
172172
export { createConsolaReporter } from './integrations/consola';
173-
export { addVercelAiProcessors, processVercelAiSpanAttributes } from './tracing/vercel-ai';
173+
export { addVercelAiProcessors } from './tracing/vercel-ai';
174174
export { _INTERNAL_getSpanContextForToolCallId, _INTERNAL_cleanupToolCallSpanContext } from './tracing/vercel-ai/utils';
175175
export { toolCallSpanContextMap as _INTERNAL_toolCallSpanContextMap } from './tracing/vercel-ai/constants';
176176
export { instrumentOpenAiClient } from './tracing/openai';

packages/core/src/tracing/vercel-ai/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
} from '../ai/gen-ai-attributes';
2828
import { SPAN_TO_OPERATION_NAME, toolCallSpanContextMap, toolDescriptionMap } from './constants';
2929
import type { TokenSummary } from './types';
30+
import { hasSpanStreamingEnabled } from '../spans/hasSpanStreamingEnabled';
3031
import {
3132
accumulateTokensForParent,
3233
applyAccumulatedTokens,
@@ -456,8 +457,15 @@ function processGenerateSpan(span: Span, name: string, attributes: SpanAttribute
456457
span.updateName(`${operationName} ${modelId}`);
457458
}
458459

459-
// Store tool descriptions in the toolDescriptionMap so processSpan can apply them to execute_tool spans
460-
if (attributes[AI_PROMPT_TOOLS_ATTRIBUTE] && Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])) {
460+
// Store tool descriptions in the toolDescriptionMap so processSpan can apply them to execute_tool spans.
461+
// This is only needed for span streaming (transaction path handles this separately)
462+
const client = getClient();
463+
if (
464+
client &&
465+
hasSpanStreamingEnabled(client) &&
466+
attributes[AI_PROMPT_TOOLS_ATTRIBUTE] &&
467+
Array.isArray(attributes[AI_PROMPT_TOOLS_ATTRIBUTE])
468+
) {
461469
const descriptions = new Map<string, string>();
462470

463471
// parse tool names and descriptions from tool string array

0 commit comments

Comments
 (0)