google-agents-cli-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseADK Development Workflow & Guidelines
ADK开发工作流与规范
STOP — Do NOT write code yet. If no project exists, scaffold first with. If the user already has code, useagents-cli scaffold create <name>to add the agents-cli structure. Runagents-cli scaffold enhance .to check if a project already exists. Skipping this leads to missing eval boilerplate, CI/CD config, and project conventions.agents-cli info
agents-cli is a CLI and skills toolkit for building, evaluating, and deploying agents on Google Cloud using the Agent Development Kit (ADK). It works with any coding agent — Gemini CLI, Claude Code, Codex, or others. Install with .
uvx google-agents-cli setupRequires: google-agents-cli= 0.1.0 If version is behind, run: uv tool install "google-agents-cli=0.1.0" Check version: agents-cli info Install uv first if needed.
注意——请勿立即编写代码。 如果尚未创建项目,请先使用搭建脚手架。如果用户已有代码,请使用agents-cli scaffold create <name>添加agents-cli结构。运行agents-cli scaffold enhance .检查项目是否已存在。跳过此步骤会导致缺少评估模板、CI/CD配置和项目约定。agents-cli info
agents-cli 是一款CLI及技能工具包,用于借助Agent Development Kit (ADK)在Google Cloud上构建、评估和部署Agent。它兼容任何代码Agent——Gemini CLI、Claude Code、Codex等。使用 进行安装。
uvx google-agents-cli setup依赖要求:google-agents-cli= 0.1.0 如果版本落后,请运行:uv tool install "google-agents-cli=0.1.0" 检查版本:agents-cli info 如有需要,请先安装uv
Session Continuity & Skill Cross-References
会话连续性与技能交叉引用
Re-read the relevant skill before each phase — not after you've already started and hit a problem. Context compaction may have dropped earlier skill content. If skills are not available, run to install them.
uvx google-agents-cli setup| Phase | Skill | When to load |
|---|---|---|
| 0 — Understand | — | No skill needed — read |
| 1 — Study samples | — | Check Notable Samples table below — clone and study matching samples before scaffolding |
| 2 — Scaffold | | Before creating or enhancing a project |
| 3 — Build | | Before writing agent code — API patterns, tools, callbacks, state |
| 4 — Evaluate | | Before running any eval — evalset schema, metrics, eval-fix loop |
| 5 — Deploy | | Before deploying — target selection, troubleshooting 403/timeouts |
| 6 — Publish | | After deploying, if registering with Gemini Enterprise (optional) |
| 7 — Observe | | After deploying — traces, logging, monitoring setup |
在每个阶段开始之前,重新阅读相关技能——不要等已经开始并遇到问题后才读。上下文压缩可能会丢失早期的技能内容。如果技能不可用,请运行 进行安装。
uvx google-agents-cli setup| 阶段 | 技能 | 加载时机 |
|---|---|---|
| 0 — 需求理解 | — | 无需技能——阅读 |
| 1 — 参考示例学习 | — | 查看下方的典型示例表格——在搭建脚手架前克隆并研究匹配的示例 |
| 2 — 脚手架搭建 | | 创建或升级项目之前 |
| 3 — 构建 | | 编写Agent代码之前——API模式、工具、回调、状态 |
| 4 — 评估 | | 运行任何评估之前——评估集 schema、指标、评估-修复循环 |
| 5 — 部署 | | 部署之前——目标选择、403/超时故障排查 |
| 6 — 发布 | | 部署完成后,如果需要注册到Gemini Enterprise(可选) |
| 7 — 监控 | | 部署完成后——追踪、日志、监控设置 |
Setup
安装配置
If is not installed:
agents-clibash
uv tool install google-agents-cli如果未安装:
agents-clibash
uv tool install google-agents-cliuv
command not found
uvuv
命令未找到
uvInstall following the official installation guide.
uv请按照官方安装指南安装。
uvProduct name mapping
产品名称映射
The platform formerly known as "Vertex AI" is now Gemini Enterprise Agent Platform (short: Agent Platform). Users may refer to products by different names. Map them to the correct CLI values:
| User may say | CLI value |
|---|---|
| Agent Engine, Vertex AI Agent Engine, Agent Runtime | |
| Vertex AI Search, Agent Search | |
| Vertex AI Vector Search, Vector Search | |
| Agent Engine sessions, Agent Platform Sessions | |
The Python SDK package name is unchanged.
vertexai原名为「Vertex AI」的平台现在是Gemini Enterprise Agent Platform(简称:Agent Platform)。用户可能会用不同名称指代产品,请将其映射为正确的CLI参数:
| 用户可能的表述 | CLI参数值 |
|---|---|
| Agent Engine、Vertex AI Agent Engine、Agent Runtime | |
| Vertex AI Search、Agent Search | |
| Vertex AI Vector Search、Vector Search | |
| Agent Engine sessions、Agent Platform Sessions | |
Python SDK包名保持不变。
vertexaiPhase 0: Understand
阶段0:需求理解
Before writing or scaffolding anything, understand what you're building.
If already exists, read it — it is your primary source of truth. Otherwise:
DESIGN_SPEC.mdDo NOT proceed to planning, scaffolding, or coding. Ask the user the questions below and wait for their answers. You MUST have the user's answers before moving on. Do not assume, research, or fill in the blanks yourself. The user's intent drives everything — skipping this step leads to wasted work.
Always ask:
- What problem will the agent solve? — Core purpose and capabilities
- External APIs or data sources needed? — Tools, integrations, auth requirements
- Safety constraints? — What the agent must NOT do, guardrails
- Deployment preference? — Prototype first (recommended) or full deployment? If deploying: Agent Runtime, Cloud Run, or GKE?
Ask based on context:
- If retrieval or search over data mentioned (RAG, semantic search, vector search, embeddings, similarity search, data ingestion) → Datastore? Options: (embeddings, similarity search) or
agent_platform_vector_search(document search, search engine).agent_platform_search - If agent should be available to other agents → A2A protocol? Enables the agent as an A2A-compatible service.
- If full deployment chosen → CI/CD runner? GitHub Actions (default) or Google Cloud Build?
- If agent should remember user preferences or facts across sessions → Memory Bank? Long-term memory across conversations. See .
/google-agents-cli-adk-code - If Cloud Run or GKE chosen → Session storage? In-memory (default), Cloud SQL (persistent), or Agent Platform Sessions (managed).
- If deployment with CI/CD chosen → Git repository? Does one already exist, or should one be created? If creating, public or private?
Once you have the user's answers, write a with the user's approval. See for how these choices map to CLI flags. At minimum include these sections — expand with more detail if the user wants a thorough spec:
DESIGN_SPEC.md/google-agents-cli-scaffoldmarkdown
undefined在编写或搭建任何内容之前,先明确要构建的目标。
如果已存在,请阅读它——这是你的主要参考依据。否则:
DESIGN_SPEC.md请勿进入规划、脚手架搭建或编码环节。请向用户询问以下问题并等待回复。在继续之前必须获得用户的答案,不要自行假设、调研或填补信息空白。用户的意图是核心——跳过此步骤会导致无效工作。
必须询问:
- 该Agent要解决什么问题?——核心用途和功能
- 是否需要外部API或数据源?——工具、集成、认证要求
- 安全约束有哪些?——Agent绝对不能执行的操作、防护规则
- 部署偏好是什么?——先做原型(推荐)还是直接完整部署?如果部署:选择Agent Runtime、Cloud Run还是GKE?
根据上下文补充询问:
- 如果提到基于数据的检索或搜索(RAG、语义搜索、向量搜索、嵌入、相似度搜索、数据导入)→ 数据存储类型? 选项:(嵌入、相似度搜索)或
agent_platform_vector_search(文档搜索、搜索引擎)。agent_platform_search - 如果Agent需要被其他Agent调用→ A2A协议? 可将该Agent设为兼容A2A的服务。
- 如果选择完整部署→ CI/CD执行器? GitHub Actions(默认)还是Google Cloud Build?
- 如果Agent需要跨会话记住用户偏好或信息→ Memory Bank? 跨对话的长期记忆。请查看。
/google-agents-cli-adk-code - 如果选择Cloud Run或GKE→ 会话存储? 内存存储(默认)、Cloud SQL(持久化)或Agent Platform Sessions(托管)。
- 如果选择带CI/CD的部署→ Git仓库? 是否已存在,还是需要创建?如果创建,设为公开还是私有?
获得用户的答案后,编写并获得用户认可。请查看了解这些选择如何映射到CLI参数。至少包含以下章节——如果用户需要详细规范,可以扩展更多内容:
DESIGN_SPEC.md/google-agents-cli-scaffoldmarkdown
undefinedDESIGN_SPEC.md
DESIGN_SPEC.md
Overview
概述
Describe the agent's purpose and how it works.
描述Agent的用途及工作方式。
Example Use Cases
示例用例
Concrete examples with expected inputs and outputs.
具体示例,包含预期输入和输出。
Tools Required
所需工具
Each tool with its purpose, API details, and authentication needs.
每个工具的用途、API详情及认证需求。
Constraints & Safety Rules
约束与安全规则
Specific rules — not just generic statements.
具体规则——不要仅使用通用表述。
Success Criteria
成功标准
Measurable outcomes for evaluation.
可衡量的评估结果。
Reference Samples
参考示例
Check the Notable Samples in Phase 1 — list any that match this use case.
Optional sections for more detailed specs: **Edge Cases to Handle**, **Architecture & Sub-Agents**, **Data Sources & Auth**, **Non-Functional Requirements**.
Once you have a clear understanding, proceed to **Phase 1**.查看阶段1的典型示例——列出与本用例匹配的示例。
详细规范的可选章节:**需处理的边缘情况**、**架构与子Agent**、**数据源与认证**、**非功能需求**。
明确需求后,进入**阶段1**。Phase 1: Study Reference Samples
阶段1:学习参考示例
Ask yourself: is there a sample that can help me design this and cut time? Scan the keywords below. Multiple samples can match — clone and study all that are relevant.
bash
undefined问问自己:有没有可以帮助设计并节省时间的示例?查看以下关键词。可能有多个匹配的示例——克隆并研究所有相关示例。
bash
undefinedClone a sample to study — read the key files, understand the patterns, then apply
克隆示例进行研究——阅读关键文件,理解模式,然后应用到自己的脚手架项目中。请勿使用adk@<sample>
脚手架。
adk@<sample>them to your own scaffolded project. Do NOT use adk@<sample>
scaffolding.
adk@<sample>—
git clone --filter=tree:0 --sparse https://github.com/google/adk-samples /tmp/adk-samples 2>/dev/null;
cd /tmp/adk-samples && git sparse-checkout add python/agents/<sample-name>
cd /tmp/adk-samples && git sparse-checkout add python/agents/<sample-name>
- **`ambient-expense-agent`** — Agent that runs on a schedule or reacts to events, with no interactive user.
Keywords: scheduled, cron, daily, pubsub, event-driven, alerts, email, ambient
Key files: `expense_agent/fast_api_app.py`, `expense_agent/agent.py`, `expense_agent/config.py`, `terraform/`
- **`adk-ae-oauth`** — Agent with OAuth 2.0 user consent, deployed to Agent Runtime with Gemini Enterprise.
Keywords: OAuth, authentication, user consent, Google Drive, Agent Runtime, Gemini Enterprise
Key files: `README.md`, `adk_ae_oauth/tools.py`, `adk_ae_oauth/auths.py`
- **`genmedia-for-commerce`** — Full-stack agent with React UI, MCP tools, media/image handling, and Gemini Enterprise registration.
Keywords: MCP, media, video generation, Veo, virtual try-on, retail, full-stack, React, Gemini Enterprise
Key files: `genmedia4commerce/agent.py`, `genmedia4commerce/agent_utils.py`, `genmedia4commerce/fast_api_app.py`
- **`deep-search`** — Research agent that iterates until quality is met, with source citations.
Keywords: research, citations, iterative, grounding, multi-agent, human-in-the-loop, web search, report
Key files: `app/agent.py`, `app/config.py`
- **`safety-plugins`** — Reusable safety guardrails that plug into any agent runner.
Keywords: safety, guardrails, model armor, filters
Key files: `safety_plugins/plugins/model_armor.py`, `safety_plugins/plugins/agent_as_a_judge.py`, `safety_plugins/main.py`
- **`data-science`** — Agent that executes code in a managed sandbox for data analysis.
Keywords: SQL, BigQuery, code execution, sandbox
Key files: `data_science/sub_agents/analytics/agent.py`
- **`memory-bank`** — Conversational agent with cross-session memory via Memory Bank (Cloud Run and Agent Runtime).
Keywords: memory, cross-session, recall, context, remember, Memory Bank
Key files: `app/agent.py`, `app/agent_runtime_app.py`, `app/fast_api_app.py`
If no sample matches, proceed to Phase 2. But first — are you sure? Re-read the user's request and compare it against the keywords above. Skipping a matching sample means rebuilding patterns that already exist.
> **IMPORTANT — Exit criteria:** After studying a sample, ask yourself: can I apply anything from this sample to help me deliver the design? Note what you'll reuse before moving on. Do NOT proceed until you've answered this.
> **This list is useful at any phase** — revisit it when you hit deployment, publishing, or infrastructure questions. A sample's Terraform or registration pattern may be exactly what you need later.git clone --filter=tree:0 --sparse https://github.com/google/adk-samples /tmp/adk-samples 2>/dev/null;
cd /tmp/adk-samples && git sparse-checkout add python/agents/<sample-name>
cd /tmp/adk-samples && git sparse-checkout add python/agents/<sample-name>
- **`ambient-expense-agent`** — 按计划运行或响应事件的Agent,无交互式用户。
关键词:定时、cron、每日、pubsub、事件驱动、告警、邮件、后台运行
关键文件:`expense_agent/fast_api_app.py`、`expense_agent/agent.py`、`expense_agent/config.py`、`terraform/`
- **`adk-ae-oauth`** — 带有OAuth 2.0用户授权的Agent,部署到Agent Runtime并集成Gemini Enterprise。
关键词:OAuth、认证、用户授权、Google Drive、Agent Runtime、Gemini Enterprise
关键文件:`README.md`、`adk_ae_oauth/tools.py`、`adk_ae_oauth/auths.py`
- **`genmedia-for-commerce`** — 带有React UI、MCP工具、媒体/图片处理功能的全栈Agent,并已注册到Gemini Enterprise。
关键词:MCP、媒体、视频生成、Veo、虚拟试穿、零售、全栈、React、Gemini Enterprise
关键文件:`genmedia4commerce/agent.py`、`genmedia4commerce/agent_utils.py`、`genmedia4commerce/fast_api_app.py`
- **`deep-search`** — 迭代执行直到达到质量要求的研究型Agent,包含来源引用。
关键词:研究、引用、迭代、基础检索、多Agent、人工介入、网页搜索、报告
关键文件:`app/agent.py`、`app/config.py`
- **`safety-plugins`** — 可复用的安全防护规则,可接入任何Agent运行器。
关键词:安全、防护规则、模型防护、过滤器
关键文件:`safety_plugins/plugins/model_armor.py`、`safety_plugins/plugins/agent_as_a_judge.py`、`safety_plugins/main.py`
- **`data-science`** — 在托管沙箱中执行代码以进行数据分析的Agent。
关键词:SQL、BigQuery、代码执行、沙箱
关键文件:`data_science/sub_agents/analytics/agent.py`
- **`memory-bank`** — 通过Memory Bank实现跨会话记忆的对话式Agent(支持Cloud Run和Agent Runtime)。
关键词:记忆、跨会话、召回、上下文、记忆功能、Memory Bank
关键文件:`app/agent.py`、`app/agent_runtime_app.py`、`app/fast_api_app.py`
如果没有匹配的示例,进入阶段2。但先确认一下:你确定没有匹配的吗?重新阅读用户需求并与上述关键词对比。跳过匹配的示例意味着要重新构建已有的模式。
> **重要——退出标准:** 研究示例后,问问自己:我是否可以应用该示例中的内容来帮助完成设计?在继续之前记录下要复用的内容。必须回答此问题后才能推进。
> **此列表在任何阶段都有用**——遇到部署、发布或基础设施问题时可重新查看。示例中的Terraform或注册模式可能正是你后续需要的。Phase 2: Scaffold (if needed)
阶段2:搭建脚手架(如有需要)
Use to create a new project or import an existing one into the agents-cli format (adding deployment, CI/CD, infrastructure). It covers architecture choices (deployment target, agent type, session storage) and project creation or enhancement.
/google-agents-cli-scaffoldSkip this phase if the project was already created or enhanced by agents-cli — run from the project root to check.
agents-cli info使用创建新项目,或将现有项目导入agents-cli格式(添加部署、CI/CD、基础设施配置)。它涵盖架构选择(部署目标、Agent类型、会话存储)以及项目创建或升级。
/google-agents-cli-scaffold如果项目已通过agents-cli创建或升级,请跳过此阶段——在项目根目录运行进行检查。
agents-cli infoPhase 3: Build and Implement
阶段3:构建与实现
Implement the agent logic:
- Write/modify code in the agent directory (check /
GEMINI.mdfor directory name)CLAUDE.md - Quick smoke test: Use to verify the agent works after changes — this is the fastest way to check behavior without leaving the terminal
agents-cli run "your prompt" - Iterate on the implementation based on user feedback
If the user asks for interactive testing, suggest — it opens a web-based playground for manual conversation with the agent.
agents-cli playgroundFor ADK API patterns and code examples, use .
/google-agents-cli-adk-codeNEVER write pytest tests that assert on LLM output content (e.g., checking for keywords in responses, verifying persona, validating tone). LLM outputs are non-deterministic — these tests are flaky by nature and belong in eval, not pytest. Usefor quick checks andagents-cli runfor systematic validation.agents-cli eval run
实现Agent逻辑:
- 在Agent目录中编写/修改代码(查看/
GEMINI.md获取目录名称)CLAUDE.md - 快速冒烟测试:修改后使用验证Agent是否正常工作——这是无需离开终端即可检查行为的最快方式
agents-cli run "your prompt" - 根据用户反馈迭代实现
如果用户要求交互式测试,建议使用——它会打开一个基于网页的 playground,用于手动与Agent对话。
agents-cli playground如需ADK API模式和代码示例,请使用。
/google-agents-cli-adk-code切勿编写断言LLM输出内容的pytest测试(例如,检查响应中的关键词、验证角色、确认语气)。LLM输出是非确定性的——这类测试本质上不稳定,应属于评估环节,而非pytest测试。使用进行快速检查,使用agents-cli run进行系统验证。agents-cli eval run
Phase 3.5: Provision Datastore (RAG projects only)
阶段3.5:配置数据存储(仅RAG项目)
For projects, provision the datastore before testing: , then . Use — not (same datastore provisioning but faster, skips unrelated Terraform).
agentic_ragagents-cli infra datastoreagents-cli data-ingestioninfra datastoreinfra single-project对于项目,请在测试前配置数据存储:,然后运行。请使用——不要使用(两者数据存储配置相同,但前者更快,会跳过无关的Terraform操作)。
agentic_ragagents-cli infra datastoreagents-cli data-ingestioninfra datastoreinfra single-projectPhase 4: Evaluate
阶段4:评估
This is the most important phase. Evaluation validates agent behavior end-to-end.
MANDATORY: Activate before running evaluation.
It contains the evalset schema, config format, and critical gotchas. Do NOT skip this.
/google-agents-cli-evalDo NOT skip this phase. After building the agent, you MUST proceed to evaluation. Do NOT write pytest tests to validate agent behavior — that is what eval is for.
uv run pytestagents-cli eval run- — Tests code correctness: imports work, functions return expected types, API contracts hold. Does NOT test whether the agent behaves well.
uv run pytest - — Tests agent behavior: response quality, tool usage, persona consistency, safety compliance. This is what validates your agent actually works.
agents-cli eval run - — Quick one-off smoke test during development. Use this for fast iteration, not pytest.
agents-cli run "prompt"
NEVER write pytest tests that check LLM response content (e.g., asserting pirate keywords appear, checking if the agent mentions allergies). LLM outputs are non-deterministic. Use eval with LLM-as-judge criteria instead.
- Start small: Begin with 1-2 sample eval cases, not a full suite
- Run evaluations:
agents-cli eval run - Discuss results with the user
- Fix issues and iterate on the core cases first
- Only after core cases pass, add edge cases and new scenarios
- Repeat until quality thresholds are met
Expect 5-10+ iterations here.
这是最重要的阶段。 评估用于端到端验证Agent行为。
必须执行: 运行评估前激活。它包含评估集schema、配置格式和关键注意事项。请勿跳过此步骤。
/google-agents-cli-eval请勿跳过此阶段。 构建Agent后,必须进入评估环节。切勿编写pytest测试来验证Agent行为——这是评估的用途。
uv run pytestagents-cli eval run- — 测试代码正确性:导入是否正常、函数是否返回预期类型、API契约是否符合要求。不测试Agent表现是否良好。
uv run pytest - — 测试Agent行为:响应质量、工具使用、角色一致性、安全合规性。这是验证Agent是否真正可用的方式。
agents-cli eval run - — 开发过程中的快速一次性冒烟测试。用于快速迭代,而非pytest测试。
agents-cli run "prompt"
切勿编写检查LLM响应内容的pytest测试(例如,断言出现海盗关键词、检查Agent是否提及过敏情况)。LLM输出是非确定性的,请改用LLM作为评判标准的评估方式。
- 从小规模开始:先从1-2个评估示例开始,不要一开始就用完整的测试套件
- 运行评估:
agents-cli eval run - 与用户讨论结果
- 修复问题并优先迭代核心用例
- 核心用例通过后,再添加边缘情况和新场景
- 重复直到达到质量阈值
预计需要5-10+次迭代。
Phase 5: Deploy
阶段5:部署
Once evaluation thresholds are met:
- Check if the project has a deployment target configured — run to see current config
agents-cli info - If the project is a prototype (no deployment target), add deployment support first:
Seebash
agents-cli scaffold enhance . --deployment-target <target>for the deployment target decision matrix (Agent Runtime vs Cloud Run vs GKE)./google-agents-cli-deploy - Deploy when ready:
agents-cli deploy
IMPORTANT: Never deploy without explicit human approval.
达到评估阈值后:
- 检查项目是否已配置部署目标——运行查看当前配置
agents-cli info - 如果项目是原型(无部署目标),先添加部署支持:
请查看bash
agents-cli scaffold enhance . --deployment-target <target>获取部署目标决策矩阵(Agent Runtime vs Cloud Run vs GKE)。/google-agents-cli-deploy - 准备就绪后部署:
agents-cli deploy
重要: 未经人工明确批准,切勿部署。
Phase 6: Publish (optional)
阶段6:发布(可选)
Not all agents require this — currently supporting Gemini Enterprise. See for registration modes, flags, and troubleshooting.
/google-agents-cli-publish并非所有Agent都需要此步骤——目前仅支持Gemini Enterprise。请查看获取注册模式、参数和故障排查方法。
/google-agents-cli-publishPhase 7: Observe
阶段7:监控
After deploying, use observability tools to monitor agent behavior in production. See for Cloud Trace, prompt-response logging, BigQuery Analytics, and third-party integrations.
/google-agents-cli-observability部署完成后,使用可观测性工具监控Agent在生产环境中的行为。请查看获取Cloud Trace、请求-响应日志、BigQuery分析及第三方集成的相关信息。
/google-agents-cli-observabilityOperational Guidelines for Coding Agents
代码Agent操作规范
Common Shortcuts to Resist
需避免的常见捷径
Agents routinely skip steps with plausible-sounding excuses. Recognize these and push back:
| Shortcut | Why it fails |
|---|---|
| "The user's request is clear enough, no need to clarify" | You're guessing at requirements. Phase 0 exists to confirm intent before scaffolding — even one question can prevent a full rework. |
"The agent responded correctly in | One prompt is not a test suite. Eval catches regressions, edge cases, and tool trajectory issues that a single run never will. |
| "I'll use a newer/better model" | The scaffolded model was chosen deliberately. Changing it without being asked violates code preservation (Principle 1) and often breaks things — wrong location, deprecated version, or 404. Your training data is likely out of date — rely on the skills and the model listing command, not your knowledge of model names. |
| "I can skip the scaffold and set up manually" | Manual setup misses eval boilerplate, CI/CD config, and |
Agent经常会用看似合理的借口跳过步骤,请识别这些情况并纠正:
| 捷径 | 失败原因 |
|---|---|
| "用户的请求足够明确,无需澄清" | 你在猜测需求。阶段0的存在是为了在搭建脚手架前确认意图——哪怕一个问题都能避免全盘返工。 |
"Agent在 | 单个请求不能代表测试套件。评估能发现单次运行永远无法察觉的回归、边缘情况和工具调用路径问题。 |
| "我要使用更新/更好的模型" | 脚手架选择的模型是经过考量的。未经要求更改模型违反代码保留原则(原则1),且通常会导致问题——路径错误、版本过时或404错误。你的训练数据可能已过时,请依赖技能和模型列表命令,而非自己记忆的模型名称。 |
| "我可以跳过脚手架手动配置" | 手动配置会遗漏评估模板、CI/CD配置和 |
Principle 1: Code Preservation & Isolation
原则1:代码保留与隔离
Code modifications require surgical precision — alter only the code segments directly targeted by the user's request and strictly preserve all surrounding and unrelated code.
Mandatory Pre-Execution Verification:
Before finalizing any code replacement, verify the following:
- Target Identification: Clearly define the exact lines or expressions to change, based solely on the user's explicit instructions.
- Preservation Check: Confirm that all code, configuration values (e.g., ,
model,version), comments, and formatting outside the identified target remain identical.api_key
Example:
- User Request: "Change the agent's instruction to be a recipe suggester."
- Incorrect (VIOLATION):
python
root_agent = Agent( name="recipe_suggester", model="gemini-1.5-flash", # UNINTENDED - model was not requested to change instruction="You are a recipe suggester." ) - Correct (COMPLIANT):
python
root_agent = Agent( name="recipe_suggester", # OK, related to new purpose model="gemini-flash-latest", # PRESERVED instruction="You are a recipe suggester." # OK, the direct target )
代码修改需要精准操作——仅修改用户请求直接指向的代码段,严格保留所有周边及无关代码。
执行前必须验证:
在最终确定任何代码替换前,验证以下内容:
- 目标定位: 仅根据用户的明确指令,明确定义要修改的精确行或表达式。
- 保留检查: 确认目标范围之外的所有代码、配置值(如、
model、version)、注释和格式保持完全一致。api_key
示例:
- 用户请求: "将Agent的指令改为食谱推荐器。"
- 错误(违反规范):
python
root_agent = Agent( name="recipe_suggester", model="gemini-1.5-flash", # 非预期修改——未要求更改模型 instruction="You are a recipe suggester." ) - 正确(符合规范):
python
root_agent = Agent( name="recipe_suggester", # 允许,与新用途相关 model="gemini-flash-latest", # 保留原配置 instruction="You are a recipe suggester." # 允许,直接修改目标 )
Principle 2: Execution Best Practices
原则2:执行最佳实践
-
Model Selection — CRITICAL:
- NEVER change the model unless explicitly asked.
- When creating NEW agents (not modifying existing), use the latest Gemini model. List available models to pick the newest one:
bash
# Use 'global' or any supported region (e.g. 'us-east1') uv run --with google-genai python -c " from google import genai client = genai.Client(vertexai=True, location='global') for m in client.models.list(): print(m.name) " - Do NOT use older models unless explicitly requested. For model docs, fetch . See also stable model versions.
https://adk.dev/agents/models/google-gemini/index.md
-
Running Python Commands:
- Always use to execute Python commands (e.g.,
uv)uv run python script.py - Run before executing scripts
uv sync
- Always use
-
Breaking Infinite Loops:
- Stop immediately if you see the same error 3+ times in a row
- RED FLAGS: Lock IDs incrementing, names appending v5→v6→v7, "I'll try one more time" repeatedly
- State conflicts (Error 409): Use instead of retrying creation
terraform import - When stuck: Run underlying commands directly (e.g., CLI)
terraform
-
Troubleshooting:
- Check first — it covers most common patterns
/google-agents-cli-adk-code - Use WebFetch on URLs from the ADK docs index () for deep dives
curl https://adk.dev/llms.txt - When encountering persistent errors, a targeted web search often finds solutions faster
- CLI command failures: run — the output ends with a
agents-cli <command> --helpline pointing to the exact source file implementing that command. Read it to understand the logic and diagnose failures. UseSource:to get the full CLI install path if you need to browse across multiple files.agents-cli info
- Check
-
模型选择——至关重要:
- 除非明确要求,否则切勿更改模型。
- 创建新Agent(而非修改现有Agent)时,使用最新的Gemini模型。列出可用模型以选择最新版本:
bash
# 使用'global'或任何支持的区域(例如'us-east1') uv run --with google-genai python -c " from google import genai client = genai.Client(vertexai=True, location='global') for m in client.models.list(): print(m.name) " - 除非明确要求,否则请勿使用旧模型。如需模型文档,请获取。另请查看稳定模型版本。
https://adk.dev/agents/models/google-gemini/index.md
-
运行Python命令:
- 始终使用执行Python命令(例如
uv)uv run python script.py - 执行脚本前运行
uv sync
- 始终使用
-
打破无限循环:
- 如果连续3次以上出现相同错误,请立即停止
- 危险信号:锁ID递增、名称从v5→v6→v7追加、反复出现"我再试一次"
- 状态冲突(错误409):使用而非重试创建
terraform import - 遇到阻塞时:直接运行底层命令(例如CLI)
terraform
-
故障排查:
- 首先查看——它涵盖了大多数常见模式
/google-agents-cli-adk-code - 对ADK文档索引中的URL使用WebFetch()进行深入研究
curl https://adk.dev/llms.txt - 遇到持续错误时,针对性的网页搜索通常能更快找到解决方案
- CLI命令失败: 运行——输出末尾的
agents-cli <command> --help行指向实现该命令的精确源文件。阅读该文件以理解逻辑并诊断故障。如需浏览多个文件,请使用Source:获取完整的CLI安装路径。agents-cli info
- 首先查看
Systematic Debugging
系统化调试
When something breaks, follow this sequence — don't skip steps or shotgun fixes:
- Reproduce — Run the exact command that failed. Save the full error output. If you can't reproduce it, you can't fix it.
- Localize — Narrow the cause: is it the agent code, a tool, the config, or the environment? Use to isolate agent behavior from deployment issues.
agents-cli run "prompt" - Fix one thing — Change one variable at a time. If you change the instruction AND the tool AND the config simultaneously, you won't know what fixed it (or what broke something else).
- Verify — Rerun the exact reproduction command. Don't assume the fix worked.
- Guard — If it was a non-obvious bug, add an eval case to catch regressions.
Stop-the-line rule: If a change breaks something that was working, stop feature work and fix the regression first. Don't push forward hoping to circle back — regressions compound.
- Environment Variables:
- files and env var assignments (e.g.,
.env,GOOGLE_CLOUD_PROJECT) are typically required for the agent to function — never remove or modify them unless the user explicitly asksGOOGLE_CLOUD_LOCATION - If a file exists in the project root, treat it as essential configuration
.env - For secrets and API keys, prefer GCP Secret Manager over plain entries — see
.envfor secret management guidance/google-agents-cli-deploy
出现问题时,请遵循以下步骤——不要跳过步骤或盲目尝试修复:
- 重现问题——运行导致失败的精确命令。保存完整的错误输出。如果无法重现,就无法修复。
- 定位原因——缩小范围:是Agent代码、工具、配置还是环境的问题?使用将Agent行为与部署问题隔离开。
agents-cli run "prompt" - 单次修改一个变量——每次只更改一个变量。如果同时修改指令、工具和配置,你将无法知道是什么解决了问题(或者是什么导致了其他问题)。
- 验证修复——重新运行导致问题的精确命令。不要假设修复有效。
- 预防回归——如果是不明显的错误,请添加一个评估用例以避免回归。
停止推进规则: 如果某个更改破坏了原本正常的功能,请停止新功能开发并优先修复回归。不要继续推进并寄希望于后续再处理——回归问题会不断累积。
- 环境变量:
- 文件和环境变量赋值(例如
.env、GOOGLE_CLOUD_PROJECT)通常是Agent正常运行所必需的——除非用户明确要求,否则切勿删除或修改GOOGLE_CLOUD_LOCATION - 如果项目根目录存在文件,请将其视为关键配置
.env - 对于密钥和API密钥,优先使用GCP Secret Manager而非明文条目——请查看
.env获取密钥管理指南/google-agents-cli-deploy
Using a Temporary Scaffold as Reference
使用临时脚手架作为参考
When you need specific infrastructure files (Terraform, CI/CD, Dockerfile) but don't want to modify the current project, use to create a temporary project in and copy over what you need.
/google-agents-cli-scaffold/tmp/当你需要特定的基础设施文件(Terraform、CI/CD、Dockerfile)但不想修改当前项目时,可以使用在目录创建临时项目,然后复制所需文件。
/google-agents-cli-scaffold/tmp/Reference Files
参考文件
| File | Contents |
|---|---|
| Underlying tools and commands that |
| 文件 | 内容 |
|---|---|
| |
Development Commands
开发命令
Setup & Skills
安装配置与技能
| Command | Purpose |
|---|---|
| Install skills to coding agents |
| Install skills, skip authentication step |
| Preview what setup would do without executing |
| Reinstall/update skills to latest version |
| 命令 | 用途 |
|---|---|
| 为代码Agent安装技能 |
| 安装技能,跳过认证步骤 |
| 预览安装操作,不实际执行 |
| 重新安装/更新技能至最新版本 |
Scaffolding
脚手架搭建
| Command | Purpose |
|---|---|
| Create a new project |
| Add deployment / CI-CD to project |
| Upgrade project to newer agents-cli version |
| 命令 | 用途 |
|---|---|
| 创建新项目 |
| 为项目添加部署/CI-CD配置 |
| 将项目升级至更新的agents-cli版本 |
Development
开发
| Command | Purpose |
|---|---|
| Interactive local testing (ADK web playground) |
| Run agent with a single prompt (non-interactive) |
| Check code quality |
| Auto-fix linting issues |
| Also run mypy type checking |
| Install project dependencies (uv sync) |
| 命令 | 用途 |
|---|---|
| 交互式本地测试(ADK网页playground) |
| 使用单个请求运行Agent(非交互式) |
| 检查代码质量 |
| 自动修复代码规范问题 |
| 同时运行mypy类型检查 |
| 安装项目依赖(uv sync) |
Evaluation
评估
| Command | Purpose |
|---|---|
| Run evaluation against evalsets |
| Run a specific evalset |
| Run all evalsets |
| Compare two eval result files |
| 命令 | 用途 |
|---|---|
| 针对评估集运行评估 |
| 运行指定的评估集 |
| 运行所有评估集 |
| 比较两个评估结果文件 |
Deployment & Infrastructure
部署与基础设施
| Command | Purpose |
|---|---|
| Deploy to dev (requires human approval) |
| Provision single-project GCP infrastructure without CI/CD (Terraform, optional) |
| Set up CI/CD pipeline + staging/prod infrastructure |
| Register agent with Gemini Enterprise |
| 命令 | 用途 |
|---|---|
| 部署到开发环境(需要人工批准) |
| 配置单项目GCP基础设施(不含CI/CD,基于Terraform,可选) |
| 设置CI/CD流水线 + 预发布/生产环境基础设施 |
| 将Agent注册到Gemini Enterprise |
Project Info
项目信息
| Command | Purpose |
|---|---|
| Show CLI install path, skills location, and project config |
Use to discover the CLI install path — this is where the CLI source code lives. Read files under that path to understand CLI internals, command implementations, or template logic. The command only shows project details when run inside a generated agent project (i.e., one with in ).
agents-cli info[tool.agents-cli]pyproject.toml| 命令 | 用途 |
|---|---|
| 显示CLI安装路径、技能位置和项目配置 |
使用查看CLI安装路径——这是CLI源代码所在位置。阅读该路径下的文件以理解CLI内部逻辑、命令实现或模板逻辑。仅在生成的Agent项目(即中包含的项目)中运行该命令时,才会显示项目详情。
agents-cli infopyproject.toml[tool.agents-cli]Authentication
认证
| Command | Purpose |
|---|---|
| Authenticate with Google for ADK services ( |
| Show authentication status |
[!NOTE] When using an API key to authenticate, thecommand does not persist them automatically, it just aids in retrieving them and providing instructions on how they can be persisted.login
| 命令 | 用途 |
|---|---|
| 通过Google认证以使用ADK服务( |
| 显示认证状态 |
[!NOTE] 使用API密钥认证时,命令不会自动保存密钥,仅帮助获取密钥并提供保存说明。login
Skills Version
技能版本
Troubleshooting hint: If skills seem outdated or incomplete, reinstall:agents-cli setup --skip-authOnly do this when you suspect stale skills are causing problems.
故障排查提示: 如果技能似乎过时或不完整,请重新安装:agents-cli setup --skip-auth仅当你怀疑过期技能导致问题时才执行此操作。
Related Skills
相关技能
- — Project creation, requirements gathering, and enhancement
/google-agents-cli-scaffold - — ADK Python API quick reference and production sample agents
/google-agents-cli-adk-code - — Evaluation methodology, evalset schema, and the eval-fix loop
/google-agents-cli-eval - — Deployment targets, CI/CD pipelines, and production workflows
/google-agents-cli-deploy - — Gemini Enterprise registration
/google-agents-cli-publish - — Cloud Trace, logging, BigQuery Analytics, and third-party integrations
/google-agents-cli-observability
- — 项目创建、需求收集和升级
/google-agents-cli-scaffold - — ADK Python API快速参考和生产级示例Agent
/google-agents-cli-adk-code - — 评估方法、评估集schema和评估-修复循环
/google-agents-cli-eval - — 部署目标、CI/CD流水线和生产工作流
/google-agents-cli-deploy - — Gemini Enterprise注册
/google-agents-cli-publish - — Cloud Trace、日志、BigQuery分析和第三方集成
/google-agents-cli-observability