一键导入
google-adk-code-executor
ADK code execution backends. Use when agents need to write and run Python code — BuiltIn, Container, VertexAI, GKE, or local executors.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
ADK code execution backends. Use when agents need to write and run Python code — BuiltIn, Container, VertexAI, GKE, or local executors.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
ADK Agent-to-Agent (A2A) protocol integration. Use when building remote agent communication — exposing ADK agents as A2A servers or connecting to external A2A agents as clients.
ADK App pattern with plugins, event compaction, and resumability. Use when you need plugins (context filtering, debug logging), event summarization, or resumable long-running operations.
ADK artifact services for file storage. Use when agents need to save/load files, images, or binary data — InMemory, File, and GCS artifact backends.
ADK authentication and credentials. Use when adding auth to tools — API keys, bearer tokens, OAuth2 flows, OpenID Connect, service accounts, and credential storage services.
Catalog of all ADK built-in tools. Use when looking for pre-built tools to add to agents — search, memory, artifacts, transfer, grounding, and user interaction tools.
Implement ADK agent and tool callbacks. Use when adding lifecycle hooks — before/after agent execution, before/after tool calls, for logging, validation, conditional execution, or response modification.
| name | google-adk-code-executor |
| description | ADK code execution backends. Use when agents need to write and run Python code — BuiltIn, Container, VertexAI, GKE, or local executors. |
Code executors let agents write and execute Python code. ADK provides multiple backends with different isolation levels.
| Executor | Isolation | Use Case | Install |
|---|---|---|---|
BuiltInCodeExecutor | Gemini sandbox | Simple code tasks | google-adk |
UnsafeLocalCodeExecutor | None (local process) | Development only | google-adk |
ContainerCodeExecutor | Docker container | Self-hosted production | google-adk[extensions] |
VertexAiCodeExecutor | Google Cloud sandbox | Managed production | google-adk[extensions] |
GkeCodeExecutor | Kubernetes pod | GKE-based production | google-adk[extensions] |
AgentEngineSandboxCodeExecutor | Agent Engine | Vertex AI Agent Engine | google-adk[extensions] |
Uses Gemini's built-in code execution capability. No additional setup.
from google.adk.agents import Agent
from google.adk.code_executors import BuiltInCodeExecutor
agent = Agent(
name="coder",
model="gemini-2.5-flash",
instruction="Write and execute Python code to solve problems.",
code_executor=BuiltInCodeExecutor(),
)
Executes code directly on the host machine. Never use in production.
from google.adk.code_executors import UnsafeLocalCodeExecutor
agent = Agent(
name="dev_coder",
model="gemini-2.5-flash",
instruction="Write and run Python code locally.",
code_executor=UnsafeLocalCodeExecutor(),
)
Runs code inside a Docker container for isolation.
pip install google-adk[extensions]
from google.adk.code_executors import ContainerCodeExecutor
agent = Agent(
name="sandboxed_coder",
model="gemini-2.5-flash",
instruction="Write and execute code safely.",
code_executor=ContainerCodeExecutor(
image="python:3.11-slim",
packages=["pandas", "numpy"],
),
)
Google Cloud-managed sandbox. No container management needed.
pip install google-adk[extensions]
from google.adk.code_executors import VertexAiCodeExecutor
agent = Agent(
name="cloud_coder",
model="gemini-2.5-flash",
instruction="Write and execute code in a managed sandbox.",
code_executor=VertexAiCodeExecutor(
project="my-gcp-project",
location="us-central1",
),
)
Executes code in a Kubernetes pod on GKE.
pip install google-adk[extensions]
from google.adk.code_executors import GkeCodeExecutor
agent = Agent(
name="gke_coder",
model="gemini-2.5-flash",
instruction="Execute code on the cluster.",
code_executor=GkeCodeExecutor(
cluster_name="my-cluster",
project="my-gcp-project",
location="us-central1",
),
)
For agents deployed to Vertex AI Agent Engine:
from google.adk.code_executors import AgentEngineSandboxCodeExecutor
agent = Agent(
name="engine_coder",
model="gemini-2.5-flash",
instruction="Execute code in the Agent Engine sandbox.",
code_executor=AgentEngineSandboxCodeExecutor(),
)
| Requirement | Recommended Executor |
|---|---|
| Quick prototyping | BuiltInCodeExecutor |
| Local dev with full libraries | UnsafeLocalCodeExecutor |
| Self-hosted production | ContainerCodeExecutor |
| Google Cloud production | VertexAiCodeExecutor |
| GKE-based infrastructure | GkeCodeExecutor |
| Deployed to Agent Engine | AgentEngineSandboxCodeExecutor |
BuiltInCodeExecutor is the safest default — uses Gemini's built-in sandboxUnsafeLocalCodeExecutor has NO isolation — code runs with full host accesspip install google-adk[extensions]code_executor field)google-adk-llm-agent — Agent configuration (where code_executor is set)google-adk-deploy — Production deployment considerations