@voltagent/core 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8011,10 +8011,24 @@ var AgentTraceContext = class {
8011
8011
  constructor(observability, operationName, options) {
8012
8012
  this.observability = observability;
8013
8013
  this.tracer = observability.getTracer();
8014
+ const isSubagent = !!options.parentSpan;
8014
8015
  this.commonAttributes = {
8015
- "entity.id": options.agentId,
8016
- "entity.type": "agent",
8017
- "entity.name": options.agentName,
8016
+ // Root entity attributes - only for root agents
8017
+ ...!isSubagent && {
8018
+ "entity.id": options.agentId,
8019
+ "entity.type": "agent",
8020
+ "entity.name": options.agentName
8021
+ },
8022
+ // Subagent attributes - with different namespace
8023
+ ...isSubagent && {
8024
+ "subagent.id": options.agentId,
8025
+ "subagent.name": options.agentName,
8026
+ "subagent.type": "agent",
8027
+ // Keep parent's entity info for filtering - this ensures traces are associated with root agent
8028
+ "entity.id": options.parentAgentId,
8029
+ "entity.type": "agent"
8030
+ },
8031
+ // Common attributes
8018
8032
  ...options.userId && { "user.id": options.userId },
8019
8033
  ...options.conversationId && { "conversation.id": options.conversationId },
8020
8034
  ...options.parentAgentId && { "agent.parent.id": options.parentAgentId },
@@ -8028,14 +8042,17 @@ var AgentTraceContext = class {
8028
8042
  const inputStr = typeof options.input === "string" ? options.input : (0, import_internal5.safeStringify)(options.input);
8029
8043
  spanAttributes.input = inputStr;
8030
8044
  }
8045
+ const spanName = options.parentSpan ? `subagent:${options.agentName || operationName}` : operationName;
8031
8046
  this.rootSpan = this.tracer.startSpan(
8032
- operationName,
8047
+ spanName,
8033
8048
  {
8034
8049
  kind: import_api7.SpanKind.INTERNAL,
8035
8050
  attributes: {
8036
8051
  ...spanAttributes,
8037
- "agent.state": "running"
8052
+ "agent.state": "running",
8038
8053
  // Track initial agent state
8054
+ // Mark as subagent if we have a parent span
8055
+ ...options.parentSpan && { "agent.is_subagent": true }
8039
8056
  }
8040
8057
  },
8041
8058
  parentContext