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

Class MockLlmAgent

tests/unittests/test_runners.py:90–113  ·  view source on GitHub ↗

Mock LLM agent for unit testing.

Source from the content-addressed store, hash-verified

88
89
90class MockLlmAgent(LlmAgent):
91 """Mock LLM agent for unit testing."""
92
93 def __init__(
94 self,
95 name: str,
96 disallow_transfer_to_parent: bool = False,
97 parent_agent: Optional[BaseAgent] = None,
98 ):
99 # Use a string model instead of mock
100 super().__init__(name=name, model="gemini-1.5-pro", sub_agents=[])
101 self.disallow_transfer_to_parent = disallow_transfer_to_parent
102 self.parent_agent = parent_agent
103
104 async def _run_async_impl(
105 self, invocation_context: InvocationContext
106 ) -> AsyncGenerator[Event, None]:
107 yield Event(
108 invocation_id=invocation_context.invocation_id,
109 author=self.name,
110 content=types.Content(
111 role="model", parts=[types.Part(text="Test LLM response")]
112 ),
113 )
114
115
116class MockAgentWithMetadata(BaseAgent):

Calls

no outgoing calls