This project has been archived by its maintainers, and is no longer receiving any updates.
langchain-disposable
Give your LangChain agent a code execution tool that runs in an isolated container — no network, read-only filesystem, 30-second timeout. Every run is disposable.
When to use it
Use this package if you already use LangChain and want:
- a LangChain tool for remote execution
- API-key-authenticated execution through Disposable Exec
- the standard Disposable Exec flow behind a LangChain-facing interface
If you just need the raw client, use disposable-exec.
Install
pip install langchain-disposable disposable-exec
For the agent example, also install the LangChain packages and model provider package you already use.
Environment variables
export DISPOSABLE_EXEC_BASE_URL="https://your-api-host"
export DISPOSABLE_EXEC_API_KEY="de_xxx"
Minimal tool example
import os
from langchain_disposable import DisposableExecTool
tool = DisposableExecTool(
api_key=os.environ["DISPOSABLE_EXEC_API_KEY"],
base_url=os.environ["DISPOSABLE_EXEC_BASE_URL"],
)
result = tool.invoke({"script": "print(2 + 2)"})
print(result)
Minimal agent example
import os
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
from langchain_disposable import DisposableExecTool
tool = DisposableExecTool(
api_key=os.environ["DISPOSABLE_EXEC_API_KEY"],
base_url=os.environ["DISPOSABLE_EXEC_BASE_URL"],
)
prompt = ChatPromptTemplate.from_messages(
[
("system", "Use the execution tool when Python is useful."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
]
)
agent = create_tool_calling_agent(ChatOpenAI(model="gpt-4o-mini"), [tool], prompt)
executor = AgentExecutor(agent=agent, tools=[tool], verbose=True)
print(executor.invoke({"input": "Use Python to compute the mean of [2, 4, 6, 8]."}))
What the agent gets back
The tool returns a JSON string with:
stdout— captured standard outputstderr— captured standard errorexit_code— process exit code (0 = success)failure_reason— structured reason if failed:timeout,exit_nonzero,sandbox_error,platform_error,orphanedduration— execution time in seconds
Your agent can use failure_reason to decide whether to retry, rewrite the code, or give up.
Relationship to Disposable Exec
langchain-disposable is a thin LangChain wrapper on top of disposable-exec. Disposable Exec provides the API key, /me, /run, /status, and /result flow. This package makes that flow easy to use from LangChain.
Metadata
Release files for langchain-disposable 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_disposable-0.1.1.tar.gz | 4.4 kB | Without provenance | Details for langchain_disposable-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_disposable-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for langchain_disposable-0.1.1-py3-none-any.whl |
Total release size: 9.1 kB
Release files / langchain_disposable-0.1.1.tar.gz
| Download URL | langchain_disposable-0.1.1.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8d2da08aad34056a1149b451a0ecd466dfba2fa75fd13e564b5528c1e06157e7
|
|
BLAKE2b-256 checksum How to use checksums |
ca4785bb80c2071f7d518dca467df46b6d264a2281329d899f5c67ba132d6fb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Release files / langchain_disposable-0.1.1-py3-none-any.whl
| Download URL | langchain_disposable-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d3e690026dfaef1e5f46c16c7a2d839bf8589c123b969b6e42693cb29f9124b
|
|
BLAKE2b-256 checksum How to use checksums |
8118b8e5d1be2f7362d4b7d222c92b5cff59c06c641e77fb4daf738d8f208f09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.0
|
Security for langchain-disposable 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.