vxcontrol/pentagi · error
failed to create exec process: %w
Error message
failed to create exec process: %w
What it means
ExecCommand calls dockerClient.ContainerExecCreate to spawn the sh -c process inside the terminal container. If the Docker API rejects the exec creation, the call fails with "failed to create exec process: %w" wrapping the Docker error.
Source
Thrown at backend/pkg/tools/terminal.go:233
// Format command with working directory and ANSI styling
styledCommand := fmt.Sprintf("%s $ %s%s%s%s", cwd, ansiColorInputCmd, command, ansiColorReset, ansiLineTerminator)
_, err = t.tlp.PutMsg(ctx, database.TermlogTypeStdin, styledCommand, t.containerID, t.taskID, t.subtaskID)
if err != nil {
return "", fmt.Errorf("failed to put terminal log (stdin): %w", err)
}
timeout = t.normalizeExecTimeout(timeout)
createResp, err := t.dockerClient.ContainerExecCreate(ctx, containerName, client.ExecCreateOptions{
Cmd: cmd,
AttachStdout: true,
AttachStderr: true,
WorkingDir: cwd,
TTY: true,
})
if err != nil {
return "", fmt.Errorf("failed to create exec process: %w", err)
}
if detach {
resultChan := make(chan execResult, 1)
detachedCtx := context.WithoutCancel(ctx)
go func() {
output, err := t.getExecResult(detachedCtx, createResp.ID, timeout)
resultChan <- execResult{output: output, err: err}
}()
select {
case result := <-resultChan:
if result.err != nil {
return "", fmt.Errorf("command failed: %w: %s", result.err, result.output)
}
if result.output == "" {
return "Command completed in background with exit code 0", nilView on GitHub (pinned to ea665308ba)
Solutions
- Read the wrapped Docker error for the specific API cause
- Confirm the container (PrimaryTerminalName result) still exists and is running right before exec
- Validate that the cwd path exists inside the container image
- Recreate the terminal container and retry; check daemon health (docker info)
Example fix
// before
ExecCreateOptions{WorkingDir: "/nonexistent", ...} // failed to create exec process: ... no such directory
// after
cwd := docker.WorkFolderPathInContainer // guaranteed to exist in the image
createResp, err := dockerClient.ContainerExecCreate(ctx, containerName, client.ExecCreateOptions{WorkingDir: cwd, ...}) Defensive patterns
Strategy: retry
Validate before calling
exists, err := dockerClient.IsContainerRunning(ctx, containerLID)
if err != nil || !exists {
return fmt.Errorf("container not ready for exec: %w", err)
}
if cwd != "" {
if err := ensureDirInContainer(ctx, containerName, cwd); err != nil {
return fmt.Errorf("cwd %q missing in container: %w", cwd, err)
}
} Try / catch
out, err := term.ExecCommand(ctx, cwd, cmd, false, timeout)
if err != nil && strings.HasPrefix(err.Error(), "failed to create exec process:") {
// likely a race with container exit or bad cwd — recreate sandbox, then retry once
if rerr := term.EnsureRunning(ctx); rerr == nil {
out, err = term.ExecCommand(ctx, cwd, cmd, false, timeout)
}
} Prevention
- Re-verify container state immediately before exec to narrow the race window
- Default cwd to docker.WorkFolderPathInContainer and validate any custom path exists in the image
- Monitor Docker daemon health and restarts (exec creation fails while the daemon is down)
- Keep the PrimaryTerminalName naming scheme stable across the codebase so lookups don't miss
When it happens
Trigger: ContainerExecCreate failing because the container name doesn't resolve (container removed/renamed), the container just stopped between the running-check and this call, an invalid working directory (cwd doesn't exist in the container), or the Docker daemon erroring/being unreachable.
Common situations: Race where the container exits between IsContainerRunning and exec creation; PrimaryTerminalName container removed externally; cwd pointing to a path not present in the image; Docker daemon OOM or restarting; malformed command leading to API rejection.
Related errors
- failed to attach file-check exec: %w
- failed to inspect file-check exec: %w
- failed to stat container path '%s': %w
- failed to create list exec for '%s': %w
- failed to attach list exec for '%s': %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/791698a2fcd379af.
Report an issue: GitHub.