Skip to content

Conversation

@armans-code
Copy link

@armans-code armans-code commented Nov 23, 2025

Background

Right now, tool call spans are only created if they have a defined execute function. This means that tool calls that don't have an execute function aren't picked up in tracing. Thus, the only way to tell which tool calls were picked is to manually parse + look at the ai.response.toolCalls attribute of a doGenerate/doStream span.

See #10498

Summary

We now emit tool calls spans even if they don't have a defined execute function.

Manual Verification

Ran AI SDK with these changes on a new app and defined a tool call without an execute function. Made sure the OTel spans were emitted.

Example:

{
  _spanContext: {
    traceId: 'e58b6aa4a3529d7d66443c41c13f4e08',
    spanId: 'e1a3b36e0d2b6af9',
    traceFlags: 1,
    traceState: undefined
  },
  kind: 0,
  parentSpanContext: {
    traceId: 'e58b6aa4a3529d7d66443c41c13f4e08',
    spanId: '368d8f9a9c4e8748',
    traceFlags: 1,
    traceState: undefined
  },
  attributes: {
    'operation.name': 'ai.toolCall',
    'ai.operationId': 'ai.toolCall',
    'ai.toolCall.name': 'noop',
    'ai.toolCall.id': 'call_THXOT8HgcOkQpeJYZZj55Yy5',
    'ai.toolCall.args': '{"reason":"User requested to call the noop tool."}'
  },
  links: [],
  events: [],
  startTime: [ 1763855474, 148000000 ],
  resource: r {
    _rawAttributes: [ [Array], [Array], [Array] ],
    _asyncAttributesPending: false,
    _schemaUrl: undefined,
    _memoizedAttributes: undefined
  },
  instrumentationScope: { name: 'ai', version: undefined, schemaUrl: undefined },
  _droppedAttributesCount: 0,
  _droppedEventsCount: 0,
  _droppedLinksCount: 0,
  name: 'ai.toolCall',
  status: { code: 0 },
  endTime: [ 1763855474, 148702750 ],
  _ended: true,
  _duration: [ 0, 702750 ],
  _spanProcessor: Ga { _spanProcessors: [ [Ni] ] },
  _spanLimits: {
    attributeValueLengthLimit: Infinity,
    attributeCountLimit: 128,
    linkCountLimit: 128,
    eventCountLimit: 128,
    attributePerEventCountLimit: 128,
    attributePerLinkCountLimit: 128
  },
  _attributeValueLengthLimit: Infinity,
  _performanceStartTime: 9343.804209,
  _performanceOffset: -0.605224609375,
  _startTimeProvided: false
}

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Related Issues

This is a draft of proposed changes for #10498.

@armans-code armans-code changed the title Arman/tool call spans Emit OTel spans for non-executing tool calls Nov 23, 2025
@armans-code armans-code marked this pull request as ready for review November 23, 2025 04:14
@gr2m gr2m added support feature New feature or request and removed support labels Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/telemetry feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants