MCPcopy Create free account
hub / github.com/google/adk-python / test_trace_agent_invocation

Function test_trace_agent_invocation

tests/unittests/telemetry/test_spans.py:131–151  ·  view source on GitHub ↗

Test trace_agent_invocation sets span attributes correctly.

(mock_span_fixture)

Source from the content-addressed store, hash-verified

129
130@pytest.mark.asyncio
131async def test_trace_agent_invocation(mock_span_fixture):
132 """Test trace_agent_invocation sets span attributes correctly."""
133 agent = LlmAgent(name='test_llm_agent', model='gemini-pro')
134 agent.description = 'Test agent description'
135 invocation_context = await _create_invocation_context(agent)
136
137 trace_agent_invocation(mock_span_fixture, agent, invocation_context)
138
139 expected_calls = [
140 mock.call('gen_ai.operation.name', 'invoke_agent'),
141 mock.call('gen_ai.agent.description', agent.description),
142 mock.call('gen_ai.agent.name', agent.name),
143 mock.call(
144 'gen_ai.conversation.id',
145 invocation_context.session.id,
146 ),
147 ]
148 mock_span_fixture.set_attribute.assert_has_calls(
149 expected_calls, any_order=True
150 )
151 assert mock_span_fixture.set_attribute.call_count == len(expected_calls)
152
153
154@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

LlmAgentClass · 0.90
trace_agent_invocationFunction · 0.90
callMethod · 0.45

Tested by

no test coverage detected