Skip to content

Commit 0e18f81

Browse files
Achuth17copybara-github
authored andcommitted
fix(telemetery): Rolling back change to fix issue affecting LlmAgent creation due to missing version field
Co-authored-by: Achuth Narayan Rajagopal <achuthr@google.com> PiperOrigin-RevId: 883336463
1 parent 51c19cb commit 0e18f81

File tree

4 files changed

+0
-46
lines changed

4 files changed

+0
-46
lines changed

src/google/adk/agents/base_agent.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,6 @@ class MyAgent(BaseAgent):
136136
sub_agents: list[BaseAgent] = Field(default_factory=list)
137137
"""The sub-agents of this agent."""
138138

139-
version: str = ''
140-
"""The agent's version.
141-
142-
Version of the agent being invoked. Used to identify the Agent involved in telemetry.
143-
"""
144-
145139
before_agent_callback: Optional[BeforeAgentCallback] = None
146140
"""Callback or list of callbacks to be invoked before the agent run.
147141
@@ -686,7 +680,6 @@ def __create_kwargs(
686680

687681
kwargs: Dict[str, Any] = {
688682
'name': config.name,
689-
'version': config.version,
690683
'description': config.description,
691684
}
692685
if config.sub_agents:

src/google/adk/agents/base_agent_config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ class BaseAgentConfig(BaseModel):
5555

5656
name: str = Field(description='Required. The name of the agent.')
5757

58-
version: str = Field(
59-
default='', description='Optional. The version of the agent.'
60-
)
61-
6258
description: str = Field(
6359
default='', description='Optional. The description of the agent.'
6460
)

src/google/adk/telemetry/tracing.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@
8383

8484
USER_CONTENT_ELIDED = '<elided>'
8585

86-
GEN_AI_AGENT_VERSION = 'gen_ai.agent.version'
87-
8886
# Needed to avoid circular imports
8987
if TYPE_CHECKING:
9088
from ..agents.base_agent import BaseAgent
@@ -159,7 +157,6 @@ def trace_agent_invocation(
159157
span.set_attribute(GEN_AI_AGENT_DESCRIPTION, agent.description)
160158

161159
span.set_attribute(GEN_AI_AGENT_NAME, agent.name)
162-
span.set_attribute(GEN_AI_AGENT_VERSION, agent.version)
163160
span.set_attribute(GEN_AI_CONVERSATION_ID, ctx.session.id)
164161

165162

@@ -495,7 +492,6 @@ def use_generate_content_span(
495492
USER_ID: invocation_context.session.user_id,
496493
'gcp.vertex.agent.event_id': model_response_event.id,
497494
'gcp.vertex.agent.invocation_id': invocation_context.invocation_id,
498-
GEN_AI_AGENT_VERSION: invocation_context.agent.version,
499495
}
500496
if (
501497
_is_gemini_agent(invocation_context.agent)
@@ -530,7 +526,6 @@ async def use_inference_span(
530526
USER_ID: invocation_context.session.user_id,
531527
'gcp.vertex.agent.event_id': model_response_event.id,
532528
'gcp.vertex.agent.invocation_id': invocation_context.invocation_id,
533-
GEN_AI_AGENT_VERSION: invocation_context.agent.version,
534529
}
535530
if (
536531
_is_gemini_agent(invocation_context.agent)

tests/unittests/telemetry/test_spans.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from google.adk.models.llm_response import LlmResponse
2727
from google.adk.sessions.in_memory_session_service import InMemorySessionService
2828
from google.adk.telemetry.tracing import ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS
29-
from google.adk.telemetry.tracing import GEN_AI_AGENT_VERSION
3029
from google.adk.telemetry.tracing import trace_agent_invocation
3130
from google.adk.telemetry.tracing import trace_call_llm
3231
from google.adk.telemetry.tracing import trace_inference_result
@@ -122,33 +121,6 @@ async def test_trace_agent_invocation(mock_span_fixture):
122121
mock.call('gen_ai.operation.name', 'invoke_agent'),
123122
mock.call('gen_ai.agent.description', agent.description),
124123
mock.call('gen_ai.agent.name', agent.name),
125-
mock.call(GEN_AI_AGENT_VERSION, ''),
126-
mock.call(
127-
'gen_ai.conversation.id',
128-
invocation_context.session.id,
129-
),
130-
]
131-
mock_span_fixture.set_attribute.assert_has_calls(
132-
expected_calls, any_order=True
133-
)
134-
assert mock_span_fixture.set_attribute.call_count == len(expected_calls)
135-
136-
137-
@pytest.mark.asyncio
138-
async def test_trace_agent_invocation_with_version(mock_span_fixture):
139-
"""Test trace_agent_invocation sets span attributes correctly when version is provided."""
140-
agent = LlmAgent(name='test_llm_agent', model='gemini-pro')
141-
agent.description = 'Test agent description'
142-
agent.version = '1.0.0'
143-
invocation_context = await _create_invocation_context(agent)
144-
145-
trace_agent_invocation(mock_span_fixture, agent, invocation_context)
146-
147-
expected_calls = [
148-
mock.call('gen_ai.operation.name', 'invoke_agent'),
149-
mock.call('gen_ai.agent.description', agent.description),
150-
mock.call('gen_ai.agent.name', agent.name),
151-
mock.call(GEN_AI_AGENT_VERSION, agent.version),
152124
mock.call(
153125
'gen_ai.conversation.id',
154126
invocation_context.session.id,
@@ -815,7 +787,6 @@ async def test_generate_content_span(
815787

816788
mock_span.set_attributes.assert_called_once_with({
817789
GEN_AI_AGENT_NAME: invocation_context.agent.name,
818-
GEN_AI_AGENT_VERSION: '',
819790
GEN_AI_CONVERSATION_ID: invocation_context.session.id,
820791
USER_ID: invocation_context.session.user_id,
821792
'gcp.vertex.agent.event_id': 'event-123',
@@ -1136,7 +1107,6 @@ async def test_generate_content_span_with_experimental_semconv(
11361107

11371108
mock_span.set_attributes.assert_called_once_with({
11381109
GEN_AI_AGENT_NAME: invocation_context.agent.name,
1139-
GEN_AI_AGENT_VERSION: '',
11401110
GEN_AI_CONVERSATION_ID: invocation_context.session.id,
11411111
USER_ID: invocation_context.session.user_id,
11421112
'gcp.vertex.agent.event_id': 'event-123',

0 commit comments

Comments
 (0)