-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Summary
Code execution through the picod service does not work correctly when the --workspace argument is set to a directory other than /root (e.g., /workspace). This causes execution failures and unexpected behavior when using the CodeInterpreterClient.
Environment
- Component: picod (Code Execution Service)
- Image:
ghcr.io/volcano-sh/picod:latest - Affected Files:
docs/getting-started.mdexample/code-interpreter/code-interpreter.yaml
Problem Description
When the picod container is started with --workspace=/workspace (or any directory other than /root), code execution requests fail or behave unexpectedly. The issue stems from the fact that the specified workspace directory may not exist or is not properly initialized in the container.
Root Cause
Looking at pkg/picod/execute.go, the command execution logic is:
// Set working directory
if req.WorkingDir != "" {
safeWorkingDir, err := s.sanitizePath(req.WorkingDir)
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{
"error": fmt.Sprintf("Invalid working directory: %v", err),
"code": http.StatusBadRequest,
})
return
}
cmd.Dir = safeWorkingDir
}When working_dir is not explicitly provided in the execution request, the command runs in the default working directory of the picod process. However, if the workspace is set to a non-existent directory like /workspace:
- The directory may not exist in the container
- File operations and command executions fail
- Code that relies on writing/reading files cannot function properly
Steps to Reproduce
-
Deploy picod with workspace set to
/workspace:args: - --workspace=/workspace
-
Attempt to execute code using the CodeInterpreterClient:
from agentcube import CodeInterpreterClient with CodeInterpreterClient(name="my-interpreter") as client: result = client.run_code("python", "print('Hello from AgentCube!')") print(result)
-
Observe execution failures or unexpected behavior
Expected Behavior
Code execution should work seamlessly regardless of the configured workspace directory, with the directory being properly created and accessible.
Actual Behavior
Code execution fails when workspace is set to a directory that doesn't exist (e.g., /workspace).