Documentation Index
Fetch the complete documentation index at: https://langchain-zh.cn/llms.txt
Use this file to discover all available pages before exploring further.
Runloop 提供用于在隔离环境中运行代码的可销毁开发环境。有关注册、身份验证和平台详细信息,请参阅 Runloop 文档。
pip install langchain-runloop
创建沙箱后端
在 Python 中,您使用提供商 SDK 创建开发环境,然后将其封装在 deepagents 后端 中。
from runloop_api_client import RunloopSDK
from langchain_runloop import RunloopSandbox
api_key = "..."
client = RunloopSDK(bearer_token=api_key)
devbox = client.devbox.create()
backend = RunloopSandbox(devbox=devbox)
try:
result = backend.execute("echo hello")
print(result.output)
finally:
devbox.shutdown()
与 Deep Agents 配合使用
from runloop_api_client import RunloopSDK
from langchain_anthropic import ChatAnthropic
from deepagents import create_deep_agent
from langchain_runloop import RunloopSandbox
api_key = "..."
client = RunloopSDK(bearer_token=api_key)
devbox = client.devbox.create()
backend = RunloopSandbox(devbox=devbox)
agent = create_deep_agent(
model=ChatAnthropic(model="claude-sonnet-4-20250514"),
system_prompt="You are a coding assistant with sandbox access.",
backend=backend,
)
try:
result = agent.invoke(
{"messages": [{"role": "user", "content": "Create a small Python project and run tests"}]}
)
finally:
devbox.shutdown()
完成后请始终关闭开发环境,以避免持续的资源占用。
另见:沙箱。