langchain-opsen
Run LangChain deepagents on opsen — with machine, model and tool spend on one bill and a budget the runtime enforces mid-run.
pip install langchain-opsen
from deepagents import create_deep_agent
from langchain_anthropic import ChatAnthropic
from langchain_opsen import OpsenSandbox
agent = create_deep_agent(
model=ChatAnthropic(model="claude-sonnet-4-6"),
system_prompt="You are a Python coding assistant.",
backend=OpsenSandbox(task_id="nightly-report", budget_usd=2.00),
)
Set OPSEN_API_KEY, or pass api_key=. Get one here:
What this adds
Every sandbox backend bills you for the machine and leaves the model bill with a different vendor, on a different invoice, with no shared identifier. Two bills, reconciled by hand, and no answer to "what did that agent cost".
opsen sits in both paths, so:
agent_cost = backend.cost()
# {'total_usd': 0.41, 'compute_usd': 0.02, 'tokens_usd': 0.39,
# 'calls': 34, 'input_tokens': 84120, 'output_tokens': 9310,
# 'task_id': 'nightly-report'}
budget_usd is a ceiling the gateway enforces during the run. An
agent that would cross it is refused mid-flight rather than noticed
afterwards on an invoice.
Behaviour worth knowing
The session starts lazily. Constructing OpsenSandbox starts no
machine — the first command does. An agent built and never run costs
nothing.
File operations and the shell share one channel. Both go through the
same exec path, so the file tools and execute() always agree about the
working directory.
Ports depend on the runtime. host(port) works on E2B, works on
Modal when the port was declared at sandbox creation, and raises on the
local runtime with a message naming the limitation. A provider that hands
back a URL which does not answer turns "preview my server" into a
debugging session.
Configuration
| Argument | Default | Meaning |
|---|---|---|
api_key |
$OPSEN_API_KEY |
From opsen.dev/keys |
task_id |
"deepagents" |
Groups this agent's spend. One id, one line on the spend page. |
budget_usd |
none | Hard ceiling, enforced mid-run |
labels |
{} |
Arbitrary tags — customer, environment, whatever you group by |
base_url |
https://opsen.dev |
For self-hosted deployments |
timeout |
300 |
Default seconds per command |
Licence
Apache-2.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_opsen-0.1.4.tar.gz.
File metadata
- Download URL: langchain_opsen-0.1.4.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e26dd52e963504645168e47d4bc34e2bacbb48844d225c5287d92b6b4db2489c
|
|
| MD5 |
f6b196995e19c9c0da62b46ff783776e
|
|
| BLAKE2b-256 |
957a6ac9e9432baa28d5e03ae4d7ce33a26dfa6fb10989bb2059bd39c27a3b94
|
Provenance
The following attestation bundles were made for langchain_opsen-0.1.4.tar.gz:
Publisher:
release.yml on md322613/opsen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_opsen-0.1.4.tar.gz -
Subject digest:
e26dd52e963504645168e47d4bc34e2bacbb48844d225c5287d92b6b4db2489c - Sigstore transparency entry: 2754452047
- Sigstore integration time:
-
Permalink:
md322613/opsen@c1f831ea612c86822c0556481d2b1de7639855b0 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/md322613
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c1f831ea612c86822c0556481d2b1de7639855b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_opsen-0.1.4-py3-none-any.whl.
File metadata
- Download URL: langchain_opsen-0.1.4-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ac1ff872b7e7c89accad59fbb89d764c1eba2e193ad833884aba6e3a5bcdc7e
|
|
| MD5 |
8026f4c71894ee74ff6b9bd055b46eca
|
|
| BLAKE2b-256 |
d4bb12684513983a19843f249299fb2a81b0ca3519affe452fc26680f6649d47
|
Provenance
The following attestation bundles were made for langchain_opsen-0.1.4-py3-none-any.whl:
Publisher:
release.yml on md322613/opsen
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_opsen-0.1.4-py3-none-any.whl -
Subject digest:
6ac1ff872b7e7c89accad59fbb89d764c1eba2e193ad833884aba6e3a5bcdc7e - Sigstore transparency entry: 2754452049
- Sigstore integration time:
-
Permalink:
md322613/opsen@c1f831ea612c86822c0556481d2b1de7639855b0 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/md322613
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c1f831ea612c86822c0556481d2b1de7639855b0 -
Trigger Event:
push
-
Statement type: