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

Function _setup_runner_context

src/google/adk/cli/cli.py:274–345  ·  view source on GitHub ↗

Sets up the agent, services, and environment for running. Returns a tuple containing the loaded agent/app, services, and other contextual information needed for execution.

(
    *,
    agent_parent_dir: str,
    agent_folder_name: str,
    in_memory: bool = False,
    session_service_uri: Optional[str] = None,
    artifact_service_uri: Optional[str] = None,
    memory_service_uri: Optional[str] = None,
    use_local_storage: bool = True,
    default_llm_model: Optional[str] = None,
)

Source from the content-addressed store, hash-verified

272
273
274def _setup_runner_context(
275 *,
276 agent_parent_dir: str,
277 agent_folder_name: str,
278 in_memory: bool = False,
279 session_service_uri: Optional[str] = None,
280 artifact_service_uri: Optional[str] = None,
281 memory_service_uri: Optional[str] = None,
282 use_local_storage: bool = True,
283 default_llm_model: Optional[str] = None,
284):
285 """Sets up the agent, services, and environment for running.
286
287 Returns a tuple containing the loaded agent/app, services, and other
288 contextual information needed for execution.
289 """
290 agent_parent_path = Path(agent_parent_dir).resolve()
291 agent_root = agent_parent_path / agent_folder_name
292 load_services_module(str(agent_root))
293 user_id = 'test_user'
294
295 agents_dir = str(agent_parent_path)
296 agent_loader = AgentLoader(agents_dir=agents_dir)
297 agent_or_app = agent_loader.load_agent(agent_folder_name)
298
299 if default_llm_model:
300 _override_default_llm_model(default_llm_model)
301 session_app_name = (
302 agent_or_app.name if isinstance(agent_or_app, App) else agent_folder_name
303 )
304 app_name_to_dir = None
305 if isinstance(agent_or_app, App) and agent_or_app.name != agent_folder_name:
306 app_name_to_dir = {agent_or_app.name: agent_folder_name}
307
308 if not is_env_enabled('ADK_DISABLE_LOAD_DOTENV'):
309 envs.load_dotenv_for_agent(agent_folder_name, agents_dir)
310
311 if in_memory:
312 session_service_uri = 'memory://'
313 artifact_service_uri = 'memory://'
314 use_local_storage = False
315
316 session_service = create_session_service_from_options(
317 base_dir=agent_parent_path,
318 session_service_uri=session_service_uri,
319 app_name_to_dir=app_name_to_dir,
320 use_local_storage=use_local_storage,
321 )
322
323 artifact_service = create_artifact_service_from_options(
324 base_dir=agent_parent_path,
325 artifact_service_uri=artifact_service_uri,
326 app_name_to_dir=app_name_to_dir,
327 use_local_storage=use_local_storage,
328 )
329 memory_service = create_memory_service_from_options(
330 base_dir=agent_parent_path,
331 memory_service_uri=memory_service_uri,

Callers 2

run_cliFunction · 0.85
run_once_cliFunction · 0.85

Calls 10

load_agentMethod · 0.95
load_services_moduleFunction · 0.85
AgentLoaderClass · 0.85
is_env_enabledFunction · 0.85
resolveMethod · 0.45

Tested by

no test coverage detected