{"record":{"id":"fde37c17e6054d63","repo":"microsoft/autogen","slug":"failed-to-get-list-of-available-packages-ret-out","errorCode":null,"errorMessage":"Failed to get list of available packages: {ret.output.strip()}","messagePattern":"Failed to get list of available packages: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py","lineNumber":225,"sourceCode":"\n    def _construct_url(self, path: str) -> str:\n        endpoint = self._pool_management_endpoint\n        if not endpoint.endswith(\"/\"):\n            endpoint += \"/\"\n        url = endpoint + f\"{path}?api-version={self._AZURE_API_VER}&identifier={self._session_id}\"\n        return url\n\n    async def get_available_packages(self, cancellation_token: CancellationToken) -> set[str]:\n        if self._available_packages is not None:\n            return self._available_packages\n        avail_pkgs = \"\"\"\nimport pkg_resources\\n[d.project_name for d in pkg_resources.working_set]\n\"\"\"\n        ret = await self._execute_code_dont_check_setup(\n            [CodeBlock(code=avail_pkgs, language=\"python\")], cancellation_token\n        )\n        if ret.exit_code != 0:\n            raise ValueError(f\"Failed to get list of available packages: {ret.output.strip()}\")\n        pkgs = ret.output.strip(\"[]\")\n        pkglist = pkgs.split(\",\\n\")\n        return {pkg.strip(\" '\") for pkg in pkglist}\n\n    async def _populate_available_packages(self, cancellation_token: CancellationToken) -> None:\n        self._available_packages = await self.get_available_packages(cancellation_token)\n\n    async def _setup_functions(self, cancellation_token: CancellationToken) -> None:\n        if not self._func_code:\n            self._func_code = build_python_functions_file(self._functions)\n\n            # Check required function imports and packages\n            lists_of_packages = [x.python_packages for x in self._functions if isinstance(x, FunctionWithRequirements)]\n            # Should we also be checking the imports?\n\n            flattened_packages = [item for sublist in lists_of_packages for item in sublist]\n            required_packages = set(flattened_packages)\n","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/code_executors/azure/_azure_container_code_executor.py#L207-L243","documentation":"AzureContainerCodeExecutor.get_available_packages() runs `import pkg_resources; [d.project_name for d in pkg_resources.working_set]` inside the ACA container to enumerate installed packages; if that probe exits non-zero, the captured stdout/stderr is wrapped in ValueError. The executor container is therefore up but the Python probe failed — commonly pkg_resources (setuptools) missing in the image, an OOM/killed probe, or the container image lacking the expected Python environment.","triggerScenarios":"The first function-execution call triggers _populate_available_packages -> get_available_packages; the in-container python process exits non-zero, e.g. ModuleNotFoundError: No module named 'pkg_resources' on images without setuptools, or a container that crashed mid-probe.","commonSituations":"Custom container images based on slim/python:3.12+ where setuptools is absent, images where the default ENTRYPOINT interferes, resource limits killing the job, or a stale pool whose image was rebuilt without build tools.","solutions":["Ensure setuptools is installed in the execution container image (RUN pip install setuptools)","Use the default autogen-created container image, which includes pkg_resources","Inspect ret.output in the exception to see the in-container traceback and fix the image accordingly","Recreate the container pool if the image was updated but the pool still runs the old one"],"exampleFix":"# before (Dockerfile for custom execution image)\nFROM python:3.12-slim\nRUN pip install numpy pandas\n# probe fails: no pkg_resources\n\n# after\nFROM python:3.12-slim\nRUN pip install setuptools numpy pandas","handlingStrategy":"try-catch","validationCode":"# no in-container probe can be run from the caller; validate the image instead at build time\n# docker run --rm my-exec-image python -c \"import pkg_resources; print('ok')\"","typeGuard":null,"tryCatchPattern":"try:\n    await executor.execute_code(blocks, token)\nexcept ValueError as e:\n    if 'Failed to get list of available packages' in str(e):\n        raise RuntimeError('execution image lacks setuptools/pkg_resources; rebuild image') from e\n    raise","preventionTips":["Include setuptools in any custom execution container image","Add a CI step that runs the pkg_resources probe inside the image","Recreate the container pool whenever the image changes"],"tags":["azure","code-executor","container","dependency","environment"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}