[PR #190] [MERGED] feat: add modal sandbox #193

Closed
opened 2026-02-16 06:17:24 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/deepagentsjs/pull/190
Author: @hntrl
Created: 2/4/2026
Status: Merged
Merged: 2/5/2026
Merged by: @christian-bromann

Base: cb/daytonaHead: hunter/modal


📝 Commits (2)

📊 Changes

18 files changed (+3854 additions, -0 deletions)

View changed files

.changeset/modal-sandbox.md (+15 -0)
.pr-description.md (+51 -0)
📝 examples/package.json (+1 -0)
examples/sandbox/modal-sandbox.ts (+133 -0)
libs/providers/modal/.npmignore (+23 -0)
libs/providers/modal/README.md (+344 -0)
libs/providers/modal/package.json (+71 -0)
libs/providers/modal/src/auth.test.ts (+178 -0)
libs/providers/modal/src/auth.ts (+90 -0)
libs/providers/modal/src/index.ts (+51 -0)
libs/providers/modal/src/sandbox.int.test.ts (+641 -0)
libs/providers/modal/src/sandbox.test.ts (+836 -0)
libs/providers/modal/src/sandbox.ts (+726 -0)
libs/providers/modal/src/types.ts (+252 -0)
libs/providers/modal/tsconfig.json (+8 -0)
libs/providers/modal/tsdown.config.ts (+27 -0)
libs/providers/modal/vitest.config.ts (+40 -0)
📝 pnpm-lock.yaml (+367 -0)

📄 Description

Adds @langchain/modal package - a Modal sandbox provider for deepagents

Changes

New Package: libs/providers/modal/

  • sandbox.ts - ModalSandbox class implementing SandboxBackendProtocol

    • Command execution via Modal SDK's exec()
    • File upload/download using Modal's file handle API
    • initialFiles support for pre-populating sandbox files
    • .client and .instance getters for direct SDK access
  • types.ts - Type definitions extending Modal SDK's SandboxCreateParams

    • Pass-through SDK options (timeoutMs, memoryMiB, gpu, cpu, etc.)
    • Wrapped options for volumes/secrets (accept names instead of objects)
    • Custom additions: appName, imageName, initialFiles, auth
  • auth.ts - Authentication utilities

    • getAuthCredentials() resolves token from options or environment variables
    • Comprehensive error messages for missing credentials
  • Tests

    • Unit tests with mocked Modal SDK (sandbox.test.ts, auth.test.ts)
    • Integration tests against real Modal infrastructure (sandbox.int.test.ts)

New Example: examples/sandbox/modal-sandbox.ts

Demonstrates using ModalSandbox with createDeepAgent to run Python code in an isolated container.


Usage

import { ModalSandbox } from "@langchain/modal";
import { createDeepAgent } from "deepagents";

const sandbox = await ModalSandbox.create({
  imageName: "python:3.12-slim",
  timeoutMs: 600_000,
  initialFiles: {
    "main.py": "print('Hello from Modal!')",
  },
});

const agent = createDeepAgent({
  model: yourModel,
  backend: sandbox,
});

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/deepagentsjs/pull/190 **Author:** [@hntrl](https://github.com/hntrl) **Created:** 2/4/2026 **Status:** ✅ Merged **Merged:** 2/5/2026 **Merged by:** [@christian-bromann](https://github.com/christian-bromann) **Base:** `cb/daytona` ← **Head:** `hunter/modal` --- ### 📝 Commits (2) - [`886456d`](https://github.com/langchain-ai/deepagentsjs/commit/886456d82eb5557e4f40397f595edc99d5101b85) feat: add modal sandbox - [`7fe8cc7`](https://github.com/langchain-ai/deepagentsjs/commit/7fe8cc792090930f283550fa425a641afd0f6061) chore: format ### 📊 Changes **18 files changed** (+3854 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `.changeset/modal-sandbox.md` (+15 -0) ➕ `.pr-description.md` (+51 -0) 📝 `examples/package.json` (+1 -0) ➕ `examples/sandbox/modal-sandbox.ts` (+133 -0) ➕ `libs/providers/modal/.npmignore` (+23 -0) ➕ `libs/providers/modal/README.md` (+344 -0) ➕ `libs/providers/modal/package.json` (+71 -0) ➕ `libs/providers/modal/src/auth.test.ts` (+178 -0) ➕ `libs/providers/modal/src/auth.ts` (+90 -0) ➕ `libs/providers/modal/src/index.ts` (+51 -0) ➕ `libs/providers/modal/src/sandbox.int.test.ts` (+641 -0) ➕ `libs/providers/modal/src/sandbox.test.ts` (+836 -0) ➕ `libs/providers/modal/src/sandbox.ts` (+726 -0) ➕ `libs/providers/modal/src/types.ts` (+252 -0) ➕ `libs/providers/modal/tsconfig.json` (+8 -0) ➕ `libs/providers/modal/tsdown.config.ts` (+27 -0) ➕ `libs/providers/modal/vitest.config.ts` (+40 -0) 📝 `pnpm-lock.yaml` (+367 -0) </details> ### 📄 Description Adds `@langchain/modal` package - a Modal sandbox provider for deepagents ## Changes ### New Package: `libs/providers/modal/` - **`sandbox.ts`** - `ModalSandbox` class implementing `SandboxBackendProtocol` - Command execution via Modal SDK's `exec()` - File upload/download using Modal's file handle API - `initialFiles` support for pre-populating sandbox files - `.client` and `.instance` getters for direct SDK access - **`types.ts`** - Type definitions extending Modal SDK's `SandboxCreateParams` - Pass-through SDK options (timeoutMs, memoryMiB, gpu, cpu, etc.) - Wrapped options for volumes/secrets (accept names instead of objects) - Custom additions: `appName`, `imageName`, `initialFiles`, `auth` - **`auth.ts`** - Authentication utilities - `getAuthCredentials()` resolves token from options or environment variables - Comprehensive error messages for missing credentials - **Tests** - Unit tests with mocked Modal SDK (`sandbox.test.ts`, `auth.test.ts`) - Integration tests against real Modal infrastructure (`sandbox.int.test.ts`) ### New Example: `examples/sandbox/modal-sandbox.ts` Demonstrates using `ModalSandbox` with `createDeepAgent` to run Python code in an isolated container. --- ## Usage ```typescript import { ModalSandbox } from "@langchain/modal"; import { createDeepAgent } from "deepagents"; const sandbox = await ModalSandbox.create({ imageName: "python:3.12-slim", timeoutMs: 600_000, initialFiles: { "main.py": "print('Hello from Modal!')", }, }); const agent = createDeepAgent({ model: yourModel, backend: sandbox, }); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 06:17:24 -05:00
yindo closed this issue 2026-02-16 06:17:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#193