apache/beam · error · ImportError

google-adk is required to use ADKAgentModelHandler. Install…

Error message

google-adk is required to use ADKAgentModelHandler. Install it with: pip install google-adk

What it means

ADKAgentModelHandler.__init__ detects that the optional google-adk package (flagged by ADK_AVAILABLE) is absent, so the handler cannot create runners or session services; the guard fires before any agent is invoked.

Solutions

  1. Install the dependency: pip install google-adk
  2. For containerized runners, add google-adk to the worker image's requirements and rebuild
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at sdks/python/apache_beam/ml/inference/agent_development_kit.py:139 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/a4883d943536d003. Report an issue: GitHub.

Appendix: source

Thrown at sdks/python/apache_beam/ml/inference/agent_development_kit.py:139

    max_batch_weight: Optional maximum total weight of a batch.
    element_size_fn: Optional function that returns the size (weight) of an
      element.
  """
  def __init__(
      self,
      agent: _AgentOrFactory,
      app_name: str = "beam_inference",
      session_service_factory: Optional[Callable[[],
                                                 "BaseSessionService"]] = None,
      *,
      min_batch_size: Optional[int] = None,
      max_batch_size: Optional[int] = None,
      max_batch_duration_secs: Optional[int] = None,
      max_batch_weight: Optional[int] = None,
      element_size_fn: Optional[Callable[[Any], int]] = None,
      **kwargs):
    if not ADK_AVAILABLE:
      raise ImportError(
          "google-adk is required to use ADKAgentModelHandler. "
          "Install it with: pip install google-adk")

    if agent is None:
      raise ValueError("'agent' must be an Agent instance or a callable.")

    self._agent_or_factory = agent
    self._app_name = app_name
    self._session_service_factory = session_service_factory

    super().__init__(
        min_batch_size=min_batch_size,
        max_batch_size=max_batch_size,
        max_batch_duration_secs=max_batch_duration_secs,
        max_batch_weight=max_batch_weight,
        element_size_fn=element_size_fn,
        **kwargs)

View on GitHub (pinned to 12126d8942)