Skip to content

Conversation

@copybara-service
Copy link

@copybara-service copybara-service bot commented Feb 10, 2026

feat: Updating the Tracing implementation and updating BaseAgent.runLive

This update should make the java tracing consistent with Python ADK:

  1. BaseAgent.java:

    • The runAsync and runLive methods have been modified to create the InvocationContext before starting the tracing span.
    • The span name for agent invocations has been changed from "agent_run [<agent name>]" to "invoke_agent <agent name>".
    • A new Tracing.traceAgentInvocation method is now called to add initial tracing attributes for the agent invocation.
    • In runLive, the runLiveImpl execution is now wrapped with calls to beforeAgentCallback and afterAgentCallback to ensure proper tracing of these lifecycle events.
  2. Tracing.java:

    • The OpenTelemetry tracer name has been updated from "com.google.adk" to "gcp.vertex.agent".
    • A new traceAgentInvocation method has been added to set standard attributes for agent invocation spans, including gen_ai.operation.name, gen_ai.agent.description, gen_ai.agent.name, and gen_ai.conversation.id.
    • Attribute keys used in traceToolCall, traceToolResponse, traceCallLlm, and traceSendData have been updated to use the "gcp.vertex.agent." prefix instead of "adk." or "com.google.adk".
    • The serialization of message content (like tool call arguments, tool responses, and data) is now guarded by the CAPTURE_MESSAGE_CONTENT_IN_SPANS flag. When disabled, empty JSON objects are recorded instead.
    • traceToolResponse now includes logic to extract and trace the tool_call.id and the tool response content from FunctionResponse objects.
    • traceCallLlm now captures additional LLM request and response details, such as gen_ai.request.top_p, gen_ai.request.max_tokens, gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, and gen_ai.response.finish_reasons.

@copybara-service copybara-service bot force-pushed the test_867888690 branch 4 times, most recently from b2d683b to 974b510 Compare February 10, 2026 12:39
@copybara-service copybara-service bot changed the title feat: Updating the Tracing implementation feat: Updating the Tracing implementation and updating BaseAgent.runLive Feb 10, 2026
@copybara-service copybara-service bot force-pushed the test_867888690 branch 5 times, most recently from 1ecab47 to 2f01d05 Compare February 10, 2026 21:33
This update should make the java tracing consistent with Python ADK:

1.  **`BaseAgent.java`**:
    *   The `runAsync` and `runLive` methods have been modified to create the `InvocationContext` before starting the tracing span.
    *   The span name for agent invocations has been changed from `"agent_run [<agent name>]"` to `"invoke_agent <agent name>"`.
    *   A new `Tracing.traceAgentInvocation` method is now called to add initial tracing attributes for the agent invocation.
    *   In `runLive`, the `runLiveImpl` execution is now wrapped with calls to `beforeAgentCallback` and `afterAgentCallback` to ensure proper tracing of these lifecycle events.

2.  **`Tracing.java`**:
    *   The OpenTelemetry tracer name has been updated from `"com.google.adk"` to `"gcp.vertex.agent"`.
    *   A new `traceAgentInvocation` method has been added to set standard attributes for agent invocation spans, including `gen_ai.operation.name`, `gen_ai.agent.description`, `gen_ai.agent.name`, and `gen_ai.conversation.id`.
    *   Attribute keys used in `traceToolCall`, `traceToolResponse`, `traceCallLlm`, and `traceSendData` have been updated to use the `"gcp.vertex.agent."` prefix instead of `"adk."` or `"com.google.adk"`.
    *   The serialization of message content (like tool call arguments, tool responses, and data) is now guarded by the `CAPTURE_MESSAGE_CONTENT_IN_SPANS` flag. When disabled, empty JSON objects are recorded instead.
    *   `traceToolResponse` now includes logic to extract and trace the `tool_call.id` and the tool response content from `FunctionResponse` objects.
    *   `traceCallLlm` now captures additional LLM request and response details, such as `gen_ai.request.top_p`, `gen_ai.request.max_tokens`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, and `gen_ai.response.finish_reasons`.

PiperOrigin-RevId: 868299966
@copybara-service copybara-service bot merged commit 8acb1ea into main Feb 10, 2026
@copybara-service copybara-service bot deleted the test_867888690 branch February 10, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant