{"record":{"id":"5c21e784f4cc1087","repo":"crewAIInc/crewAI","slug":"could-not-import-daytona-coderunparams-while-build","errorCode":null,"errorMessage":"Could not import daytona.CodeRunParams while building argv/env for sandbox.process.code_run. This usually means the installed 'daytona' SDK is too old or incompatible. Upgrade with: pip install -U 'crewai-tools[daytona]'","messagePattern":"Could not import daytona\\.CodeRunParams while building argv/env for sandbox\\.process\\.code_run\\. This usually means the installed 'daytona' SDK is too old or incompatible\\. Upgrade with: pip install -U 'crewai-tools\\[daytona\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"lib/crewai-tools/src/crewai_tools/tools/daytona_sandbox_tool/daytona_python_tool.py","lineNumber":71,"sourceCode":"            return {\n                \"exit_code\": getattr(response, \"exit_code\", None),\n                \"result\": getattr(response, \"result\", None),\n                \"artifacts\": getattr(response, \"artifacts\", None),\n            }\n        finally:\n            self._release_sandbox(sandbox, should_delete)\n\n    def _build_code_run_params(\n        self,\n        argv: list[str] | None,\n        env: dict[str, str] | None,\n    ) -> Any | None:\n        if argv is None and env is None:\n            return None\n        try:\n            from daytona import CodeRunParams\n        except ImportError as exc:\n            raise ImportError(\n                \"Could not import daytona.CodeRunParams while building \"\n                \"argv/env for sandbox.process.code_run. This usually means the \"\n                \"installed 'daytona' SDK is too old or incompatible. Upgrade \"\n                \"with: pip install -U 'crewai-tools[daytona]'\"\n            ) from exc\n        kwargs: dict[str, Any] = {}\n        if argv is not None:\n            kwargs[\"argv\"] = argv\n        if env is not None:\n            kwargs[\"env\"] = env\n        return CodeRunParams(**kwargs)\n","sourceCodeStart":53,"sourceCodeEnd":83,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-tools/src/crewai_tools/tools/daytona_sandbox_tool/daytona_python_tool.py#L53-L83","documentation":"DaytonaCodeExecutionTool._build_code_run_params imports daytona.CodeRunParams from the Daytona SDK only when the caller supplies argv or env. If that import fails, the tool raises ImportError with an explicit remediation message, chaining the original ImportError. It means the installed daytona package predates CodeRunParams (or is broken), so per-call argv/env cannot be forwarded to sandbox.process.code_run.","triggerScenarios":"Instantiating/calling the python execution tool with argv=['python','-u'] or env={'FOO':'1'} while an old daytona SDK (< the version introducing CodeRunParams) is installed; a partially installed/corrupted daytona package where the symbol is missing.","commonSituations":"Pinning daytona to an old version in requirements; environments where crewai-tools was installed without the [daytona] extra pulling a current SDK; using argv/env features against an SDK that never had them.","solutions":["Upgrade the SDK: pip install -U 'crewai-tools[daytona]' (or uv add 'crewai-tools[daytona]').","If you must not upgrade, drop the argv/env arguments — plain code execution works without CodeRunParams.","Verify with python -c \"from daytona import CodeRunParams\" that the symbol now resolves.","Check pip show daytona for the installed version against the SDK changelog if problems persist."],"exampleFix":"# before: old SDK + argv/env\nuv pip install 'daytona==0.5.0'\ntool._run(code='print(1)', argv=['python', '-u'])\n\n# after\nuv pip install -U 'crewai-tools[daytona]'\ntool._run(code='print(1)', argv=['python', '-u'])","handlingStrategy":"validation","validationCode":"import importlib.util\n\ndef daytona_supports_code_run_params() -> bool:\n    return importlib.util.find_spec('daytona') is not None and _has_symbol()\n\ndef _has_symbol() -> bool:\n    try:\n        import daytona  # noqa: F401\n        from daytona import CodeRunParams  # noqa: F401\n        return True\n    except ImportError:\n        return False\n\n# gate the feature\nif argv or env:\n    assert daytona_supports_code_run_params(), 'upgrade: pip install -U \"crewai-tools[daytona]\"'","typeGuard":null,"tryCatchPattern":"try:\n    tool._run(code=src, argv=argv, env=env)\nexcept ImportError as e:\n    if 'CodeRunParams' in str(e):\n        result = tool._run(code=src)  # degrade: no argv/env forwarding\n    else:\n        raise","preventionTips":["Pin a modern daytona SDK in requirements alongside crewai-tools[daytona].","Run a startup dependency check (importlib.util.find_spec) and fail fast with a clear message.","Avoid argv/env unless you need them — plain code execution skips the import entirely."],"tags":["daytona","importerror","sdk-version","dependency","python-tool"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}