Skip to content

Commit b5d2233

Browse files
Add LangChain DeepAgents example and documentation
Example application demonstrating the LangChain backend with sandbox templates, skills definitions, and a kind cluster test script. Includes README for the langchain-agent-sandbox package with usage examples for direct sandbox, template-based, and warm pool modes. Signed-off-by: Johann-Peter Hartmann <johann-peter.hartmann@mayflower.de>
1 parent a43d891 commit b5d2233

File tree

10 files changed

+1346
-1
lines changed

10 files changed

+1346
-1
lines changed

clients/python/langchain-agent-sandbox/README.md

Lines changed: 462 additions & 0 deletions
Large diffs are not rendered by default.

examples/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ This directory contains examples of how to use the Agent Sandbox. Each subdirect
1515
- [**policy**](./policy): Examples of using different policies with sandboxes.
1616
- [**python-runtime-sandbox**](./python-runtime-sandbox): An example of a Python runtime sandbox.
1717
- [**sandbox-ksa**](./sandbox-ksa): Examples of a sandbox with a service account, namespace, and a basic sandbox.
18-
- [**vscode-sandbox**](./vscode-sandbox): An example of running VSCode in a sandbox.
18+
- [**vscode-sandbox**](./vscode-sandbox): An example of running VSCode in a sandbox.
19+
- [**langchain-deepagents**](./langchain-deepagents): LangChain DeepAgents with agent-sandbox backend for secure code execution.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: data-analysis
3+
description: "Analyze data files and generate insights. Trigger on phrases like 'analyze this data', 'show statistics', 'summarize the CSV'."
4+
version: 1.0.0
5+
tags: [data, analysis, statistics]
6+
---
7+
# Data Analysis
8+
9+
## Overview
10+
This skill helps analyze data files (CSV, JSON, text) and generate statistical summaries.
11+
12+
## Prerequisites
13+
The sandbox should have Python with pandas available, or use basic Python for simple analysis.
14+
15+
## Workflow
16+
1. Read the data file to understand its structure
17+
2. Write an analysis script
18+
3. Execute and capture results
19+
4. Present findings in a clear format
20+
21+
## Analysis Templates
22+
23+
### CSV Summary
24+
```python
25+
import csv
26+
with open('/app/data.csv') as f:
27+
reader = csv.DictReader(f)
28+
rows = list(reader)
29+
print(f"Rows: {len(rows)}")
30+
print(f"Columns: {reader.fieldnames}")
31+
```
32+
33+
### JSON Exploration
34+
```python
35+
import json
36+
with open('/app/data.json') as f:
37+
data = json.load(f)
38+
print(f"Type: {type(data)}")
39+
if isinstance(data, list):
40+
print(f"Items: {len(data)}")
41+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: file-organizer
3+
description: "Organize files by type, date, or custom criteria. Trigger on phrases like 'organize files', 'sort by type', 'clean up directory'."
4+
version: 1.0.0
5+
tags: [files, organization, cleanup]
6+
---
7+
# File Organizer
8+
9+
## Overview
10+
This skill helps organize files in the sandbox by moving them to appropriate directories based on type, name patterns, or custom criteria.
11+
12+
## Workflow
13+
1. List files in the target directory with `ls_info`
14+
2. Categorize files based on extension or pattern
15+
3. Create destination directories
16+
4. Move files using shell commands
17+
18+
## Organization Strategies
19+
20+
### By Extension
21+
```python
22+
import os
23+
import shutil
24+
25+
extensions = {
26+
'.py': 'python',
27+
'.js': 'javascript',
28+
'.md': 'docs',
29+
'.json': 'data',
30+
'.csv': 'data',
31+
}
32+
33+
for filename in os.listdir('/app'):
34+
ext = os.path.splitext(filename)[1]
35+
if ext in extensions:
36+
dest = f'/app/{extensions[ext]}'
37+
os.makedirs(dest, exist_ok=True)
38+
shutil.move(f'/app/{filename}', f'{dest}/{filename}')
39+
```
40+
41+
### By Date (modification time)
42+
```python
43+
import os
44+
from datetime import datetime
45+
46+
for filename in os.listdir('/app'):
47+
path = f'/app/{filename}'
48+
mtime = os.path.getmtime(path)
49+
date_str = datetime.fromtimestamp(mtime).strftime('%Y-%m')
50+
# organize by year-month
51+
```
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: python-script
3+
description: "Generate and run Python scripts. Trigger on phrases like 'write a script', 'create a Python program', 'run Python code'."
4+
version: 1.0.0
5+
tags: [python, scripting, automation]
6+
---
7+
# Python Script Generation
8+
9+
## Overview
10+
This skill helps you create, debug, and run Python scripts in the sandbox environment.
11+
12+
## Workflow
13+
1. Create the script file using `write`
14+
2. Execute with `execute("python /app/script.py")`
15+
3. If errors occur, read the file, fix issues, and re-run
16+
17+
## Best Practices
18+
- Always include error handling with try/except
19+
- Use descriptive variable names
20+
- Add comments for complex logic
21+
- Print results for verification
22+
23+
## Common Patterns
24+
25+
### File Processing
26+
```python
27+
import os
28+
for filename in os.listdir('/app/data'):
29+
with open(f'/app/data/{filename}') as f:
30+
# process file
31+
```
32+
33+
### Data Transformation
34+
```python
35+
import json
36+
data = json.loads(input_string)
37+
# transform
38+
output = json.dumps(result, indent=2)
39+
```

0 commit comments

Comments
 (0)