LangChain Daytona

raw JSON →
0.0.5 verified Fri May 01 auth: no python

LangChain Daytona provides a Dayntona sandbox integration for secure code execution within LangChain agents. Version 0.0.5 requires Python >=3.11 and <4.0. Part of the deepagents monorepo, it is under active development.

pip install langchain-daytona
error ModuleNotFoundError: No module named 'langchain_daytona'
cause Package not installed or installed under a different name.
fix
Run pip install langchain-daytona (note the hyphen, not underscore).
error AttributeError: module 'langchain_daytona' has no attribute 'DaytonaSandboxTool'
cause The symbol may be in a submodule or the package version is too old.
fix
Ensure langchain-daytona>=0.0.5. Then import as from langchain_daytona import DaytonaSandboxTool. If still missing, check if the package exposes a different name.
error ValueError: DAYTONA_API_KEY environment variable not set
cause The required API key is missing.
fix
Set the DAYTONA_API_KEY environment variable before running your script, e.g., export DAYTONA_API_KEY='your_key'.
breaking Version 0.0.5 drops support for Python <3.11. Upgrade Python or pin to an older version.
fix Use Python 3.11 or later, or install langchain-daytona==0.0.4 if you need older Python.
gotcha The DaytonaSandboxTool requires a running Daytona sandbox instance. Without it, invocations will fail with a connection error.
fix Ensure DAYTONA_API_KEY environment variable is set and the sandbox ID is valid and active.
deprecated The old import path langchain_daytona.tools.DaytonaSandboxTool is deprecated and will be removed in a future release.
fix Use from langchain_daytona import DaytonaSandboxTool instead.

Initialize a Daytona sandbox tool with an API key and sandbox ID, then run code inside the sandbox.

import os
from langchain_daytona import DaytonaSandboxTool

tool = DaytonaSandboxTool(api_key=os.environ.get('DAYTONA_API_KEY', ''), sandbox_id="my-sandbox")
result = tool.invoke({"code": "print('hello from sandbox')"})
print(result)