{"record":{"id":"9ee44671bcf0ebab","repo":"BerriAI/litellm","slug":"codeinterpreterinterception-no-sandbox-available","errorCode":null,"errorMessage":"CodeInterpreterInterception: no sandbox available. Provide a sandbox_config or configure a sandbox tool resolvable via sandbox_tool_name.","messagePattern":"CodeInterpreterInterception: no sandbox available\\. Provide a sandbox_config or configure a sandbox tool resolvable via sandbox_tool_name\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/code_interpreter_interception/handler.py","lineNumber":740,"sourceCode":"                await self._evict_lru_session_if_over_cap(identity)\n            self._container_cache[cache_key] = (container, params, time.time(), identity)\n        return container, params\n\n    async def _evict_lru_session_if_over_cap(self, identity: str) -> None:\n        identity_entries: Final = [(k, v) for k, v in self._container_cache.items() if v[3] == identity]\n        if len(identity_entries) < _SESSION_SCOPED_PER_IDENTITY_CAP:\n            return\n        lru_key, lru_entry = min(identity_entries, key=lambda item: item[1][2])\n        self._container_cache.pop(lru_key, None)\n        await self._delete_container(container=lru_entry[0], params=lru_entry[1])\n\n    async def _create_container(self) -> tuple[ContainerHandle, SandboxToolParams | None]:\n        if self.sandbox_config is not None:\n            return await self.sandbox_config.acreate_sandbox(), None\n\n        params: Final = _resolve_sandbox_tool(self.sandbox_tool_name)\n        if params is None:\n            raise ValueError(\n                \"CodeInterpreterInterception: no sandbox available. Provide a \"\n                \"sandbox_config or configure a sandbox tool resolvable via \"\n                \"sandbox_tool_name.\"\n            )\n        container: Final = await litellm.acreate_sandbox(\n            provider=params[\"sandbox_provider\"],\n            api_key=params.get(\"api_key\"),\n            api_base=params.get(\"api_base\"),\n        )\n        return container, params\n\n    async def _run_code(\n        self, container: ContainerHandle, params: SandboxToolParams | None, code: str\n    ) -> CodeExecutionResult:\n        if self.sandbox_config is not None:\n            return await self.sandbox_config.arun_code(container=container, code=code)\n        if params is None:\n            raise ValueError(\"CodeInterpreterInterception: no sandbox available to run code.\")","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/code_interpreter_interception/handler.py#L722-L758","documentation":"CodeInterpreterInterception executes model-generated code in a sandbox. _create_container() first uses self.sandbox_config if given; otherwise it resolves a sandbox provider via _resolve_sandbox_tool(self.sandbox_tool_name), which returns None when sandbox_tool_name is None, when litellm.sandbox.sandbox_tools cannot be imported, or when resolve_sandbox_tool finds no registered tool with that name. With both paths empty it raises this ValueError so code never runs locally.","triggerScenarios":"Enabling code_interpreter_interception without sandbox_config and without sandbox_tool_name (both default to None); setting sandbox_tool_name to a name that has no registered sandbox tool (no matching provider config/credentials); sandbox support module unavailable in the installed litellm build.","commonSituations":"Turning on the code-interpreter interception callback in the proxy config but forgetting the sandbox block; passing sandbox_tool_name with a typo or before registering the tool; environments where optional sandbox dependencies are not installed.","solutions":["Pass sandbox_config to CodeInterpreterInterception(...) (a provider sandbox config object implementing acreate_sandbox/arun_code/adelete_sandbox)","Or set sandbox_tool_name to a registered sandbox tool name so _resolve_sandbox_tool succeeds, and provide that provider's credentials","Verify the config block actually reaches the logger: code_interpreter_interception_params with sandbox_tool_name under litellm_settings","Check the provider's API key env vars are set so the tool is resolvable at runtime"],"exampleFix":"# before\nCodeInterpreterInterceptionLogger()  # no sandbox_config, no sandbox_tool_name\n# ValueError: no sandbox available. Provide a sandbox_config or configure a sandbox tool...\n\n# after\nfrom litellm.integrations.code_interpreter_interception.handler import CodeInterpreterInterceptionLogger\nlogger = CodeInterpreterInterceptionLogger(\n    sandbox_config=MyProviderSandboxConfig(api_key=...),  # or sandbox_tool_name='my_daytona_tool'\n)","handlingStrategy":"validation","validationCode":"logger = CodeInterpreterInterceptionLogger(sandbox_tool_name=name)\nif logger.sandbox_config is None and _resolve_sandbox_tool(name) is None:\n    raise RuntimeError('configure sandbox_config or a registered sandbox_tool_name before enabling interception')","typeGuard":"def has_sandbox(logger) -> bool:\n    if logger.sandbox_config is not None:\n        return True\n    from litellm.integrations.code_interpreter_interception.handler import _resolve_sandbox_tool\n    return _resolve_sandbox_tool(logger.sandbox_tool_name) is not None","tryCatchPattern":"try:\n    container, params = await logger._create_container()\nexcept ValueError as e:\n    if 'no sandbox available' in str(e):\n        # fail with config guidance instead of retrying\n        raise RuntimeError('code interception needs sandbox_config or sandbox_tool_name') from e\n    raise","preventionTips":["Always pass either sandbox_config or sandbox_tool_name when enabling code_interpreter_interception","Set provider credentials in env so the sandbox tool resolves at runtime","Smoke-test sandbox creation at startup, not on the first user request"],"tags":["sandbox","code-interpreter","configuration","litellm","guardrail"],"backgroundTag":"missing-required-config","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}