Observed since 20 Oct, 21:46 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
agentcube-sdk
Python SDK for AgentCube Code Interpreter
The official Python SDK for AgentCube, enabling programmatic interaction with secure, isolated Code Interpreter environments.
This SDK creates a seamless bridge between your application and the AgentCube runtime, handling the complexity of:
with statement) for automatic resource cleanup.git clone https://github.com/volcano-sh/agentcube.git
cd agentcube/sdk-python
pip install .
from agentcube import CodeInterpreterClient
with CodeInterpreterClient() as client:
output = client.run_code("python", "print('Hello, AgentCube!')")
print(output)
# Session automatically deleted on exit
For long-running applications, you can manually control the lifecycle:
# Create a session with a 1-hour timeout
client = CodeInterpreterClient(ttl=3600)
try:
client.run_code("python", "print('Session started')")
# ... perform operations ...
# File system state persists within session
client.write_file("42", "value.txt")
client.run_code("python", "print(open('value.txt').read())")
finally:
client.stop() # CRITICAL: Ensure resources are released
with CodeInterpreterClient() as client:
client.upload_file("./data.csv", "/workspace/data.csv")
client.run_code("python", """
import pandas as pd
df = pd.read_csv('/workspace/data.csv')
df.describe().to_csv('/workspace/summary.csv')
""")
client.download_file("/workspace/summary.csv", "./summary.csv")
| Method | Description |
|---|---|
execute_command(cmd) | Execute shell command |
run_code(language, code) | Execute code (python/bash) |
upload_file(local, remote) | Upload file to sandbox |
download_file(remote, local) | Download file from sandbox |
write_file(content, path) | Write string to file |
list_files(path) | List directory contents |
stop() | Delete session and release resources |
CodeInterpreterClient(
name="custom-template", # CodeInterpreter CRD template name
namespace="agentcube", # Kubernetes namespace
ttl=7200, # Session TTL (seconds)
session_id="existing-id", # Optional: reuse existing session
verbose=True # Enable debug logging
)
Environment Variables:
WORKLOAD_MANAGER_URL: Control Plane URLROUTER_URL: Data Plane URLFor workflows requiring file system state persistence across multiple client instances:
Note: Each
run_codecall spawns a new process. Python variables do NOT persist. Only file system state is preserved.
# Step 1: Create session and save state to file
client1 = CodeInterpreterClient()
session_id = client1.session_id # Save for reuse
client1.write_file("42", "value.txt")
# Don't call stop() - let session persist
# Step 2: Reuse session with new client
client2 = CodeInterpreterClient(session_id=session_id)
client2.run_code("python", "print(open('value.txt').read())") # File persists
client2.stop() # Cleanup when done
make build-python-sdk
python3 -m pytest sdk-python/tests/
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
requestsEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | requests | runtime |
PyJWTEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | PyJWT>=2.0.0 | runtime |
cryptographyEnvironment{
"extras": "",
"marker": null,
"requires_python": ">=3.10",
"evaluation": "NOT_EVALUATED"
} | cryptography | runtime |
bdist_wheel · 22.56 KB · Python py3
sdist · 19.13 KB · Python source
Observed since 20 Oct, 21:46 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:f37c873cc1458700cbff9c6089f354510c708d5dbac0d492e0870ecc245c895e