google-cloud-agentplatform 1.165.1.dev0__tar.gz → 1.165.1.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. {google_cloud_agentplatform-1.165.1.dev0/google_cloud_agentplatform.egg-info → google_cloud_agentplatform-1.165.1.dev1}/PKG-INFO +1 -1
  2. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_common.py +64 -66
  3. google_cloud_agentplatform-1.165.1.dev0/agentplatform/_genai/_agent_engines_utils.py → google_cloud_agentplatform-1.165.1.dev1/agentplatform/_genai/_runtimes_utils.py +91 -98
  4. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/client.py +98 -17
  5. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/evals.py +11 -11
  6. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/feedback_contexts.py +3 -3
  7. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/feedback_entries.py +7 -7
  8. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/live.py +10 -10
  9. google_cloud_agentplatform-1.165.1.dev0/agentplatform/_genai/live_agent_engines.py → google_cloud_agentplatform-1.165.1.dev1/agentplatform/_genai/live_runtimes.py +23 -24
  10. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/runtime_revisions.py +154 -174
  11. google_cloud_agentplatform-1.165.1.dev0/agentplatform/_genai/agent_engines.py → google_cloud_agentplatform-1.165.1.dev1/agentplatform/_genai/runtimes.py +420 -722
  12. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/sandbox_snapshots.py +34 -34
  13. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/sandbox_templates.py +23 -23
  14. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/sandboxes.py +112 -122
  15. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/session_events.py +60 -60
  16. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/sessions.py +155 -167
  17. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/types/__init__.py +331 -497
  18. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/types/common.py +16482 -17666
  19. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/version.py +1 -1
  20. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1/google_cloud_agentplatform.egg-info}/PKG-INFO +1 -1
  21. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/google_cloud_agentplatform.egg-info/SOURCES.txt +2 -3
  22. google_cloud_agentplatform-1.165.1.dev0/agentplatform/_genai/runtimes.py +0 -78
  23. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/LICENSE +0 -0
  24. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/README.md +0 -0
  25. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/__init__.py +0 -0
  26. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/__init__.py +0 -0
  27. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_bigquery_utils.py +0 -0
  28. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_datasets_utils.py +0 -0
  29. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_builtin_tools.py +0 -0
  30. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_constant.py +0 -0
  31. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_data_converters.py +0 -0
  32. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_metric_handlers.py +0 -0
  33. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_metric_loaders.py +0 -0
  34. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_utils.py +0 -0
  35. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_evals_visualization.py +0 -0
  36. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_gcs_utils.py +0 -0
  37. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_logging_utils.py +0 -0
  38. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_memory_bank_utils.py +0 -0
  39. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_observability_data_converter.py +0 -0
  40. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_operations_utils.py +0 -0
  41. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_prompt_management_utils.py +0 -0
  42. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_prompt_optimizer_utils.py +0 -0
  43. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_skills_utils.py +0 -0
  44. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/_transformers.py +0 -0
  45. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/a2a_task_events.py +0 -0
  46. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/a2a_tasks.py +0 -0
  47. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/datasets.py +0 -0
  48. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/endpoints.py +0 -0
  49. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/example_stores.py +0 -0
  50. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/memories.py +0 -0
  51. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/memory_banks.py +0 -0
  52. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/memory_revisions.py +0 -0
  53. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/model_garden.py +0 -0
  54. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/prompt_optimizer.py +0 -0
  55. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/prompts.py +0 -0
  56. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/rag.py +0 -0
  57. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/skill_revisions.py +0 -0
  58. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/skills.py +0 -0
  59. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/types/agent_engines.py +0 -0
  60. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/types/evals.py +0 -0
  61. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/types/prompt_optimizer.py +0 -0
  62. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/agentplatform/_genai/types/prompts.py +0 -0
  63. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/google_cloud_agentplatform.egg-info/dependency_links.txt +0 -0
  64. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/google_cloud_agentplatform.egg-info/requires.txt +0 -0
  65. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/google_cloud_agentplatform.egg-info/top_level.txt +0 -0
  66. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/pyproject.toml +0 -0
  67. {google_cloud_agentplatform-1.165.1.dev0 → google_cloud_agentplatform-1.165.1.dev1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: google-cloud-agentplatform
3
- Version: 1.165.1.dev0
3
+ Version: 1.165.1.dev1
4
4
  Summary: Google Cloud Agent Platform Client Library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License: Apache-2.0
@@ -139,21 +139,21 @@ def _get_api_client_with_location(
139
139
  )._api_client
140
140
 
141
141
 
142
- def _get_agent_engine_instance(
142
+ def _get_runtime_instance(
143
143
  agent_name: str, api_client: BaseApiClient
144
- ) -> Union[types.AgentEngine, Any]:
144
+ ) -> Union[types.Runtime, Any]:
145
145
  """Gets or creates an agent engine instance for the current thread."""
146
- if not hasattr(_thread_local_data, "agent_engine_instances"):
147
- _thread_local_data.agent_engine_instances = {}
148
- if agent_name not in _thread_local_data.agent_engine_instances:
146
+ if not hasattr(_thread_local_data, "runtime_instances"):
147
+ _thread_local_data.runtime_instances = {}
148
+ if agent_name not in _thread_local_data.runtime_instances:
149
149
  client = agentplatform.Client(
150
150
  project=api_client.project,
151
151
  location=api_client.location,
152
152
  )
153
- _thread_local_data.agent_engine_instances[agent_name] = (
154
- client.agent_engines.get(name=agent_name)
153
+ _thread_local_data.runtime_instances[agent_name] = client.runtimes.get(
154
+ name=agent_name
155
155
  )
156
- return _thread_local_data.agent_engine_instances[agent_name]
156
+ return _thread_local_data.runtime_instances[agent_name]
157
157
 
158
158
 
159
159
  def _generate_content_with_retry(
@@ -1804,7 +1804,7 @@ def _execute_inference_concurrently(
1804
1804
  model_or_fn: Optional[Union[str, Callable[[Any], Any]]] = None,
1805
1805
  gemini_config: Optional[genai_types.GenerateContentConfig] = None,
1806
1806
  inference_fn: Optional[Callable[..., Any]] = None,
1807
- agent_engine: Optional[Union[str, types.AgentEngine]] = None,
1807
+ runtime: Optional[Union[str, types.Runtime]] = None,
1808
1808
  agent: Optional["LlmAgent"] = None, # type: ignore # noqa: F821
1809
1809
  user_simulator_config: Optional[types.evals.UserSimulatorConfig] = None,
1810
1810
  ) -> list[
@@ -1834,7 +1834,7 @@ def _execute_inference_concurrently(
1834
1834
  # prompt from the structured agent_data rather than requiring a flat
1835
1835
  # prompt/request column.
1836
1836
  has_agent_data = (
1837
- agent is not None or agent_engine is not None
1837
+ agent is not None or runtime is not None
1838
1838
  ) and AGENT_DATA in prompt_dataset.columns
1839
1839
 
1840
1840
  primary_prompt_column: Optional[str] = None
@@ -1851,7 +1851,7 @@ def _execute_inference_concurrently(
1851
1851
  f" Found: {prompt_dataset.columns.tolist()}"
1852
1852
  )
1853
1853
 
1854
- max_workers = AGENT_MAX_WORKERS if agent_engine or agent else MAX_WORKERS
1854
+ max_workers = AGENT_MAX_WORKERS if runtime or agent else MAX_WORKERS
1855
1855
  with tqdm(total=len(prompt_dataset), desc=progress_desc) as pbar:
1856
1856
  with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as executor:
1857
1857
  for index, row in prompt_dataset.iterrows():
@@ -1907,29 +1907,29 @@ def _execute_inference_concurrently(
1907
1907
  pbar.update(1)
1908
1908
  continue
1909
1909
 
1910
- if agent_engine or agent:
1910
+ if runtime or agent:
1911
1911
 
1912
1912
  def agent_run_wrapper( # type: ignore[no-untyped-def]
1913
1913
  row_arg,
1914
1914
  contents_arg,
1915
- agent_engine_arg,
1915
+ runtime_arg,
1916
1916
  agent_arg,
1917
1917
  inference_fn_arg,
1918
1918
  api_client_arg,
1919
1919
  user_simulator_config_arg,
1920
1920
  ) -> Any:
1921
- if agent_engine_arg:
1922
- if isinstance(agent_engine_arg, str):
1923
- agent_engine_instance = _get_agent_engine_instance(
1924
- agent_engine_arg, api_client_arg
1921
+ if runtime_arg:
1922
+ if isinstance(runtime_arg, str):
1923
+ runtime_instance = _get_runtime_instance(
1924
+ runtime_arg, api_client_arg
1925
1925
  )
1926
1926
  else:
1927
- agent_engine_instance = agent_engine_arg
1927
+ runtime_instance = runtime_arg
1928
1928
 
1929
1929
  return inference_fn_arg(
1930
1930
  row=row_arg,
1931
1931
  contents=contents_arg,
1932
- agent_engine=agent_engine_instance,
1932
+ runtime=runtime_instance,
1933
1933
  )
1934
1934
  elif agent_arg:
1935
1935
  return inference_fn_arg(
@@ -1944,7 +1944,7 @@ def _execute_inference_concurrently(
1944
1944
  agent_run_wrapper,
1945
1945
  row,
1946
1946
  contents,
1947
- agent_engine,
1947
+ runtime,
1948
1948
  agent,
1949
1949
  inference_fn,
1950
1950
  api_client,
@@ -2559,7 +2559,7 @@ def _execute_inference(
2559
2559
  api_client: BaseApiClient,
2560
2560
  src: Union[str, pd.DataFrame],
2561
2561
  model: Optional[Union[Callable[[Any], Any], str]] = None,
2562
- agent_engine: Optional[Union[str, types.AgentEngine]] = None,
2562
+ runtime: Optional[Union[str, types.Runtime]] = None,
2563
2563
  agent: Optional["LlmAgent"] = None, # type: ignore # noqa: F821
2564
2564
  gemini_agent: Optional[str] = None,
2565
2565
  dest: Optional[str] = None,
@@ -2577,8 +2577,8 @@ def _execute_inference(
2577
2577
  GCS path, or a BigQuery table) or a Pandas DataFrame.
2578
2578
  model: The model to use for inference. Can be a callable function or a
2579
2579
  string representing a model.
2580
- agent_engine: The agent engine to use for inference. Can be a resource
2581
- name string or an `AgentEngine` instance.
2580
+ runtime: The agent engine to use for inference. Can be a resource
2581
+ name string or an `Runtime` instance.
2582
2582
  agent: The local agent to use for inference. Can be an ADK agent instance.
2583
2583
  gemini_agent: The Gemini Agents API agent resource name to run inference
2584
2584
  against via the Interactions API.
@@ -2599,10 +2599,9 @@ def _execute_inference(
2599
2599
  if location:
2600
2600
  api_client = _get_api_client_with_location(api_client, location)
2601
2601
 
2602
- if sum(x is not None for x in [model, agent_engine, agent, gemini_agent]) != 1:
2602
+ if sum(x is not None for x in [model, runtime, agent, gemini_agent]) != 1:
2603
2603
  raise ValueError(
2604
- "Exactly one of model, agent_engine, agent, or gemini_agent must be"
2605
- " provided."
2604
+ "Exactly one of model, runtime, agent, or gemini_agent must be" " provided."
2606
2605
  )
2607
2606
 
2608
2607
  prompt_dataset = _load_dataframe(api_client, src)
@@ -2665,27 +2664,26 @@ def _execute_inference(
2665
2664
  eval_dataset_df=results_df,
2666
2665
  candidate_name=candidate_name,
2667
2666
  )
2668
- elif agent_engine or agent:
2667
+ elif runtime or agent:
2669
2668
  candidate_name = None
2670
- if agent_engine:
2671
- candidate_name = "agent_engine_0"
2669
+ if runtime:
2670
+ candidate_name = "runtime_0"
2672
2671
  elif agent:
2673
2672
  agent_config = types.evals.AgentConfig.from_agent(agent)
2674
2673
  candidate_name = agent_config.agent_id or "agent_0"
2675
2674
 
2676
2675
  if (
2677
- agent_engine
2678
- and not isinstance(agent_engine, str)
2676
+ runtime
2677
+ and not isinstance(runtime, str)
2679
2678
  and not (
2680
- hasattr(agent_engine, "api_client")
2681
- and type(agent_engine).__name__ == "AgentEngine"
2679
+ hasattr(runtime, "api_client") and type(runtime).__name__ == "Runtime"
2682
2680
  )
2683
2681
  ):
2684
2682
  raise TypeError(
2685
- f"Unsupported agent_engine type: {type(agent_engine)}. Expecting a"
2683
+ f"Unsupported runtime type: {type(runtime)}. Expecting a"
2686
2684
  " string (agent engine resource name in"
2687
2685
  " 'projects/{project_id}/locations/{location_id}/reasoningEngines/{reasoning_engine_id}'"
2688
- " format) or a types.AgentEngine instance."
2686
+ " format) or a types.Runtime instance."
2689
2687
  )
2690
2688
  if (
2691
2689
  _evals_constant.INTERMEDIATE_EVENTS in prompt_dataset.columns
@@ -2701,7 +2699,7 @@ def _execute_inference(
2701
2699
  logger.debug("Starting Agent Run process ...")
2702
2700
  results_df = _run_agent_internal(
2703
2701
  api_client=api_client,
2704
- agent_engine=agent_engine,
2702
+ runtime=runtime,
2705
2703
  agent=agent,
2706
2704
  prompt_dataset=prompt_dataset,
2707
2705
  user_simulator_config=user_simulator_config,
@@ -2716,7 +2714,7 @@ def _execute_inference(
2716
2714
  candidate_name=candidate_name,
2717
2715
  )
2718
2716
  else:
2719
- raise ValueError("Either model, agent_engine or agent must be provided.")
2717
+ raise ValueError("Either model, runtime or agent must be provided.")
2720
2718
 
2721
2719
  if dest:
2722
2720
  file_name = "inference_results.jsonl" if model else "agent_run_results.jsonl"
@@ -3316,7 +3314,7 @@ def _create_agent_results_dataframe(
3316
3314
 
3317
3315
  def _run_agent_internal(
3318
3316
  api_client: BaseApiClient,
3319
- agent_engine: Optional[Union[str, types.AgentEngine]],
3317
+ runtime: Optional[Union[str, types.Runtime]],
3320
3318
  agent: Optional["LlmAgent"], # type: ignore # noqa: F821
3321
3319
  prompt_dataset: pd.DataFrame,
3322
3320
  user_simulator_config: Optional[types.evals.UserSimulatorConfig] = None,
@@ -3325,7 +3323,7 @@ def _run_agent_internal(
3325
3323
  """Runs an agent."""
3326
3324
  raw_responses = _run_agent(
3327
3325
  api_client=api_client,
3328
- agent_engine=agent_engine,
3326
+ runtime=runtime,
3329
3327
  agent=agent,
3330
3328
  prompt_dataset=prompt_dataset,
3331
3329
  user_simulator_config=user_simulator_config,
@@ -3367,7 +3365,7 @@ def _run_agent_internal(
3367
3365
 
3368
3366
  def _run_agent(
3369
3367
  api_client: BaseApiClient,
3370
- agent_engine: Optional[Union[str, types.AgentEngine]],
3368
+ runtime: Optional[Union[str, types.Runtime]],
3371
3369
  agent: Optional["LlmAgent"], # type: ignore # noqa: F821
3372
3370
  prompt_dataset: pd.DataFrame,
3373
3371
  user_simulator_config: Optional[types.evals.UserSimulatorConfig] = None,
@@ -3386,10 +3384,10 @@ def _run_agent(
3386
3384
  simulator is never routed to a different region.
3387
3385
  """
3388
3386
  del allow_cross_region_model # Simulator always runs in the client region.
3389
- if agent_engine:
3387
+ if runtime:
3390
3388
  return _execute_inference_concurrently(
3391
3389
  api_client=api_client,
3392
- agent_engine=agent_engine,
3390
+ runtime=runtime,
3393
3391
  prompt_dataset=prompt_dataset,
3394
3392
  progress_desc="Agent Run",
3395
3393
  gemini_config=None,
@@ -3407,12 +3405,12 @@ def _run_agent(
3407
3405
  inference_fn=_execute_local_agent_run_with_retry,
3408
3406
  )
3409
3407
  else:
3410
- raise ValueError("Neither agent_engine nor agent is provided.")
3408
+ raise ValueError("Neither runtime nor agent is provided.")
3411
3409
 
3412
3410
 
3413
- def _create_agent_engine_session(
3411
+ def _create_runtime_session(
3414
3412
  *,
3415
- agent_engine: types.AgentEngine,
3413
+ runtime: types.Runtime,
3416
3414
  user_id: str,
3417
3415
  session_state: Optional[dict[str, Any]] = None,
3418
3416
  ) -> Any:
@@ -3424,7 +3422,7 @@ def _create_agent_engine_session(
3424
3422
  Sessions API.
3425
3423
 
3426
3424
  Args:
3427
- agent_engine: The AgentEngine instance.
3425
+ runtime: The Runtime instance.
3428
3426
  user_id: The user ID for the session.
3429
3427
  session_state: Optional initial state for the session.
3430
3428
 
@@ -3435,7 +3433,7 @@ def _create_agent_engine_session(
3435
3433
  RuntimeError: If the session could not be created via either path.
3436
3434
  """
3437
3435
  try:
3438
- session = agent_engine.create_session( # type: ignore[attr-defined]
3436
+ session = runtime.create_session( # type: ignore[attr-defined]
3439
3437
  user_id=user_id,
3440
3438
  state=session_state,
3441
3439
  )
@@ -3448,18 +3446,18 @@ def _create_agent_engine_session(
3448
3446
  "Agent engine does not have 'create_session' operation registered."
3449
3447
  " Falling back to managed Sessions API."
3450
3448
  )
3451
- if agent_engine.api_resource is None:
3449
+ if runtime.api_resource is None:
3452
3450
  raise RuntimeError(
3453
- "Failed to create session: agent_engine.api_resource is None."
3451
+ "Failed to create session: runtime.api_resource is None."
3454
3452
  ) from exc
3455
- if agent_engine.api_client is None:
3453
+ if runtime.api_client is None:
3456
3454
  raise RuntimeError(
3457
- "Failed to create session: agent_engine.api_client is None."
3455
+ "Failed to create session: runtime.api_client is None."
3458
3456
  ) from exc
3459
- operation = agent_engine.api_client.sessions.create(
3460
- name=agent_engine.api_resource.name,
3457
+ operation = runtime.api_client.sessions.create(
3458
+ name=runtime.api_resource.name,
3461
3459
  user_id=user_id,
3462
- config=types.CreateAgentEngineSessionConfig(
3460
+ config=types.CreateRuntimeSessionConfig(
3463
3461
  session_state=session_state,
3464
3462
  ),
3465
3463
  )
@@ -3481,7 +3479,7 @@ def _create_agent_engine_session(
3481
3479
  def _execute_agent_run_with_retry(
3482
3480
  row: pd.Series,
3483
3481
  contents: Union[genai_types.ContentListUnion, genai_types.ContentListUnionDict],
3484
- agent_engine: types.AgentEngine,
3482
+ runtime: types.Runtime,
3485
3483
  max_retries: int = 3,
3486
3484
  ) -> Union[list[dict[str, Any]], dict[str, Any]]:
3487
3485
  """Executes agent run over agent engine for a single prompt."""
@@ -3497,8 +3495,8 @@ def _execute_agent_run_with_retry(
3497
3495
  return {"error": f"Failed to get all required agent engine inputs: {e}"}
3498
3496
 
3499
3497
  try:
3500
- session_id = _create_agent_engine_session(
3501
- agent_engine=agent_engine,
3498
+ session_id = _create_runtime_session(
3499
+ runtime=runtime,
3502
3500
  user_id=user_id,
3503
3501
  session_state=session_state,
3504
3502
  )
@@ -3516,19 +3514,19 @@ def _execute_agent_run_with_retry(
3516
3514
  agent_data_obj = types.evals.AgentData.model_validate(agent_data_obj)
3517
3515
  _, history_events = _extract_prompt_from_agent_data(agent_data_obj)
3518
3516
 
3519
- if agent_engine.api_resource is None:
3520
- return {"error": "agent_engine.api_resource is None."}
3521
- if agent_engine.api_client is None:
3522
- return {"error": "agent_engine.api_client is None."}
3523
- session_name = f"{agent_engine.api_resource.name}/sessions/{session_id}"
3517
+ if runtime.api_resource is None:
3518
+ return {"error": "runtime.api_resource is None."}
3519
+ if runtime.api_client is None:
3520
+ return {"error": "runtime.api_client is None."}
3521
+ session_name = f"{runtime.api_resource.name}/sessions/{session_id}"
3524
3522
  base_ts = datetime.datetime(2000, 1, 1, tzinfo=datetime.timezone.utc)
3525
3523
  for i, ag_event in enumerate(history_events):
3526
- agent_engine.api_client.sessions.events.append(
3524
+ runtime.api_client.sessions.events.append(
3527
3525
  name=session_name,
3528
3526
  author=ag_event.author or "user",
3529
3527
  invocation_id="history",
3530
3528
  timestamp=base_ts + datetime.timedelta(seconds=i),
3531
- config=types.AppendAgentEngineSessionEventConfig(
3529
+ config=types.AppendRuntimeSessionEventConfig(
3532
3530
  content=ag_event.content,
3533
3531
  ),
3534
3532
  )
@@ -3537,7 +3535,7 @@ def _execute_agent_run_with_retry(
3537
3535
  for attempt in range(max_retries):
3538
3536
  try:
3539
3537
  responses = []
3540
- for event in agent_engine.stream_query( # type: ignore[attr-defined]
3538
+ for event in runtime.stream_query( # type: ignore[attr-defined]
3541
3539
  user_id=user_id,
3542
3540
  session_id=session_id,
3543
3541
  message=contents,
@@ -4159,7 +4157,7 @@ def _create_evaluation_set_from_dataframe(
4159
4157
  agent_data_obj = agent_data_val
4160
4158
 
4161
4159
  # When agent_data exists but has no agents map (e.g. from remote
4162
- # agent_engine inference), inject the agents map from agent_info so
4160
+ # runtime inference), inject the agents map from agent_info so
4163
4161
  # the server-side autorater can access tool definitions and
4164
4162
  # instructions.
4165
4163
  if (