agent-construction
Build and troubleshoot ADK Python Agent/LlmAgent definitions, model settings, modes, callbacks, schemas, and multi-agent delegation.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- agent-construction
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Build and troubleshoot ADK Python Agent/LlmAgent definitions, model settings, modes, callbacks, schemas, and multi-agent delegation.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md11.5 KB
- 参考文档references/troubleshooting.md9.2 KB
- 参考文档references/workflows.md11.7 KB
- 脚本scripts/inspect_agent_api.py2.5 KB
03 SKILL.md 正文
ADK Python Agent Construction
Use this sub-skill when a user asks to define, revise, or debug Python ADK agents built with google.adk.Agent or google.adk.agents.LlmAgent.
Route Here
- Create a minimal
root_agent, addmodel,instruction,description, tools, callbacks, or schemas. - Choose between
mode="chat",mode="task", andmode="single_turn"for LLM agents and sub-agents. - Build hierarchical multi-agent systems with
sub_agents, delegation descriptions,taskagents, orsingle_turnhelper agents. - Add structured input/output with Pydantic schemas,
output_schema,input_schema, andoutput_key. - Diagnose constructor validation errors, missing model credentials, callback ordering, schema/tool interactions, and sub-agent context isolation.
Route Elsewhere
- Workflow graph nodes,
Workflow,BaseNode, graph edges, dynamic nodes, joins, and workflow HITL: useworkflow-orchestration. - ADK CLI commands, YAML app loading,
adk run,adk web, deployment, and config schema generation: usecli-configuration-deployment. - Tool internals, toolsets, MCP/OpenAPI/Google API tools, auth flows, and optional integration extras: use
tools-and-integrations. - Runner services, sessions, memory, artifacts, plugins, telemetry, and code executors: use
runtime-services. - Modifying the ADK source repository itself, style, focused tests, docs, or samples: use
repo-development.
Quick Start
- Import from the public package:
from google.adk import Agentorfrom google.adk.agents import LlmAgent, RunConfig. - Name agents with valid Python identifiers; never use
useras an agent name. - Put model behavior in
instruction, static generation options ingenerate_content_config, tools intools, and final response schemas inoutput_schema. - Expose a Python app by defining
root_agent = Agent(...)in an importable module. - Use a
Runneronly after selecting runtime services and creating or auto-creating sessions; this sub-skill focuses on the agent definitions.
from google.adk import Agent
def get_weather(city: str) -> str:
"""Return a simple weather summary."""
return f"Weather for {city}: sunny."
root_agent = Agent(
name="weather_agent",
model="gemini-3.5-flash",
instruction="Answer weather questions and call tools when needed.",
tools=[get_weather],
)
References
- API reference — constructor fields, imports, validation rules, callbacks, schemas,
RunConfig, andRunner.runinvocation shape. - Workflows — recipes for minimal agents, sample app layout, callbacks, structured output,
taskandsingle_turnsub-agents, and multi-agent delegation. - Troubleshooting — fixes for generation config errors, schema/tool behavior, model credentials, branch isolation, callback order, and tool error callbacks.
- Inspection script — safe local diagnostic that prints installed ADK signatures and constructs a no-network minimal agent.
Agent-Construction Checklist
- Agent tree has unique, identifier-safe names and clear one-line
descriptionstrings for delegatable sub-agents. - Root
LlmAgentruns in chat mode;taskandsingle_turnare usually child agents exposed to the parent as tools. output_schemais used for final structured responses;generate_content_config.response_schemais not used onLlmAgent.- Tool callables have docstrings and typed parameters; deeper toolset/auth issues route to
tools-and-integrations. - Callback functions return
Noneto continue, or the documented override shape to short-circuit or replace model/tool behavior. - Model/provider credentials and optional extras are treated as deployment assumptions, not as requirements for constructing an in-memory agent object.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).