Skip to main content

langchain-briq

PyPI CI

briq sandbox integration for Deep Agents. A Deep Agent runs its commands and file tools in a briq sandbox.

from deepagents import create_deep_agent
from langchain_briq import BriqSandbox

backend = BriqSandbox.create(size="medium")  # reads BRIQ_API_KEY
try:
    agent = create_deep_agent(model="anthropic:claude-sonnet-4-5", backend=backend)
    result = agent.invoke(
        {"messages": [{"role": "user", "content": "Write fizzbuzz in Python and run it."}]}
    )
    print(result["messages"][-1].content)
finally:
    backend.destroy()  # removes the sandbox and its disk

Install: pip install langchain-briq. Python 3.11 or later. It depends on deepagents and briq-cloud. Get an API key on the briq dashboard and set BRIQ_API_KEY.

What it does

BriqSandbox is a BaseSandbox: it implements execute, upload_files, download_files and id, and the rest of the Deep Agents filesystem tools (read, write, edit, ls, glob, grep) come from BaseSandbox. They run python3 in the sandbox, which the default image has.

Method Does
BriqSandbox.create(...) Makes a sandbox and waits until it runs.
BriqSandbox.connect(id) Reconnects to a sandbox. A sleeping one wakes on the next call.
backend.execute(command, timeout=) Runs a shell command. Returns the output and the exit code.
backend.upload_files([(path, bytes)]) Writes files, creates the directories above them.
backend.download_files([path]) Reads files.
backend.id The sandbox id.
backend.destroy() Removes the sandbox and its disk.
backend.sandbox The underlying briq_cloud.Sandbox, for previews, stop, start.

async methods (aexecute, aupload_files, adownload_files) run the same calls in a thread.

Create options

BriqSandbox.create(
    size="large",  # small, medium, large or xlarge
    image="ghcr.io/acme/tools:1",  # an OCI image with a shell and python3
    env={"MODE": "test"},  # shows in the sandbox's status
    secret_env={"API_TOKEN": token},  # write-only
    sleep="3h",  # idle time before it sleeps; "never" stays awake
    default_timeout=600,  # seconds a command may run without its own timeout
)
  • Any other size raises BriqError with code unsupported before a request is sent.
  • secret_env raises unsupported when the API cannot keep the values write-only.
  • Pass client= a briq_cloud.Briq to share one client. You close it. Without it, api_key and base_url default to BRIQ_API_KEY and BRIQ_API_URL.
  • with BriqSandbox.create() as backend: destroys the sandbox when the block ends.

Reconnect

backend = BriqSandbox.create(sleep="3h")
sandbox_id = backend.id
backend.close()  # closes the client, the sandbox keeps running

backend = BriqSandbox.connect(sandbox_id)

Behavior

  • execute returns stdout, then stderr inside <stderr> tags. A command that outlives its timeout is stopped and ends with exit code 124. The timeout is 1 second to 24 hours; the default is 30 minutes.
  • A command over about 6 KB is written to a file in the sandbox and run from there. The API takes 8 KB of command per call.
  • upload_files and download_files return one response per path, in order. Error codes: invalid_path (a relative path), file_not_found, permission_denied, is_directory. A file over 100 MiB raises BriqError with code quota.
  • Errors the model cannot fix (a wrong key, no credits, a plan limit, a sandbox that no longer exists) raise briq_cloud.BriqError. Its code is stable; see the client's README.

Not supported

  • Streaming output: execute returns when the command ends.
  • A working directory or environment per command. Put them in the command: cd /work && make.
  • Output truncation: truncated is always False. A command's output over 32 MiB raises BriqError with code quota.

Develop

Needs uv.

git clone https://github.com/briq-cloud/langchain-briq && cd langchain-briq
uv sync --group test
uv run pytest                     # offline
uv run ruff check . && uv run ruff format --check .
uv run mypy

The tests run offline: tests/unit_tests/test_sandbox.py drives BriqSandbox through the real briq-cloud client against an in-memory API. tests/unit_tests/test_standard_offline.py runs the standard SandboxIntegrationTests suite of langchain-tests against a local Docker container (skipped without Docker).

Seven tests of that suite expect behavior that BaseSandbox itself no longer has (glob returns absolute paths, write overwrites): they are marked xfail in tests/conftest.py.

Against a real briq sandbox, with a key:

BRIQ_API_KEY=... uv run pytest tests/integration_tests

It makes one small sandbox for the run and destroys it.

License

MIT

Metadata

Release files for langchain-briq 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-briq 0.2.0
File Size Uploaded Provenance Actions
langchain_briq-0.2.0.tar.gz 7.3 kB With provenance Details for langchain_briq-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-briq 0.2.0
File Interpreter ABI Platform Actions
langchain_briq-0.2.0-py3-none-any.whl Python 3 none any Details for langchain_briq-0.2.0-py3-none-any.whl

Total release size: 15.7 kB

Release files / langchain_briq-0.2.0.tar.gz

Download URL langchain_briq-0.2.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2deda3317217abab2bbb3ddca922332c9dfa1cff227c50ae1e853c647d1e0138
BLAKE2b-256 checksum
How to use checksums
f28c775be8a6c1df9001437d245224ef575151d3b1cd34933f61ff94ca075be0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Release files / langchain_briq-0.2.0-py3-none-any.whl

Download URL langchain_briq-0.2.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1a982b4dd92d40b3827c5281ce094e884b206308c7c33459620be6b8056d091
BLAKE2b-256 checksum
How to use checksums
fa0c08c6c23842c91d836bbe461a6041c337bd4e461924c1fb4deb751634bab4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

Security for langchain-briq 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_briq-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 15, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page