Skip to main content

inis.run sandbox backend for LangChain Deep Agents, plus a LangGraph recipe

Project description

langchain-inis

Native inis.run sandbox backend for LangChain Deep Agents (deepagents.backends.sandbox.BaseSandbox), plus a lower-level LangGraph recipe for teams not using Deep Agents.

PyPI License: MIT Python

Beta. Verified against deepagents==0.7.1 — pin langchain-inis and re-check before assuming it tracks a later deepagents major without changes.

Install

pip install langchain-inis deepagents

Quickstart: native Deep Agents backend

from inis import Client
from deepagents import create_deep_agent
from langchain_inis import InisSandboxBackend

backend = InisSandboxBackend.create()  # owned: this app destroys it
try:
    agent = create_deep_agent(model="anthropic:claude-sonnet-5", backend=backend)
    result = agent.invoke({"messages": [{"role": "user", "content": "List /workspace, then write hello.txt"}]})
    print(result["messages"][-1].content)
finally:
    backend.destroy()

No custom lifecycle tools in the model prompt — passing backend=backend is the whole integration. Deep Agents auto-registers ls/read_file/write_file/edit_file/glob/grep and execute against it, all bounded.

Owned vs. attached

  • InisSandboxBackend.create(...) — a brand-new session this app owns and must backend.destroy() when done; SandboxBackendProtocol has no lifecycle hooks of its own.
  • InisSandboxBackend.attach(session_id, ...) — binds to a session this app does not own. Never destroys it; call backend.close() when done, which only releases this backend's local HTTP transport.
backend = InisSandboxBackend.attach(existing_session_id)
try:
    agent = create_deep_agent(model=..., backend=backend)
    ...
finally:
    backend.close()  # local transport only — the session is not this app's to destroy

One agent thread/conversation should map to one session — resolve session_id per thread using whatever key your app already tracks conversations by. See examples/langgraph_recipe.py's ThreadSessionStore for a worked example.

What it does

  • execute/aexecute (shell)
  • upload_files/download_files (+ async) — base64 for binary
  • Every derived file op (ls/read/write/edit/grep/glob/delete) — BaseSandbox's own defaults, unmodified
  • Owned/attached lifetime split — see above
  • Structured error mapping — InisError.code mapped onto FileOperationError literals where it matches

enable_capture_offload is False, forced — see below, this is the most important thing to read here.

Notes

True remote cancellation of an in-flight execute() is not implemented: BaseSandbox.execute(command, timeout=...) is timeout-only, with no abort hook. A timeout still ends the call. Streaming output is not implemented either — ExecuteResponse has no streaming shape.

Large execute() output is not capped on this backend

deepagents' automatic eviction of oversized tool results (/large_tool_results) requires writing to a directory hardcoded off the filesystem root — which fails Permission denied on inis.run's non-root, /workspace-confined session, and deepagents silently keeps the full-size message rather than raising. enable_capture_offload=False reflects that this eviction path is a no-op here, not a preference.

The practical ceiling is instead inis.run's own guest-side capture cap (up to 4 MiB per stream), well past what Deep Agents' ~80 KB budget assumes. Nothing is silently dropped — the risk is an unexpectedly large chunk of context from one verbose command. Bound noisy commands yourself (head -c/tail -c, or write to a file and read_file back a slice) until deepagents supports a configurable offload root for a plain BaseSandbox.

ExecuteResponse.truncated is set directly from inis.run's own per-stream truncation signal, so a caller reading it gets an honest answer.

LangGraph recipe (lower-level, secondary path)

examples/langgraph_recipe.py is a complete, runnable example using plain LangGraph primitives (@tool, ToolNode, StateGraph) for teams not using Deep Agents. One session per graph thread ID, a bounded tool surface, and a small file-backed ThreadSessionStore demonstrating a session ID surviving a process restart.

python examples/langgraph_recipe.py           # creates (or reattaches to) demo-thread-1
python examples/langgraph_recipe.py --end      # ... and cleans it up

Development

pip install -e ".[dev]"
pip install -e ../python   # inis core SDK, editable
pytest

Tests subclass the upstream SandboxIntegrationTests conformance suite (langchain-tests) against a fake local-subprocess inis.run HTTP backend — the network transport is faked, execute()/file ops run for real. Run on Linux (or Linux CI); several conformance tests assume GNU grep semantics that a default macOS shell doesn't have.

Links

Built and run in the EU. Your code and data never leave Europe.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_inis-0.1.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_inis-0.1.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_inis-0.1.0.tar.gz.

File metadata

  • Download URL: langchain_inis-0.1.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for langchain_inis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 af6e6b0a0135f0fc1897b6301b1f20d789e887687213133d3b50c03e43dea2b6
MD5 51789fafa2ebcbc2bb884ed56e47efbd
BLAKE2b-256 7d1a4708933e7df757cd726e9909777d451b065c22f01414e72f3b78384ab507

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_inis-0.1.0.tar.gz:

Publisher: sdk-langchain-inis-publish.yml on 4ver/inis.run

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_inis-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: langchain_inis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for langchain_inis-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ba5e2b5155bd6ee5f0991f900a95d1c8d87186ad0ad707bd91fe7881a47bac1
MD5 272335ee4a0fbddf132bc91bb2bb92a4
BLAKE2b-256 437e2cd435c271a9ee148673a8aef8f6eb5a9a17fb157158b8116a8638bb7f44

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_inis-0.1.0-py3-none-any.whl:

Publisher: sdk-langchain-inis-publish.yml on 4ver/inis.run

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page