Skip to main content

A toolkit for building LangChain applications

Project description

gatana-langchain

Current version: v1.0.1

PyPI Python License: MIT

A LangChain sandbox backend for Gatana. Use Gatana sandboxes as isolated execution environments for LangChain deep agents.

Features

  • Drop-in sandbox backend for LangChain's deepagents framework
  • Isolated command execution, file upload/download, and full filesystem tool support
  • Auto-creates and cleans up sandboxes via context manager
  • Fully typed with PEP 561 support
  • Python 3.11+

Installation

pip install gatana-langchain

Or with uv:

uv add gatana-langchain

Basic usage

Create a Gatana sandbox and pass it as the backend to a deep agent. The agent gets filesystem tools (ls, read_file, write_file, edit_file, glob, grep) and an execute tool for running shell commands — all inside the sandbox.

from gatana_client import AuthenticatedClient
from langchain_anthropic import ChatAnthropic

from deepagents import create_deep_agent
from gatana_langchain import GatanaSandbox

client = AuthenticatedClient(
    base_url="https://api.gatana.ai",
    token="your-gatana-api-key",
)

with GatanaSandbox(client=client) as backend:
    agent = create_deep_agent(
        model=ChatAnthropic(model="claude-sonnet-4-20250514"),
        system_prompt="You are a coding assistant with sandbox access.",
        backend=backend,
    )

    result = agent.invoke(
        {
            "messages": [
                {
                    "role": "user",
                    "content": "Create a Python script that prints the Fibonacci sequence and run it",
                }
            ]
        }
    )
    print(result["messages"][-1].content)
# Sandbox is automatically deleted when the `with` block exits.

Wrapping an existing sandbox

If you already have a sandbox ID (e.g. from a previous session), pass it directly. The sandbox will not be auto-deleted on exit:

backend = GatanaSandbox(client=client, sandbox_id="existing-sandbox-id")
result = backend.execute("echo hello from existing sandbox")
print(result.output)

Running commands directly

You can call execute() without creating an agent:

with GatanaSandbox(client=client) as backend:
    result = backend.execute("python --version")
    print(result.output)   # e.g. "Python 3.12.0\n"
    print(result.exit_code)  # 0

Uploading and downloading files

Seed the sandbox with files before the agent runs, or retrieve artifacts afterwards:

with GatanaSandbox(client=client) as backend:
    # Upload files into the sandbox
    backend.upload_files([
        ("/src/main.py", b"print('Hello')\n"),
        ("/pyproject.toml", b"[project]\nname = 'my-app'\n"),
    ])

    # Run the agent or execute commands...
    backend.execute("cd /src && python main.py")

    # Download artifacts from the sandbox
    results = backend.download_files(["/src/main.py"])
    for r in results:
        if r.content is not None:
            print(f"{r.path}: {r.content.decode()}")
        else:
            print(f"Failed to download {r.path}: {r.error}")

Development

This package is part of the gatana-python monorepo. See the root CONTRIBUTING.md for setup instructions.

License

MIT — Copyright (c) 2026 Gatana

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

gatana_langchain-1.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

gatana_langchain-1.0.1-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file gatana_langchain-1.0.1.tar.gz.

File metadata

  • Download URL: gatana_langchain-1.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gatana_langchain-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b156e22aa8ea779a0a601b2fdd790198736067235ee847fa3d6109519bd033f4
MD5 cf73d732e8224570ebb91004944fe811
BLAKE2b-256 5998de492f898d28aad5d7a20a6227e28b2b446470ed57eefe41a48582427598

See more details on using hashes here.

File details

Details for the file gatana_langchain-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: gatana_langchain-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.5 {"installer":{"name":"uv","version":"0.10.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gatana_langchain-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 590f08344ac1259bd144ba53e10518d0d3cb5fb78ec011a7a1ed05fb73fc7d82
MD5 3536de603aa7c6203669e0173de14e70
BLAKE2b-256 e9d1c3ce94789f4ef065cab28be19bc60b9ff7ae6264e49386f6555eefb61dfb

See more details on using hashes here.

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