MCPcopy Index your code
hub / github.com/google/adk-python / MockAgent

Class MockAgent

tests/unittests/test_runners.py:46–69  ·  view source on GitHub ↗

Mock agent for unit testing.

Source from the content-addressed store, hash-verified

44
45
46class MockAgent(BaseAgent):
47 """Mock agent for unit testing."""
48
49 def __init__(
50 self,
51 name: str,
52 parent_agent: Optional[BaseAgent] = None,
53 ):
54 super().__init__(name=name, sub_agents=[])
55 # BaseAgent doesn't have disallow_transfer_to_parent field
56 # This is intentional as we want to test non-LLM agents
57 if parent_agent:
58 self.parent_agent = parent_agent
59
60 async def _run_async_impl(
61 self, invocation_context: InvocationContext
62 ) -> AsyncGenerator[Event, None]:
63 yield Event(
64 invocation_id=invocation_context.invocation_id,
65 author=self.name,
66 content=types.Content(
67 role="model", parts=[types.Part(text="Test response")]
68 ),
69 )
70
71
72class MockLiveAgent(BaseAgent):

Calls

no outgoing calls