@iqai/adk 0.6.2 → 0.6.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @iqai/adk
2
2
 
3
+ ## 0.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ad1b38b: Improve tracing with sequential span indices for better observability.
8
+ - Add span counters to `InvocationContext` for tracking LLM, tool, and agent invocations
9
+ - Update trace span names to include indices (e.g., `agent_run [my-agent] #1`, `execute_tool [search] #1`, `llm_generate [gpt-4] #1`)
10
+ - Include app name in invocation span for better traceability
11
+ - Disable auto instrumentation by default to reduce trace noise
12
+ - Update telemetry documentation with new span naming conventions
13
+
3
14
  ## 0.6.2
4
15
 
5
16
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3497,6 +3497,11 @@ declare class TranscriptionEntry {
3497
3497
  });
3498
3498
  }
3499
3499
 
3500
+ type SpanCounters = {
3501
+ llm: number;
3502
+ tool: number;
3503
+ agent: number;
3504
+ };
3500
3505
  /**
3501
3506
  * Transfer context for multi-agent workflows
3502
3507
  * Tracks the chain of agent transfers for telemetry
@@ -3560,7 +3565,7 @@ declare function newInvocationContextId(): string;
3560
3565
  * ┌─────────────────────── invocation ──────────────────────────┐
3561
3566
  * ┌──────────── llm_agent_call_1 ────────────┐ ┌─ agent_call_2 ─┐
3562
3567
  * ┌──── step_1 ────────┐ ┌───── step_2 ──────┐
3563
- * [call_llm] [call_tool] [call_llm] [transfer]
3568
+ * [llm_generate] [execute_tool] [llm_generate] [transfer]
3564
3569
  *
3565
3570
  */
3566
3571
  declare class InvocationContext {
@@ -3640,6 +3645,7 @@ declare class InvocationContext {
3640
3645
  * of this invocation.
3641
3646
  */
3642
3647
  private readonly _invocationCostManager;
3648
+ private readonly _spanCounters;
3643
3649
  /**
3644
3650
  * Constructor for InvocationContext
3645
3651
  */
@@ -3660,6 +3666,7 @@ declare class InvocationContext {
3660
3666
  runConfig?: RunConfig;
3661
3667
  contextCacheConfig?: ContextCacheConfig;
3662
3668
  transferContext?: TransferContext;
3669
+ spanCounters?: SpanCounters;
3663
3670
  });
3664
3671
  /**
3665
3672
  * App name from the session
@@ -3675,6 +3682,22 @@ declare class InvocationContext {
3675
3682
  * @throws {LlmCallsLimitExceededError} If number of llm calls made exceed the set threshold.
3676
3683
  */
3677
3684
  incrementLlmCallCount(): void;
3685
+ /**
3686
+ * Returns the next LLM span index for this invocation.
3687
+ */
3688
+ nextLlmSpanIndex(): number;
3689
+ /**
3690
+ * Returns the next tool span index for this invocation.
3691
+ */
3692
+ nextToolSpanIndex(): number;
3693
+ /**
3694
+ * Returns the next agent span index for this invocation.
3695
+ */
3696
+ nextAgentSpanIndex(): number;
3697
+ /**
3698
+ * Exposes shared span counters for child contexts.
3699
+ */
3700
+ getSpanCounters(): SpanCounters;
3678
3701
  /**
3679
3702
  * Creates a child invocation context for a sub-agent
3680
3703
  */
@@ -5115,6 +5138,7 @@ type index$5_SingleAfterToolCallback = SingleAfterToolCallback;
5115
5138
  type index$5_SingleAgentCallback = SingleAgentCallback;
5116
5139
  type index$5_SingleBeforeModelCallback = SingleBeforeModelCallback;
5117
5140
  type index$5_SingleBeforeToolCallback = SingleBeforeToolCallback;
5141
+ type index$5_SpanCounters = SpanCounters;
5118
5142
  type index$5_StreamingMode = StreamingMode;
5119
5143
  declare const index$5_StreamingMode: typeof StreamingMode;
5120
5144
  type index$5_ToolUnion = ToolUnion;
@@ -5124,7 +5148,7 @@ declare const index$5_createBranchContextForSubAgent: typeof createBranchContext
5124
5148
  declare const index$5_mergeAgentRun: typeof mergeAgentRun;
5125
5149
  declare const index$5_newInvocationContextId: typeof newInvocationContextId;
5126
5150
  declare namespace index$5 {
5127
- export { type index$5_AfterAgentCallback as AfterAgentCallback, type index$5_AfterModelCallback as AfterModelCallback, type index$5_AfterToolCallback as AfterToolCallback, LlmAgent as Agent, index$5_AgentBuilder as AgentBuilder, type index$5_AgentBuilderConfig as AgentBuilderConfig, type index$5_AgentBuilderWithSchema as AgentBuilderWithSchema, type index$5_AgentType as AgentType, index$5_BaseAgent as BaseAgent, type index$5_BeforeAgentCallback as BeforeAgentCallback, type index$5_BeforeModelCallback as BeforeModelCallback, type index$5_BeforeToolCallback as BeforeToolCallback, type index$5_BuiltAgent as BuiltAgent, index$5_CallbackContext as CallbackContext, index$5_ContextCacheConfig as ContextCacheConfig, type index$5_ContextCacheConfigProps as ContextCacheConfigProps, type index$5_EnhancedRunner as EnhancedRunner, type index$5_FullMessage as FullMessage, type index$5_InstructionProvider as InstructionProvider, index$5_InvocationContext as InvocationContext, index$5_LangGraphAgent as LangGraphAgent, type index$5_LangGraphAgentConfig as LangGraphAgentConfig, type index$5_LangGraphNode as LangGraphNode, index$5_LlmAgent as LlmAgent, type index$5_LlmAgentConfig as LlmAgentConfig, index$5_LlmCallsLimitExceededError as LlmCallsLimitExceededError, index$5_LoopAgent as LoopAgent, type index$5_LoopAgentConfig as LoopAgentConfig, type index$5_MessagePart as MessagePart, type index$5_MultiAgentResponse as MultiAgentResponse, index$5_ParallelAgent as ParallelAgent, type index$5_ParallelAgentConfig as ParallelAgentConfig, index$5_ReadonlyContext as ReadonlyContext, index$5_RunConfig as RunConfig, type index$5_RunnerAskReturn as RunnerAskReturn, index$5_SequentialAgent as SequentialAgent, type index$5_SequentialAgentConfig as SequentialAgentConfig, type index$5_SessionOptions as SessionOptions, type index$5_SingleAfterModelCallback as SingleAfterModelCallback, type index$5_SingleAfterToolCallback as SingleAfterToolCallback, type index$5_SingleAgentCallback as SingleAgentCallback, type index$5_SingleBeforeModelCallback as SingleBeforeModelCallback, type index$5_SingleBeforeToolCallback as SingleBeforeToolCallback, index$5_StreamingMode as StreamingMode, type index$5_ToolUnion as ToolUnion, type index$5_TransferContext as TransferContext, index$5_contextCacheConfigSchema as contextCacheConfigSchema, index$5_createBranchContextForSubAgent as createBranchContextForSubAgent, index$5_mergeAgentRun as mergeAgentRun, index$5_newInvocationContextId as newInvocationContextId };
5151
+ export { type index$5_AfterAgentCallback as AfterAgentCallback, type index$5_AfterModelCallback as AfterModelCallback, type index$5_AfterToolCallback as AfterToolCallback, LlmAgent as Agent, index$5_AgentBuilder as AgentBuilder, type index$5_AgentBuilderConfig as AgentBuilderConfig, type index$5_AgentBuilderWithSchema as AgentBuilderWithSchema, type index$5_AgentType as AgentType, index$5_BaseAgent as BaseAgent, type index$5_BeforeAgentCallback as BeforeAgentCallback, type index$5_BeforeModelCallback as BeforeModelCallback, type index$5_BeforeToolCallback as BeforeToolCallback, type index$5_BuiltAgent as BuiltAgent, index$5_CallbackContext as CallbackContext, index$5_ContextCacheConfig as ContextCacheConfig, type index$5_ContextCacheConfigProps as ContextCacheConfigProps, type index$5_EnhancedRunner as EnhancedRunner, type index$5_FullMessage as FullMessage, type index$5_InstructionProvider as InstructionProvider, index$5_InvocationContext as InvocationContext, index$5_LangGraphAgent as LangGraphAgent, type index$5_LangGraphAgentConfig as LangGraphAgentConfig, type index$5_LangGraphNode as LangGraphNode, index$5_LlmAgent as LlmAgent, type index$5_LlmAgentConfig as LlmAgentConfig, index$5_LlmCallsLimitExceededError as LlmCallsLimitExceededError, index$5_LoopAgent as LoopAgent, type index$5_LoopAgentConfig as LoopAgentConfig, type index$5_MessagePart as MessagePart, type index$5_MultiAgentResponse as MultiAgentResponse, index$5_ParallelAgent as ParallelAgent, type index$5_ParallelAgentConfig as ParallelAgentConfig, index$5_ReadonlyContext as ReadonlyContext, index$5_RunConfig as RunConfig, type index$5_RunnerAskReturn as RunnerAskReturn, index$5_SequentialAgent as SequentialAgent, type index$5_SequentialAgentConfig as SequentialAgentConfig, type index$5_SessionOptions as SessionOptions, type index$5_SingleAfterModelCallback as SingleAfterModelCallback, type index$5_SingleAfterToolCallback as SingleAfterToolCallback, type index$5_SingleAgentCallback as SingleAgentCallback, type index$5_SingleBeforeModelCallback as SingleBeforeModelCallback, type index$5_SingleBeforeToolCallback as SingleBeforeToolCallback, type index$5_SpanCounters as SpanCounters, index$5_StreamingMode as StreamingMode, type index$5_ToolUnion as ToolUnion, type index$5_TransferContext as TransferContext, index$5_contextCacheConfigSchema as contextCacheConfigSchema, index$5_createBranchContextForSubAgent as createBranchContextForSubAgent, index$5_mergeAgentRun as mergeAgentRun, index$5_newInvocationContextId as newInvocationContextId };
5128
5152
  }
5129
5153
 
5130
5154
  interface ParsedArtifactUri {
@@ -6894,7 +6918,7 @@ declare const DEFAULTS: {
6894
6918
  readonly CAPTURE_MESSAGE_CONTENT: true;
6895
6919
  readonly ENABLE_TRACING: true;
6896
6920
  readonly ENABLE_METRICS: true;
6897
- readonly ENABLE_AUTO_INSTRUMENTATION: true;
6921
+ readonly ENABLE_AUTO_INSTRUMENTATION: false;
6898
6922
  };
6899
6923
 
6900
6924
  /**
@@ -7087,4 +7111,4 @@ declare const recordLlmCall: (dimensions: LlmMetricDimensions) => void;
7087
7111
 
7088
7112
  declare const VERSION = "0.1.0";
7089
7113
 
7090
- export { ADK_ATTRS, ADK_SYSTEM_NAME, AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, type AfterModelCallback, type AfterToolCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentBuilderWithSchema, AgentEvaluator, type AgentMetricDimensions, type AgentSpanAttributes, AgentTool, type AgentToolConfig, type AgentType, index$5 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, type BaseAgentType, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BasePlugin, BaseSessionService, BaseTool, BashTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BeforeModelCallback, type BeforeToolCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, ContextCacheConfig, type ContextCacheConfigProps, type ContextCacheManager, type CreateToolConfig, type CreateToolConfigWithSchema, type CreateToolConfigWithoutSchema, DEFAULTS, DatabaseSessionService, ENV_VARS, EditTool, EnhancedAuthConfig, type EnhancedLlmSpanAttributes, type EnhancedRunner, type EnhancedToolSpanAttributes, type ErrorSpanAttributes, type EvalCase, type EvalCaseResult, type EvalMetric, type EvalMetricResult, type EvalMetricResultPerInvocation, EvalResult, type EvalSet, type EvalSetResult, EvalStatus, type EvaluateConfig, index$4 as Evaluation, type EvaluationResult, Evaluator, Event, EventActions, type EventCompaction, index$7 as Events, type EventsCompactionConfig, type EventsSummarizer, ExitLoopTool, type File, FileOperationsTool, FinalResponseMatchV2Evaluator, index$3 as Flows, type FullMessage, FunctionTool, GcsArtifactService, GeminiContextCacheManager, type GetSessionConfig, GetUserChoiceTool, GlobTool, GoogleLlm, GoogleSearchTool, GrepTool, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, type IntermediateData, type Interval, type Invocation, InvocationContext, type JudgeModelOptions, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, LangfusePlugin, type LangfusePluginOptions, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmEventSummarizer, type LlmMetricDimensions, type LlmModel, type LlmModelConfig, LlmRequest, LlmResponse, type LlmSpanAttributes, LoadArtifactsTool, LoadMemoryTool, LocalEvalService, LoopAgent, type LoopAgentConfig, METRICS, McpAbi, McpAtp, McpBamm, McpCoinGecko, McpCoinGeckoPro, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntents, McpOdos, McpPolymarket, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, McpUpbit, index$2 as Memory, type MessagePart, type MetricInfo, type MetricValueInfo, index$6 as Models, type MultiAgentResponse, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OPERATIONS, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, type ParsedArtifactUri, type PerInvocationResult, type PerToolFailuresCounter, PlanReActPlanner, type PluginCallbackName, PluginManager, index$1 as Plugins, PrebuiltMetrics, REFLECT_AND_RETRY_RESPONSE_TYPE, REQUEST_EUC_FUNCTION_CALL_NAME, ReadTool, ReadonlyContext, ReflectAndRetryToolPlugin, type ReflectAndRetryToolPluginOptions, RougeEvaluator, RunConfig, Runner, type RunnerAskReturn, SEMCONV, SafetyEvaluatorV1, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionInput, type SessionOptions, index as Sessions, type SingleAfterModelCallback, type SingleAfterToolCallback, type SingleAgentCallback, type SingleBeforeModelCallback, type SingleBeforeToolCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type TelemetryStats, type ThinkingConfig, type ToolConfig, ToolContext, type ToolFailureResponse, type ToolMetricDimensions, type ToolSpanAttributes, type ToolUnion, index$8 as Tools, type TraceAgentParams, type TraceAgentTransferParams, type TraceCallbackParams, type TraceLlmParams, type TraceMemoryParams, type TracePluginParams, type TraceSessionParams, type TraceToolParams, TrackingScope, TrajectoryEvaluator, type TransferContext, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiRagMemoryService, VertexAiSessionService, WebFetchTool, WebSearchTool, WriteTool, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$6 as agentTransferRequestProcessor, requestProcessor$5 as basicRequestProcessor, buildFunctionDeclaration, buildLlmRequestForTrace, buildLlmResponseForTrace, requestProcessor$4 as codeExecutionRequestProcessor, responseProcessor$1 as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, contextCacheConfigSchema, convertMcpToolToBaseTool, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, createTool, extractTextFromContent, formatSpanAttributes, generateAuthEvent, generateClientFunctionCallId, getArtifactUri, getEnvironment, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$2 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$1 as instructionsRequestProcessor, isArtifactRef, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor as nlPlanningRequestProcessor, responseProcessor as nlPlanningResponseProcessor, normalizeJsonSchema, parseArtifactUri, pluginCallbackNameSchema, populateClientFunctionCallId, recordAgentInvocation, recordLlmCall, recordToolExecution, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, runCompactionForSlidingWindow, safeJsonStringify, shouldCaptureContent, shutdownTelemetry, telemetryService, traceAgentInvocation, traceLlmCall, traceToolCall, tracer };
7114
+ export { ADK_ATTRS, ADK_SYSTEM_NAME, AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, type AfterModelCallback, type AfterToolCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentBuilderWithSchema, AgentEvaluator, type AgentMetricDimensions, type AgentSpanAttributes, AgentTool, type AgentToolConfig, type AgentType, index$5 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, type BaseAgentType, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BasePlugin, BaseSessionService, BaseTool, BashTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BeforeModelCallback, type BeforeToolCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, ContextCacheConfig, type ContextCacheConfigProps, type ContextCacheManager, type CreateToolConfig, type CreateToolConfigWithSchema, type CreateToolConfigWithoutSchema, DEFAULTS, DatabaseSessionService, ENV_VARS, EditTool, EnhancedAuthConfig, type EnhancedLlmSpanAttributes, type EnhancedRunner, type EnhancedToolSpanAttributes, type ErrorSpanAttributes, type EvalCase, type EvalCaseResult, type EvalMetric, type EvalMetricResult, type EvalMetricResultPerInvocation, EvalResult, type EvalSet, type EvalSetResult, EvalStatus, type EvaluateConfig, index$4 as Evaluation, type EvaluationResult, Evaluator, Event, EventActions, type EventCompaction, index$7 as Events, type EventsCompactionConfig, type EventsSummarizer, ExitLoopTool, type File, FileOperationsTool, FinalResponseMatchV2Evaluator, index$3 as Flows, type FullMessage, FunctionTool, GcsArtifactService, GeminiContextCacheManager, type GetSessionConfig, GetUserChoiceTool, GlobTool, GoogleLlm, GoogleSearchTool, GrepTool, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, type IntermediateData, type Interval, type Invocation, InvocationContext, type JudgeModelOptions, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, LangfusePlugin, type LangfusePluginOptions, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmEventSummarizer, type LlmMetricDimensions, type LlmModel, type LlmModelConfig, LlmRequest, LlmResponse, type LlmSpanAttributes, LoadArtifactsTool, LoadMemoryTool, LocalEvalService, LoopAgent, type LoopAgentConfig, METRICS, McpAbi, McpAtp, McpBamm, McpCoinGecko, McpCoinGeckoPro, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntents, McpOdos, McpPolymarket, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, McpUpbit, index$2 as Memory, type MessagePart, type MetricInfo, type MetricValueInfo, index$6 as Models, type MultiAgentResponse, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OPERATIONS, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, type ParsedArtifactUri, type PerInvocationResult, type PerToolFailuresCounter, PlanReActPlanner, type PluginCallbackName, PluginManager, index$1 as Plugins, PrebuiltMetrics, REFLECT_AND_RETRY_RESPONSE_TYPE, REQUEST_EUC_FUNCTION_CALL_NAME, ReadTool, ReadonlyContext, ReflectAndRetryToolPlugin, type ReflectAndRetryToolPluginOptions, RougeEvaluator, RunConfig, Runner, type RunnerAskReturn, SEMCONV, SafetyEvaluatorV1, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionInput, type SessionOptions, index as Sessions, type SingleAfterModelCallback, type SingleAfterToolCallback, type SingleAgentCallback, type SingleBeforeModelCallback, type SingleBeforeToolCallback, SingleFlow, type SpanCounters, State, StreamingMode, type TelemetryConfig, TelemetryService, type TelemetryStats, type ThinkingConfig, type ToolConfig, ToolContext, type ToolFailureResponse, type ToolMetricDimensions, type ToolSpanAttributes, type ToolUnion, index$8 as Tools, type TraceAgentParams, type TraceAgentTransferParams, type TraceCallbackParams, type TraceLlmParams, type TraceMemoryParams, type TracePluginParams, type TraceSessionParams, type TraceToolParams, TrackingScope, TrajectoryEvaluator, type TransferContext, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiRagMemoryService, VertexAiSessionService, WebFetchTool, WebSearchTool, WriteTool, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$6 as agentTransferRequestProcessor, requestProcessor$5 as basicRequestProcessor, buildFunctionDeclaration, buildLlmRequestForTrace, buildLlmResponseForTrace, requestProcessor$4 as codeExecutionRequestProcessor, responseProcessor$1 as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, contextCacheConfigSchema, convertMcpToolToBaseTool, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, createTool, extractTextFromContent, formatSpanAttributes, generateAuthEvent, generateClientFunctionCallId, getArtifactUri, getEnvironment, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$2 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$1 as instructionsRequestProcessor, isArtifactRef, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor as nlPlanningRequestProcessor, responseProcessor as nlPlanningResponseProcessor, normalizeJsonSchema, parseArtifactUri, pluginCallbackNameSchema, populateClientFunctionCallId, recordAgentInvocation, recordLlmCall, recordToolExecution, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, runCompactionForSlidingWindow, safeJsonStringify, shouldCaptureContent, shutdownTelemetry, telemetryService, traceAgentInvocation, traceLlmCall, traceToolCall, tracer };
package/dist/index.d.ts CHANGED
@@ -3497,6 +3497,11 @@ declare class TranscriptionEntry {
3497
3497
  });
3498
3498
  }
3499
3499
 
3500
+ type SpanCounters = {
3501
+ llm: number;
3502
+ tool: number;
3503
+ agent: number;
3504
+ };
3500
3505
  /**
3501
3506
  * Transfer context for multi-agent workflows
3502
3507
  * Tracks the chain of agent transfers for telemetry
@@ -3560,7 +3565,7 @@ declare function newInvocationContextId(): string;
3560
3565
  * ┌─────────────────────── invocation ──────────────────────────┐
3561
3566
  * ┌──────────── llm_agent_call_1 ────────────┐ ┌─ agent_call_2 ─┐
3562
3567
  * ┌──── step_1 ────────┐ ┌───── step_2 ──────┐
3563
- * [call_llm] [call_tool] [call_llm] [transfer]
3568
+ * [llm_generate] [execute_tool] [llm_generate] [transfer]
3564
3569
  *
3565
3570
  */
3566
3571
  declare class InvocationContext {
@@ -3640,6 +3645,7 @@ declare class InvocationContext {
3640
3645
  * of this invocation.
3641
3646
  */
3642
3647
  private readonly _invocationCostManager;
3648
+ private readonly _spanCounters;
3643
3649
  /**
3644
3650
  * Constructor for InvocationContext
3645
3651
  */
@@ -3660,6 +3666,7 @@ declare class InvocationContext {
3660
3666
  runConfig?: RunConfig;
3661
3667
  contextCacheConfig?: ContextCacheConfig;
3662
3668
  transferContext?: TransferContext;
3669
+ spanCounters?: SpanCounters;
3663
3670
  });
3664
3671
  /**
3665
3672
  * App name from the session
@@ -3675,6 +3682,22 @@ declare class InvocationContext {
3675
3682
  * @throws {LlmCallsLimitExceededError} If number of llm calls made exceed the set threshold.
3676
3683
  */
3677
3684
  incrementLlmCallCount(): void;
3685
+ /**
3686
+ * Returns the next LLM span index for this invocation.
3687
+ */
3688
+ nextLlmSpanIndex(): number;
3689
+ /**
3690
+ * Returns the next tool span index for this invocation.
3691
+ */
3692
+ nextToolSpanIndex(): number;
3693
+ /**
3694
+ * Returns the next agent span index for this invocation.
3695
+ */
3696
+ nextAgentSpanIndex(): number;
3697
+ /**
3698
+ * Exposes shared span counters for child contexts.
3699
+ */
3700
+ getSpanCounters(): SpanCounters;
3678
3701
  /**
3679
3702
  * Creates a child invocation context for a sub-agent
3680
3703
  */
@@ -5115,6 +5138,7 @@ type index$5_SingleAfterToolCallback = SingleAfterToolCallback;
5115
5138
  type index$5_SingleAgentCallback = SingleAgentCallback;
5116
5139
  type index$5_SingleBeforeModelCallback = SingleBeforeModelCallback;
5117
5140
  type index$5_SingleBeforeToolCallback = SingleBeforeToolCallback;
5141
+ type index$5_SpanCounters = SpanCounters;
5118
5142
  type index$5_StreamingMode = StreamingMode;
5119
5143
  declare const index$5_StreamingMode: typeof StreamingMode;
5120
5144
  type index$5_ToolUnion = ToolUnion;
@@ -5124,7 +5148,7 @@ declare const index$5_createBranchContextForSubAgent: typeof createBranchContext
5124
5148
  declare const index$5_mergeAgentRun: typeof mergeAgentRun;
5125
5149
  declare const index$5_newInvocationContextId: typeof newInvocationContextId;
5126
5150
  declare namespace index$5 {
5127
- export { type index$5_AfterAgentCallback as AfterAgentCallback, type index$5_AfterModelCallback as AfterModelCallback, type index$5_AfterToolCallback as AfterToolCallback, LlmAgent as Agent, index$5_AgentBuilder as AgentBuilder, type index$5_AgentBuilderConfig as AgentBuilderConfig, type index$5_AgentBuilderWithSchema as AgentBuilderWithSchema, type index$5_AgentType as AgentType, index$5_BaseAgent as BaseAgent, type index$5_BeforeAgentCallback as BeforeAgentCallback, type index$5_BeforeModelCallback as BeforeModelCallback, type index$5_BeforeToolCallback as BeforeToolCallback, type index$5_BuiltAgent as BuiltAgent, index$5_CallbackContext as CallbackContext, index$5_ContextCacheConfig as ContextCacheConfig, type index$5_ContextCacheConfigProps as ContextCacheConfigProps, type index$5_EnhancedRunner as EnhancedRunner, type index$5_FullMessage as FullMessage, type index$5_InstructionProvider as InstructionProvider, index$5_InvocationContext as InvocationContext, index$5_LangGraphAgent as LangGraphAgent, type index$5_LangGraphAgentConfig as LangGraphAgentConfig, type index$5_LangGraphNode as LangGraphNode, index$5_LlmAgent as LlmAgent, type index$5_LlmAgentConfig as LlmAgentConfig, index$5_LlmCallsLimitExceededError as LlmCallsLimitExceededError, index$5_LoopAgent as LoopAgent, type index$5_LoopAgentConfig as LoopAgentConfig, type index$5_MessagePart as MessagePart, type index$5_MultiAgentResponse as MultiAgentResponse, index$5_ParallelAgent as ParallelAgent, type index$5_ParallelAgentConfig as ParallelAgentConfig, index$5_ReadonlyContext as ReadonlyContext, index$5_RunConfig as RunConfig, type index$5_RunnerAskReturn as RunnerAskReturn, index$5_SequentialAgent as SequentialAgent, type index$5_SequentialAgentConfig as SequentialAgentConfig, type index$5_SessionOptions as SessionOptions, type index$5_SingleAfterModelCallback as SingleAfterModelCallback, type index$5_SingleAfterToolCallback as SingleAfterToolCallback, type index$5_SingleAgentCallback as SingleAgentCallback, type index$5_SingleBeforeModelCallback as SingleBeforeModelCallback, type index$5_SingleBeforeToolCallback as SingleBeforeToolCallback, index$5_StreamingMode as StreamingMode, type index$5_ToolUnion as ToolUnion, type index$5_TransferContext as TransferContext, index$5_contextCacheConfigSchema as contextCacheConfigSchema, index$5_createBranchContextForSubAgent as createBranchContextForSubAgent, index$5_mergeAgentRun as mergeAgentRun, index$5_newInvocationContextId as newInvocationContextId };
5151
+ export { type index$5_AfterAgentCallback as AfterAgentCallback, type index$5_AfterModelCallback as AfterModelCallback, type index$5_AfterToolCallback as AfterToolCallback, LlmAgent as Agent, index$5_AgentBuilder as AgentBuilder, type index$5_AgentBuilderConfig as AgentBuilderConfig, type index$5_AgentBuilderWithSchema as AgentBuilderWithSchema, type index$5_AgentType as AgentType, index$5_BaseAgent as BaseAgent, type index$5_BeforeAgentCallback as BeforeAgentCallback, type index$5_BeforeModelCallback as BeforeModelCallback, type index$5_BeforeToolCallback as BeforeToolCallback, type index$5_BuiltAgent as BuiltAgent, index$5_CallbackContext as CallbackContext, index$5_ContextCacheConfig as ContextCacheConfig, type index$5_ContextCacheConfigProps as ContextCacheConfigProps, type index$5_EnhancedRunner as EnhancedRunner, type index$5_FullMessage as FullMessage, type index$5_InstructionProvider as InstructionProvider, index$5_InvocationContext as InvocationContext, index$5_LangGraphAgent as LangGraphAgent, type index$5_LangGraphAgentConfig as LangGraphAgentConfig, type index$5_LangGraphNode as LangGraphNode, index$5_LlmAgent as LlmAgent, type index$5_LlmAgentConfig as LlmAgentConfig, index$5_LlmCallsLimitExceededError as LlmCallsLimitExceededError, index$5_LoopAgent as LoopAgent, type index$5_LoopAgentConfig as LoopAgentConfig, type index$5_MessagePart as MessagePart, type index$5_MultiAgentResponse as MultiAgentResponse, index$5_ParallelAgent as ParallelAgent, type index$5_ParallelAgentConfig as ParallelAgentConfig, index$5_ReadonlyContext as ReadonlyContext, index$5_RunConfig as RunConfig, type index$5_RunnerAskReturn as RunnerAskReturn, index$5_SequentialAgent as SequentialAgent, type index$5_SequentialAgentConfig as SequentialAgentConfig, type index$5_SessionOptions as SessionOptions, type index$5_SingleAfterModelCallback as SingleAfterModelCallback, type index$5_SingleAfterToolCallback as SingleAfterToolCallback, type index$5_SingleAgentCallback as SingleAgentCallback, type index$5_SingleBeforeModelCallback as SingleBeforeModelCallback, type index$5_SingleBeforeToolCallback as SingleBeforeToolCallback, type index$5_SpanCounters as SpanCounters, index$5_StreamingMode as StreamingMode, type index$5_ToolUnion as ToolUnion, type index$5_TransferContext as TransferContext, index$5_contextCacheConfigSchema as contextCacheConfigSchema, index$5_createBranchContextForSubAgent as createBranchContextForSubAgent, index$5_mergeAgentRun as mergeAgentRun, index$5_newInvocationContextId as newInvocationContextId };
5128
5152
  }
5129
5153
 
5130
5154
  interface ParsedArtifactUri {
@@ -6894,7 +6918,7 @@ declare const DEFAULTS: {
6894
6918
  readonly CAPTURE_MESSAGE_CONTENT: true;
6895
6919
  readonly ENABLE_TRACING: true;
6896
6920
  readonly ENABLE_METRICS: true;
6897
- readonly ENABLE_AUTO_INSTRUMENTATION: true;
6921
+ readonly ENABLE_AUTO_INSTRUMENTATION: false;
6898
6922
  };
6899
6923
 
6900
6924
  /**
@@ -7087,4 +7111,4 @@ declare const recordLlmCall: (dimensions: LlmMetricDimensions) => void;
7087
7111
 
7088
7112
  declare const VERSION = "0.1.0";
7089
7113
 
7090
- export { ADK_ATTRS, ADK_SYSTEM_NAME, AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, type AfterModelCallback, type AfterToolCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentBuilderWithSchema, AgentEvaluator, type AgentMetricDimensions, type AgentSpanAttributes, AgentTool, type AgentToolConfig, type AgentType, index$5 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, type BaseAgentType, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BasePlugin, BaseSessionService, BaseTool, BashTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BeforeModelCallback, type BeforeToolCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, ContextCacheConfig, type ContextCacheConfigProps, type ContextCacheManager, type CreateToolConfig, type CreateToolConfigWithSchema, type CreateToolConfigWithoutSchema, DEFAULTS, DatabaseSessionService, ENV_VARS, EditTool, EnhancedAuthConfig, type EnhancedLlmSpanAttributes, type EnhancedRunner, type EnhancedToolSpanAttributes, type ErrorSpanAttributes, type EvalCase, type EvalCaseResult, type EvalMetric, type EvalMetricResult, type EvalMetricResultPerInvocation, EvalResult, type EvalSet, type EvalSetResult, EvalStatus, type EvaluateConfig, index$4 as Evaluation, type EvaluationResult, Evaluator, Event, EventActions, type EventCompaction, index$7 as Events, type EventsCompactionConfig, type EventsSummarizer, ExitLoopTool, type File, FileOperationsTool, FinalResponseMatchV2Evaluator, index$3 as Flows, type FullMessage, FunctionTool, GcsArtifactService, GeminiContextCacheManager, type GetSessionConfig, GetUserChoiceTool, GlobTool, GoogleLlm, GoogleSearchTool, GrepTool, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, type IntermediateData, type Interval, type Invocation, InvocationContext, type JudgeModelOptions, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, LangfusePlugin, type LangfusePluginOptions, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmEventSummarizer, type LlmMetricDimensions, type LlmModel, type LlmModelConfig, LlmRequest, LlmResponse, type LlmSpanAttributes, LoadArtifactsTool, LoadMemoryTool, LocalEvalService, LoopAgent, type LoopAgentConfig, METRICS, McpAbi, McpAtp, McpBamm, McpCoinGecko, McpCoinGeckoPro, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntents, McpOdos, McpPolymarket, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, McpUpbit, index$2 as Memory, type MessagePart, type MetricInfo, type MetricValueInfo, index$6 as Models, type MultiAgentResponse, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OPERATIONS, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, type ParsedArtifactUri, type PerInvocationResult, type PerToolFailuresCounter, PlanReActPlanner, type PluginCallbackName, PluginManager, index$1 as Plugins, PrebuiltMetrics, REFLECT_AND_RETRY_RESPONSE_TYPE, REQUEST_EUC_FUNCTION_CALL_NAME, ReadTool, ReadonlyContext, ReflectAndRetryToolPlugin, type ReflectAndRetryToolPluginOptions, RougeEvaluator, RunConfig, Runner, type RunnerAskReturn, SEMCONV, SafetyEvaluatorV1, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionInput, type SessionOptions, index as Sessions, type SingleAfterModelCallback, type SingleAfterToolCallback, type SingleAgentCallback, type SingleBeforeModelCallback, type SingleBeforeToolCallback, SingleFlow, State, StreamingMode, type TelemetryConfig, TelemetryService, type TelemetryStats, type ThinkingConfig, type ToolConfig, ToolContext, type ToolFailureResponse, type ToolMetricDimensions, type ToolSpanAttributes, type ToolUnion, index$8 as Tools, type TraceAgentParams, type TraceAgentTransferParams, type TraceCallbackParams, type TraceLlmParams, type TraceMemoryParams, type TracePluginParams, type TraceSessionParams, type TraceToolParams, TrackingScope, TrajectoryEvaluator, type TransferContext, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiRagMemoryService, VertexAiSessionService, WebFetchTool, WebSearchTool, WriteTool, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$6 as agentTransferRequestProcessor, requestProcessor$5 as basicRequestProcessor, buildFunctionDeclaration, buildLlmRequestForTrace, buildLlmResponseForTrace, requestProcessor$4 as codeExecutionRequestProcessor, responseProcessor$1 as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, contextCacheConfigSchema, convertMcpToolToBaseTool, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, createTool, extractTextFromContent, formatSpanAttributes, generateAuthEvent, generateClientFunctionCallId, getArtifactUri, getEnvironment, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$2 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$1 as instructionsRequestProcessor, isArtifactRef, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor as nlPlanningRequestProcessor, responseProcessor as nlPlanningResponseProcessor, normalizeJsonSchema, parseArtifactUri, pluginCallbackNameSchema, populateClientFunctionCallId, recordAgentInvocation, recordLlmCall, recordToolExecution, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, runCompactionForSlidingWindow, safeJsonStringify, shouldCaptureContent, shutdownTelemetry, telemetryService, traceAgentInvocation, traceLlmCall, traceToolCall, tracer };
7114
+ export { ADK_ATTRS, ADK_SYSTEM_NAME, AF_FUNCTION_CALL_ID_PREFIX, type AfterAgentCallback, type AfterModelCallback, type AfterToolCallback, LlmAgent as Agent, AgentBuilder, type AgentBuilderConfig, type AgentBuilderWithSchema, AgentEvaluator, type AgentMetricDimensions, type AgentSpanAttributes, AgentTool, type AgentToolConfig, type AgentType, index$5 as Agents, AiSdkLlm, AnthropicLlm, ApiKeyCredential, ApiKeyScheme, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, AuthTool, type AuthToolArguments, AutoFlow, BaseAgent, type BaseAgentType, BaseCodeExecutor, type BaseCodeExecutorConfig, BaseLLMConnection, BaseLlm, BaseLlmFlow, BaseLlmRequestProcessor, BaseLlmResponseProcessor, type BaseMemoryService, BasePlanner, BasePlugin, BaseSessionService, BaseTool, BashTool, BasicAuthCredential, BearerTokenCredential, type BeforeAgentCallback, type BeforeModelCallback, type BeforeToolCallback, type BuildFunctionDeclarationOptions, type BuiltAgent, BuiltInCodeExecutor, BuiltInPlanner, CallbackContext, type CodeExecutionInput, type CodeExecutionResult, CodeExecutionUtils, CodeExecutorContext, ContextCacheConfig, type ContextCacheConfigProps, type ContextCacheManager, type CreateToolConfig, type CreateToolConfigWithSchema, type CreateToolConfigWithoutSchema, DEFAULTS, DatabaseSessionService, ENV_VARS, EditTool, EnhancedAuthConfig, type EnhancedLlmSpanAttributes, type EnhancedRunner, type EnhancedToolSpanAttributes, type ErrorSpanAttributes, type EvalCase, type EvalCaseResult, type EvalMetric, type EvalMetricResult, type EvalMetricResultPerInvocation, EvalResult, type EvalSet, type EvalSetResult, EvalStatus, type EvaluateConfig, index$4 as Evaluation, type EvaluationResult, Evaluator, Event, EventActions, type EventCompaction, index$7 as Events, type EventsCompactionConfig, type EventsSummarizer, ExitLoopTool, type File, FileOperationsTool, FinalResponseMatchV2Evaluator, index$3 as Flows, type FullMessage, FunctionTool, GcsArtifactService, GeminiContextCacheManager, type GetSessionConfig, GetUserChoiceTool, GlobTool, GoogleLlm, GoogleSearchTool, GrepTool, HttpRequestTool, HttpScheme, InMemoryArtifactService, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, type InstructionProvider, type IntermediateData, type Interval, type Invocation, InvocationContext, type JudgeModelOptions, LLMRegistry, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, LangfusePlugin, type LangfusePluginOptions, type ListSessionsResponse, LlmAgent, type LlmAgentConfig, LlmCallsLimitExceededError, LlmEventSummarizer, type LlmMetricDimensions, type LlmModel, type LlmModelConfig, LlmRequest, LlmResponse, type LlmSpanAttributes, LoadArtifactsTool, LoadMemoryTool, LocalEvalService, LoopAgent, type LoopAgentConfig, METRICS, McpAbi, McpAtp, McpBamm, McpCoinGecko, McpCoinGeckoPro, type McpConfig, McpDiscord, McpError, McpErrorType, McpFilesystem, McpFraxlend, McpGeneric, McpIqWiki, McpMemory, McpNearAgent, McpNearIntents, McpOdos, McpPolymarket, McpSamplingHandler, type McpSamplingRequest, type McpSamplingResponse, type McpServerConfig, McpTelegram, McpToolset, type McpTransportType, McpUpbit, index$2 as Memory, type MessagePart, type MetricInfo, type MetricValueInfo, index$6 as Models, type MultiAgentResponse, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OPERATIONS, OpenAiLlm, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, type ParsedArtifactUri, type PerInvocationResult, type PerToolFailuresCounter, PlanReActPlanner, type PluginCallbackName, PluginManager, index$1 as Plugins, PrebuiltMetrics, REFLECT_AND_RETRY_RESPONSE_TYPE, REQUEST_EUC_FUNCTION_CALL_NAME, ReadTool, ReadonlyContext, ReflectAndRetryToolPlugin, type ReflectAndRetryToolPluginOptions, RougeEvaluator, RunConfig, Runner, type RunnerAskReturn, SEMCONV, SafetyEvaluatorV1, type SamplingHandler, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionInput, type SessionOptions, index as Sessions, type SingleAfterModelCallback, type SingleAfterToolCallback, type SingleAgentCallback, type SingleBeforeModelCallback, type SingleBeforeToolCallback, SingleFlow, type SpanCounters, State, StreamingMode, type TelemetryConfig, TelemetryService, type TelemetryStats, type ThinkingConfig, type ToolConfig, ToolContext, type ToolFailureResponse, type ToolMetricDimensions, type ToolSpanAttributes, type ToolUnion, index$8 as Tools, type TraceAgentParams, type TraceAgentTransferParams, type TraceCallbackParams, type TraceLlmParams, type TraceMemoryParams, type TracePluginParams, type TraceSessionParams, type TraceToolParams, TrackingScope, TrajectoryEvaluator, type TransferContext, TransferToAgentTool, UserInteractionTool, VERSION, VertexAiRagMemoryService, VertexAiSessionService, WebFetchTool, WebSearchTool, WriteTool, _findFunctionCallEventIfLastEventIsFunctionResponse, adkToMcpToolType, requestProcessor$6 as agentTransferRequestProcessor, requestProcessor$5 as basicRequestProcessor, buildFunctionDeclaration, buildLlmRequestForTrace, buildLlmResponseForTrace, requestProcessor$4 as codeExecutionRequestProcessor, responseProcessor$1 as codeExecutionResponseProcessor, requestProcessor$3 as contentRequestProcessor, contextCacheConfigSchema, convertMcpToolToBaseTool, createAuthToolArguments, createBranchContextForSubAgent, createDatabaseSessionService, createFunctionTool, createMysqlSessionService, createPostgresSessionService, createSamplingHandler, createSqliteSessionService, createTool, extractTextFromContent, formatSpanAttributes, generateAuthEvent, generateClientFunctionCallId, getArtifactUri, getEnvironment, getLongRunningFunctionCalls, getMcpTools, handleFunctionCallsAsync, handleFunctionCallsLive, requestProcessor$2 as identityRequestProcessor, initializeTelemetry, injectSessionState, requestProcessor$1 as instructionsRequestProcessor, isArtifactRef, isEnhancedAuthConfig, jsonSchemaToDeclaration, mcpSchemaToParameters, mergeAgentRun, mergeParallelFunctionResponseEvents, newInvocationContextId, requestProcessor as nlPlanningRequestProcessor, responseProcessor as nlPlanningResponseProcessor, normalizeJsonSchema, parseArtifactUri, pluginCallbackNameSchema, populateClientFunctionCallId, recordAgentInvocation, recordLlmCall, recordToolExecution, registerProviders, removeClientFunctionCallId, requestProcessor$7 as requestProcessor, runCompactionForSlidingWindow, safeJsonStringify, shouldCaptureContent, shutdownTelemetry, telemetryService, traceAgentInvocation, traceLlmCall, traceToolCall, tracer };
package/dist/index.js CHANGED
@@ -997,6 +997,7 @@ var InvocationContext = (_class5 = class _InvocationContext {
997
997
  * of this invocation.
998
998
  */
999
999
  __init10() {this._invocationCostManager = new InvocationCostManager()}
1000
+
1000
1001
  /**
1001
1002
  * Constructor for InvocationContext
1002
1003
  */
@@ -1017,6 +1018,11 @@ var InvocationContext = (_class5 = class _InvocationContext {
1017
1018
  this.runConfig = options.runConfig;
1018
1019
  this.contextCacheConfig = options.contextCacheConfig;
1019
1020
  this.transferContext = options.transferContext;
1021
+ this._spanCounters = _nullishCoalesce(options.spanCounters, () => ( {
1022
+ llm: 0,
1023
+ tool: 0,
1024
+ agent: 0
1025
+ }));
1020
1026
  }
1021
1027
  /**
1022
1028
  * App name from the session
@@ -1040,6 +1046,30 @@ var InvocationContext = (_class5 = class _InvocationContext {
1040
1046
  this.runConfig
1041
1047
  );
1042
1048
  }
1049
+ /**
1050
+ * Returns the next LLM span index for this invocation.
1051
+ */
1052
+ nextLlmSpanIndex() {
1053
+ return ++this._spanCounters.llm;
1054
+ }
1055
+ /**
1056
+ * Returns the next tool span index for this invocation.
1057
+ */
1058
+ nextToolSpanIndex() {
1059
+ return ++this._spanCounters.tool;
1060
+ }
1061
+ /**
1062
+ * Returns the next agent span index for this invocation.
1063
+ */
1064
+ nextAgentSpanIndex() {
1065
+ return ++this._spanCounters.agent;
1066
+ }
1067
+ /**
1068
+ * Exposes shared span counters for child contexts.
1069
+ */
1070
+ getSpanCounters() {
1071
+ return this._spanCounters;
1072
+ }
1043
1073
  /**
1044
1074
  * Creates a child invocation context for a sub-agent
1045
1075
  */
@@ -1064,8 +1094,9 @@ var InvocationContext = (_class5 = class _InvocationContext {
1064
1094
  transcriptionCache: this.transcriptionCache,
1065
1095
  runConfig: this.runConfig,
1066
1096
  contextCacheConfig: this.contextCacheConfig,
1067
- transferContext: this.transferContext
1097
+ transferContext: this.transferContext,
1068
1098
  // Propagate transfer context
1099
+ spanCounters: this._spanCounters
1069
1100
  });
1070
1101
  }
1071
1102
  }, _class5);
@@ -1828,7 +1859,7 @@ var DEFAULTS = {
1828
1859
  CAPTURE_MESSAGE_CONTENT: true,
1829
1860
  ENABLE_TRACING: true,
1830
1861
  ENABLE_METRICS: true,
1831
- ENABLE_AUTO_INSTRUMENTATION: true
1862
+ ENABLE_AUTO_INSTRUMENTATION: false
1832
1863
  };
1833
1864
 
1834
1865
  // src/telemetry/metrics.ts
@@ -2311,8 +2342,9 @@ var SetupService = (_class8 = class {constructor() { _class8.prototype.__init22.
2311
2342
  }
2312
2343
  }
2313
2344
  this.isInitialized = true;
2345
+ const versionLabel = config.appVersion ? ` v${config.appVersion}` : "";
2314
2346
  _api.diag.info(
2315
- `Telemetry initialized successfully for ${config.appName} v${config.appVersion || "unknown"}`
2347
+ `Telemetry initialized successfully for ${config.appName}${versionLabel}`
2316
2348
  );
2317
2349
  } catch (error) {
2318
2350
  _api.diag.error("Error initializing telemetry:", error);
@@ -6180,9 +6212,12 @@ async function handleFunctionCallsAsync(invocationContext, functionCallEvent, to
6180
6212
  functionCall,
6181
6213
  toolsDict
6182
6214
  );
6215
+ const toolSpanIndex = invocationContext.nextToolSpanIndex();
6183
6216
  const functionArgs = functionCall.args || {};
6184
6217
  const tracer2 = telemetryService.getTracer();
6185
- const span = tracer2.startSpan(`execute_tool [${tool.name}]`);
6218
+ const span = tracer2.startSpan(
6219
+ `execute_tool [${tool.name}] #${toolSpanIndex}`
6220
+ );
6186
6221
  const spanContext = _api.trace.setSpan(_api.context.active(), span);
6187
6222
  const toolStartTime = Date.now();
6188
6223
  let toolStatus = "success";
@@ -6271,6 +6306,9 @@ async function handleFunctionCallsAsync(invocationContext, functionCallEvent, to
6271
6306
  // no retry
6272
6307
  wasOverridden
6273
6308
  );
6309
+ telemetryService.setActiveSpanAttributes({
6310
+ [SEMCONV.GEN_AI_TOOL_NAME]: `${tool.name} #${toolSpanIndex}`
6311
+ });
6274
6312
  return { result, event: functionResponseEvent };
6275
6313
  });
6276
6314
  if (!functionResponse) {
@@ -7194,6 +7232,7 @@ var AgentTool = (_class18 = class extends BaseTool {
7194
7232
  pluginManager: parentInvocation.pluginManager,
7195
7233
  runConfig: parentInvocation.runConfig,
7196
7234
  contextCacheConfig: parentInvocation.contextCacheConfig,
7235
+ spanCounters: parentInvocation.getSpanCounters(),
7197
7236
  userContent: {
7198
7237
  role: "user",
7199
7238
  parts: [{ text: String(input) }]
@@ -10497,6 +10536,7 @@ var BaseLlmFlow = (_class29 = class {constructor() { _class29.prototype.__init61
10497
10536
  });
10498
10537
  const llm = this.__getLlm(invocationContext);
10499
10538
  const isStreaming = invocationContext.runConfig.streamingMode === "sse" /* SSE */;
10539
+ const llmSpanIndex = invocationContext.nextLlmSpanIndex();
10500
10540
  const generator = async function* () {
10501
10541
  for await (const llmResponse of this._callLlmAsync(
10502
10542
  invocationContext,
@@ -10515,7 +10555,7 @@ var BaseLlmFlow = (_class29 = class {constructor() { _class29.prototype.__init61
10515
10555
  }
10516
10556
  }.bind(this)();
10517
10557
  yield* telemetryService.traceAsyncGenerator(
10518
- isStreaming ? `llm_stream [${llm.model}]` : `llm_generate [${llm.model}]`,
10558
+ isStreaming ? `llm_stream [${llm.model}] #${llmSpanIndex}` : `llm_generate [${llm.model}] #${llmSpanIndex}`,
10519
10559
  generator
10520
10560
  );
10521
10561
  }
@@ -12891,8 +12931,9 @@ var BaseAgent = (_class31 = class {
12891
12931
  * Entry method to run an agent via text-based conversation.
12892
12932
  */
12893
12933
  async *runAsync(parentContext) {
12934
+ const agentSpanIndex = parentContext.nextAgentSpanIndex();
12894
12935
  yield* telemetryService.traceAsyncGenerator(
12895
- `agent_run [${this.name}]`,
12936
+ `agent_run [${this.name}] #${agentSpanIndex}`,
12896
12937
  this.runAsyncInternal(parentContext)
12897
12938
  );
12898
12939
  }
@@ -12900,8 +12941,9 @@ var BaseAgent = (_class31 = class {
12900
12941
  * Entry method to run an agent via video/audio-based conversation.
12901
12942
  */
12902
12943
  async *runLive(parentContext) {
12944
+ const agentSpanIndex = parentContext.nextAgentSpanIndex();
12903
12945
  yield* telemetryService.traceAsyncGenerator(
12904
- `agent_run_live [${this.name}]`,
12946
+ `agent_run_live [${this.name}] #${agentSpanIndex}`,
12905
12947
  this.runLiveInternal(parentContext)
12906
12948
  );
12907
12949
  }
@@ -14520,7 +14562,7 @@ var Runner = (_class37 = class {
14520
14562
  newMessage,
14521
14563
  runConfig = new RunConfig()
14522
14564
  }) {
14523
- const span = tracer.startSpan("invocation");
14565
+ const span = tracer.startSpan(`${this.appName}-invocation`);
14524
14566
  const spanContext = _api.trace.setSpan(_api.context.active(), span);
14525
14567
  const inputText = extractTextFromContent(newMessage);
14526
14568
  if (inputText && telemetryService.shouldCaptureContent()) {
@@ -15234,7 +15276,8 @@ function createBranchContextForSubAgent(agent, subAgent, invocationContext) {
15234
15276
  transcriptionCache: invocationContext.transcriptionCache,
15235
15277
  runConfig: invocationContext.runConfig,
15236
15278
  pluginManager: invocationContext.pluginManager,
15237
- contextCacheConfig: invocationContext.contextCacheConfig
15279
+ contextCacheConfig: invocationContext.contextCacheConfig,
15280
+ spanCounters: invocationContext.getSpanCounters()
15238
15281
  });
15239
15282
  }
15240
15283
  async function* mergeAgentRun(agentRuns) {
package/dist/index.mjs CHANGED
@@ -997,6 +997,7 @@ var InvocationContext = class _InvocationContext {
997
997
  * of this invocation.
998
998
  */
999
999
  _invocationCostManager = new InvocationCostManager();
1000
+ _spanCounters;
1000
1001
  /**
1001
1002
  * Constructor for InvocationContext
1002
1003
  */
@@ -1017,6 +1018,11 @@ var InvocationContext = class _InvocationContext {
1017
1018
  this.runConfig = options.runConfig;
1018
1019
  this.contextCacheConfig = options.contextCacheConfig;
1019
1020
  this.transferContext = options.transferContext;
1021
+ this._spanCounters = options.spanCounters ?? {
1022
+ llm: 0,
1023
+ tool: 0,
1024
+ agent: 0
1025
+ };
1020
1026
  }
1021
1027
  /**
1022
1028
  * App name from the session
@@ -1040,6 +1046,30 @@ var InvocationContext = class _InvocationContext {
1040
1046
  this.runConfig
1041
1047
  );
1042
1048
  }
1049
+ /**
1050
+ * Returns the next LLM span index for this invocation.
1051
+ */
1052
+ nextLlmSpanIndex() {
1053
+ return ++this._spanCounters.llm;
1054
+ }
1055
+ /**
1056
+ * Returns the next tool span index for this invocation.
1057
+ */
1058
+ nextToolSpanIndex() {
1059
+ return ++this._spanCounters.tool;
1060
+ }
1061
+ /**
1062
+ * Returns the next agent span index for this invocation.
1063
+ */
1064
+ nextAgentSpanIndex() {
1065
+ return ++this._spanCounters.agent;
1066
+ }
1067
+ /**
1068
+ * Exposes shared span counters for child contexts.
1069
+ */
1070
+ getSpanCounters() {
1071
+ return this._spanCounters;
1072
+ }
1043
1073
  /**
1044
1074
  * Creates a child invocation context for a sub-agent
1045
1075
  */
@@ -1064,8 +1094,9 @@ var InvocationContext = class _InvocationContext {
1064
1094
  transcriptionCache: this.transcriptionCache,
1065
1095
  runConfig: this.runConfig,
1066
1096
  contextCacheConfig: this.contextCacheConfig,
1067
- transferContext: this.transferContext
1097
+ transferContext: this.transferContext,
1068
1098
  // Propagate transfer context
1099
+ spanCounters: this._spanCounters
1069
1100
  });
1070
1101
  }
1071
1102
  };
@@ -1828,7 +1859,7 @@ var DEFAULTS = {
1828
1859
  CAPTURE_MESSAGE_CONTENT: true,
1829
1860
  ENABLE_TRACING: true,
1830
1861
  ENABLE_METRICS: true,
1831
- ENABLE_AUTO_INSTRUMENTATION: true
1862
+ ENABLE_AUTO_INSTRUMENTATION: false
1832
1863
  };
1833
1864
 
1834
1865
  // src/telemetry/metrics.ts
@@ -2311,8 +2342,9 @@ var SetupService = class {
2311
2342
  }
2312
2343
  }
2313
2344
  this.isInitialized = true;
2345
+ const versionLabel = config.appVersion ? ` v${config.appVersion}` : "";
2314
2346
  diag.info(
2315
- `Telemetry initialized successfully for ${config.appName} v${config.appVersion || "unknown"}`
2347
+ `Telemetry initialized successfully for ${config.appName}${versionLabel}`
2316
2348
  );
2317
2349
  } catch (error) {
2318
2350
  diag.error("Error initializing telemetry:", error);
@@ -6180,9 +6212,12 @@ async function handleFunctionCallsAsync(invocationContext, functionCallEvent, to
6180
6212
  functionCall,
6181
6213
  toolsDict
6182
6214
  );
6215
+ const toolSpanIndex = invocationContext.nextToolSpanIndex();
6183
6216
  const functionArgs = functionCall.args || {};
6184
6217
  const tracer2 = telemetryService.getTracer();
6185
- const span = tracer2.startSpan(`execute_tool [${tool.name}]`);
6218
+ const span = tracer2.startSpan(
6219
+ `execute_tool [${tool.name}] #${toolSpanIndex}`
6220
+ );
6186
6221
  const spanContext = trace3.setSpan(context2.active(), span);
6187
6222
  const toolStartTime = Date.now();
6188
6223
  let toolStatus = "success";
@@ -6271,6 +6306,9 @@ async function handleFunctionCallsAsync(invocationContext, functionCallEvent, to
6271
6306
  // no retry
6272
6307
  wasOverridden
6273
6308
  );
6309
+ telemetryService.setActiveSpanAttributes({
6310
+ [SEMCONV.GEN_AI_TOOL_NAME]: `${tool.name} #${toolSpanIndex}`
6311
+ });
6274
6312
  return { result, event: functionResponseEvent };
6275
6313
  });
6276
6314
  if (!functionResponse) {
@@ -7194,6 +7232,7 @@ var AgentTool = class extends BaseTool {
7194
7232
  pluginManager: parentInvocation.pluginManager,
7195
7233
  runConfig: parentInvocation.runConfig,
7196
7234
  contextCacheConfig: parentInvocation.contextCacheConfig,
7235
+ spanCounters: parentInvocation.getSpanCounters(),
7197
7236
  userContent: {
7198
7237
  role: "user",
7199
7238
  parts: [{ text: String(input) }]
@@ -10497,6 +10536,7 @@ var BaseLlmFlow = class {
10497
10536
  });
10498
10537
  const llm = this.__getLlm(invocationContext);
10499
10538
  const isStreaming = invocationContext.runConfig.streamingMode === "sse" /* SSE */;
10539
+ const llmSpanIndex = invocationContext.nextLlmSpanIndex();
10500
10540
  const generator = async function* () {
10501
10541
  for await (const llmResponse of this._callLlmAsync(
10502
10542
  invocationContext,
@@ -10515,7 +10555,7 @@ var BaseLlmFlow = class {
10515
10555
  }
10516
10556
  }.bind(this)();
10517
10557
  yield* telemetryService.traceAsyncGenerator(
10518
- isStreaming ? `llm_stream [${llm.model}]` : `llm_generate [${llm.model}]`,
10558
+ isStreaming ? `llm_stream [${llm.model}] #${llmSpanIndex}` : `llm_generate [${llm.model}] #${llmSpanIndex}`,
10519
10559
  generator
10520
10560
  );
10521
10561
  }
@@ -12891,8 +12931,9 @@ var BaseAgent = class {
12891
12931
  * Entry method to run an agent via text-based conversation.
12892
12932
  */
12893
12933
  async *runAsync(parentContext) {
12934
+ const agentSpanIndex = parentContext.nextAgentSpanIndex();
12894
12935
  yield* telemetryService.traceAsyncGenerator(
12895
- `agent_run [${this.name}]`,
12936
+ `agent_run [${this.name}] #${agentSpanIndex}`,
12896
12937
  this.runAsyncInternal(parentContext)
12897
12938
  );
12898
12939
  }
@@ -12900,8 +12941,9 @@ var BaseAgent = class {
12900
12941
  * Entry method to run an agent via video/audio-based conversation.
12901
12942
  */
12902
12943
  async *runLive(parentContext) {
12944
+ const agentSpanIndex = parentContext.nextAgentSpanIndex();
12903
12945
  yield* telemetryService.traceAsyncGenerator(
12904
- `agent_run_live [${this.name}]`,
12946
+ `agent_run_live [${this.name}] #${agentSpanIndex}`,
12905
12947
  this.runLiveInternal(parentContext)
12906
12948
  );
12907
12949
  }
@@ -14520,7 +14562,7 @@ var Runner = class {
14520
14562
  newMessage,
14521
14563
  runConfig = new RunConfig()
14522
14564
  }) {
14523
- const span = tracer.startSpan("invocation");
14565
+ const span = tracer.startSpan(`${this.appName}-invocation`);
14524
14566
  const spanContext = trace4.setSpan(context3.active(), span);
14525
14567
  const inputText = extractTextFromContent(newMessage);
14526
14568
  if (inputText && telemetryService.shouldCaptureContent()) {
@@ -15234,7 +15276,8 @@ function createBranchContextForSubAgent(agent, subAgent, invocationContext) {
15234
15276
  transcriptionCache: invocationContext.transcriptionCache,
15235
15277
  runConfig: invocationContext.runConfig,
15236
15278
  pluginManager: invocationContext.pluginManager,
15237
- contextCacheConfig: invocationContext.contextCacheConfig
15279
+ contextCacheConfig: invocationContext.contextCacheConfig,
15280
+ spanCounters: invocationContext.getSpanCounters()
15238
15281
  });
15239
15282
  }
15240
15283
  async function* mergeAgentRun(agentRuns) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqai/adk",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Agent Development Kit for TypeScript with multi-provider LLM support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",