{"record":{"id":"bcf5df6be58d2da1","repo":"microsoft/autogen","slug":"distributed-runtime-features-require-additional-de-bcf5df","errorCode":null,"errorMessage":"Distributed runtime features require additional dependencies. Install them with: pip install autogen-core[grpc]","messagePattern":"Distributed runtime features require additional dependencies\\. Install them with: pip install autogen-core\\[grpc\\]","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py","lineNumber":19,"sourceCode":"from __future__ import annotations\n\nimport asyncio\nimport logging\nfrom abc import ABC, abstractmethod\nfrom asyncio import Future, Task\nfrom typing import Any, AsyncIterator, Awaitable, Callable, Dict, Generic, Sequence, Set, Tuple, TypeVar\n\nfrom autogen_core import TopicId\nfrom autogen_core._agent_id import AgentId\nfrom autogen_core._runtime_impl_helpers import SubscriptionManager\n\nfrom ._constants import GRPC_IMPORT_ERROR_STR\nfrom ._utils import subscription_from_proto, subscription_to_proto\n\ntry:\n    import grpc\nexcept ImportError as e:\n    raise ImportError(GRPC_IMPORT_ERROR_STR) from e\n\nfrom .protos import agent_worker_pb2, agent_worker_pb2_grpc, cloudevent_pb2\n\nlogger = logging.getLogger(\"autogen_core\")\nevent_logger = logging.getLogger(\"autogen_core.events\")\n\nClientConnectionId = str\n\n\ndef metadata_to_dict(metadata: Sequence[Tuple[str, str]] | None) -> Dict[str, str]:\n    if metadata is None:\n        return {}\n    return {key: value for key, value in metadata}\n\n\nasync def get_client_id_or_abort(context: grpc.aio.ServicerContext[Any, Any]) -> str:  # type: ignore\n    # The type hint on context.invocation_metadata() is incorrect.\n    metadata = metadata_to_dict(context.invocation_metadata())  # type: ignore","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/runtimes/grpc/_worker_runtime_host_servicer.py#L1-L37","documentation":"_worker_runtime_host_servicer.py, the gRPC servicer backing GrpcWorkerAgentRuntimeHost, imports grpc under try/except and re-raises ImportError with GRPC_IMPORT_ERROR_STR when grpcio is absent. Because GrpcWorkerAgentRuntimeHost imports this servicer module at package load, any use of the host in an environment without the [grpc] extra fails at import time with 'Distributed runtime features require additional dependencies. Install them with: pip install autogen-core[grpc]'.","triggerScenarios":"Importing autogen_ext.runtimes.grpc (or instantiating GrpcWorkerAgentRuntimeHost / GrpcWorkerAgentRuntime) in a venv where autogen-ext was installed without the [grpc] extra and grpcio was never installed separately; fresh clones where only base requirements were installed; environments where a resolver dropped grpcio.","commonSituations":"Bare 'pip install autogen-ext' in tutorials/docs that assume the extra; slim production images pruning 'optional' packages; CI matrices that install minimal deps; conda/mix environments where grpcio exists for a different interpreter.","solutions":["Install the extra in the running environment: pip install 'autogen-core[grpc]' (and typically 'autogen-ext[grpc]')","Pin the extra in pyproject/requirements (autogen-ext[grpc]==X.Y.Z) so every environment gets grpcio","Confirm the right interpreter: python -m pip install 'autogen-core[grpc]' inside the venv that executes the app","If gRPC is unwanted, switch to autogen_core's SingleThreadedAgentRuntime and remove grpc imports"],"exampleFix":"# before\n$ pip install autogen-ext\n$ python -m my_worker  # ImportError: Distributed runtime features require...\n\n# after\n$ python -m pip install 'autogen-core[grpc]' 'autogen-ext[grpc]'\n$ python -m my_worker","handlingStrategy":"validation","validationCode":"import importlib.util\ngrpc_available = importlib.util.find_spec('grpc') is not None\nif not grpc_available:\n    raise SystemExit('Install dependencies: pip install \"autogen-core[grpc]\"')","typeGuard":"import importlib.util\ndef grpc_deps_installed() -> bool:\n    return importlib.util.find_spec('grpc') is not None","tryCatchPattern":"try:\n    from autogen_ext.runtimes.grpc._worker_runtime_host_servicer import GrpcWorkerAgentRuntimeHostServicer\nexcept ImportError as e:\n    if 'autogen-core[grpc]' in str(e):\n        raise SystemExit('Missing gRPC extra. Run: pip install \"autogen-core[grpc]\"') from e\n    raise","preventionTips":["Install via the [grpc] extra, not bare autogen-ext","Pin 'autogen-ext[grpc]' in pyproject/requirements","Verify with python -c 'import grpc' in the executing venv (CI and Docker)","Isolate project deps in a dedicated venv to avoid resolver drops"],"tags":["import","grpc","dependencies","installation"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}