Contree SDK

Contree is a container runtime purpose-built to support research on SWE agents, providing reproducible, versioned filesystem state — like Git for container execution. The SDK makes this accessible from Python.

Quick Start

Installation

⚠️ Preview release The SDK is not yet published on PyPI. For now, Contree SDK is distributed as a prebuilt wheel.

Install the SDK from a wheel package:

pip install contree_sdk-0.0.0.dev2-py3-none-any.whl

Basic Usage

 1image = await client.images.pull("busybox:latest")
 2print(f"Pulled {image=}")
 3
 4result = await image.run(shell="echo 'Hello World'")
 5print(f"Simple echo: {result.stdout=}, {result.stderr=}, {result.exit_code=}")
 6
 7result = await image.run(shell="pwd")
 8print(f"Current directory: {result.stdout=}, {result.exit_code=}")
 9
10result = await image.run(shell="ls -la")
11print(f"Directory listing: {result.stdout=}, {result.exit_code=}")
12
13result = await image.run(shell="cat -", stdin="Hello from stdin\n")
14print(f"Cat with stdin: {result.stdout=}, {result.exit_code=}")
15
16result = await image.run(shell="echo 'Error message' >&2; exit 1")
17print(f"Error command: {result.stdout=}, {result.stderr=}, {result.exit_code=}")
 1image = client.images.pull("busybox:latest")
 2print(f"Pulled {image=}")
 3
 4result = image.run(shell="echo 'Hello World'").wait()
 5print(f"Simple echo: {result.stdout=}, {result.stderr=}, {result.exit_code=}")
 6
 7result = image.run(shell="pwd").wait()
 8print(f"Current directory: {result.stdout=}, {result.exit_code=}")
 9
10result = image.run(shell="ls -la").wait()
11print(f"Directory listing: {result.stdout=}, {result.exit_code=}")
12
13result = image.run(shell="cat -", stdin="Hello from stdin\n").wait()
14print(f"Cat with stdin: {result.stdout=}, {result.exit_code=}")
15
16result = image.run(shell="echo 'Error message' >&2; exit 1").wait()
17print(f"Error command: {result.stdout=}, {result.stderr=}, {result.exit_code=}")

What’s Next?

Ready to explore more? Check out our guides: