Skip to content

GkeCodeExecutor sandbox mode: ImportError due to wrong module name (agentic_sandbox vs k8s_agent_sandbox) #4883

@leslyarun

Description

@leslyarun

Bug Description

GkeCodeExecutor with executor_type="sandbox" fails at instantiation because the code imports from agentic_sandbox import SandboxClient, but the declared dependency k8s-agent-sandbox provides the module as k8s_agent_sandbox.

Steps to Reproduce

pip install google-adk k8s-agent-sandbox kubernetes
from google.adk.code_executors import GkeCodeExecutor

executor = GkeCodeExecutor(
    namespace="agent-sandbox-system",
    executor_type="sandbox",
    sandbox_template="python-code-sandbox",
    sandbox_gateway_name="",
    timeout_seconds=300,
    cpu_limit="2",
    mem_limit="2Gi",
)

Expected Behavior

GkeCodeExecutor should instantiate successfully when k8s-agent-sandbox is installed.

Actual Behavior

ImportError: k8s-agent-sandbox not found. To use Agent Sandbox, please install
google-adk with the extensions extra: pip install "google-adk[extensions]"

Even though k8s-agent-sandbox IS installed. The root cause:

  1. gke_code_executor.py:33 does from agentic_sandbox import SandboxClient
  2. This fails because k8s-agent-sandbox provides the module as k8s_agent_sandbox, not agentic_sandbox
  3. SandboxClient becomes None
  4. _check_sandbox_dependency validator raises ImportError on instantiation

Root Cause

The import name doesn't match the package's actual module name:

Expected by google-adk Actual in k8s-agent-sandbox
Import from agentic_sandbox import SandboxClient from k8s_agent_sandbox import SandboxClient
Module dir agentic_sandbox/ k8s_agent_sandbox/
top_level.txt k8s_agent_sandbox

Verified on both k8s-agent-sandbox==0.1.1.post3 and 0.2.1 — neither provides an agentic_sandbox module.

Suggested Fix

Change the import in gke_code_executor.py:

# Before
try:
  from agentic_sandbox import SandboxClient
except ImportError:
  SandboxClient = None

# After
try:
  from k8s_agent_sandbox import SandboxClient
except ImportError:
  SandboxClient = None

Workaround

Create a shim module agentic_sandbox/__init__.py on PYTHONPATH:

from k8s_agent_sandbox import SandboxClient
__all__ = ["SandboxClient"]

Environment

  • google-adk: 1.27.2
  • k8s-agent-sandbox: 0.2.1
  • Python: 3.13
  • Kubernetes: GKE with Agent Sandbox controller + WarmPool

Related

Metadata

Metadata

Assignees

Labels

tools[Component] This issue is related to tools

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions