Skip to content

Commit 7a0a986

Browse files
authored
docs: Agent config docs v2 (#636)
* docs: Add Agent Config docs, v2 * fix: update mkdocs file
1 parent 2cef018 commit 7a0a986

File tree

6 files changed

+104160
-8
lines changed

6 files changed

+104160
-8
lines changed

docs/agents/config.md

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
# Build agents with Agent Config
2+
3+
The ADK Agent Config feature lets you build an ADK workflow without writing
4+
code. An Agent Config uses a YAML format text file with a brief description of
5+
the agent, allowing just about anyone to assemble and run an ADK agent. The
6+
following is a simple example of an basic Agent Config definition:
7+
8+
```
9+
name: assistant_agent
10+
model: gemini-2.5-flash
11+
description: A helper agent that can answer users' questions.
12+
instruction: You are an agent to help answer users' various questions.
13+
```
14+
15+
You can use Agent Config files to build more complex agents which can
16+
incorporate Functions, Tools, Sub-Agents, and more. This page describes how to
17+
build and run ADK workflows with the Agent Config feature. For detailed
18+
information on the syntax and settings supported by the Agent Config format,
19+
see the
20+
[Agent Config syntax reference](/adk-docs/api-reference/agentconfig/).
21+
22+
!!! example "Experimental"
23+
The Agent Config feature is experimental and has some
24+
[known limitations](#known-limitations). We welcome your
25+
[feedback](https://github.com/google/adk-python/issues/new?template=feature_request.md&labels=agent%20config)!
26+
27+
## Get started
28+
29+
This section describes how to set up and start building agents with the ADK and
30+
the Agent Config feature, including installation setup, building an agent, and
31+
running your agent.
32+
33+
### Setup
34+
35+
You need to install the Google Agent Development Kit libraries, and provide an
36+
access key for a generative AI model such as Gemini API. This section provides
37+
details on what you must install and configure before you can run agents with
38+
the Agent Config files.
39+
40+
!!! note
41+
The Agent Config feature currently only supports Gemini models. For more
42+
information about additional; functional restrictions, see [Known
43+
limitations](?tab=t.0#heading=h.xefmlyt7zh0i)
44+
45+
To setup ADK for use with Agent Config:
46+
47+
1. Install the ADK Python libraries by following the
48+
[Installation](https://google.github.io/adk-docs/get-started/installation/#python)
49+
instructions. *Python is currently required.* For more information, see the
50+
[Known limitations](?tab=t.0#heading=h.xefmlyt7zh0i).
51+
1. Verify that ADK is installed by running the following command in your
52+
terminal:
53+
54+
adk –version
55+
56+
This command should show the ADK version you have installed.
57+
58+
!!! Tip
59+
If the `adk` command fails to run and the version is not listed in step 2, make
60+
sure your Python environment is active. Execute `source .venv/bin/activate` in
61+
your terminal on Mac and Linux. For other platform commands, see the
62+
[Installation](https://google.github.io/adk-docs/get-started/installation/#python)
63+
page.
64+
65+
### Build an agent
66+
67+
You build an agent with Agent Config using the `adk create` command to create
68+
the project files for an agent, and then editing the `root_agent.yaml` file it
69+
generates for you.
70+
71+
To create an ADK project for use with Agent Config:
72+
73+
1. In your terminal window, run the following command to create a
74+
config-based agent:
75+
76+
adk create --type=config my_agent
77+
78+
This command generates a `my_agent/` folder, containing a
79+
`root_agent.yaml` file and an `.env` file.
80+
81+
1. In the `my_agent/.env` file, set environment variables for your agent to
82+
access generative AI models and other services:
83+
84+
1. For Gemini model access through Google API, add a line to the
85+
file with your API key:
86+
87+
GOOGLE_GENAI_USE_VERTEXAI=0
88+
GOOGLE_API_KEY=<your-Google-Gemini-API-key>
89+
90+
You can get an API key from the Google AI Studio
91+
[API Keys](google.com/app/apikey) page.
92+
93+
1. For Gemini model access through Google Cloud, add these lines to the file
94+
95+
GOOGLE_GENAI_USE_VERTEXAI=1
96+
GOOGLE_CLOUD_PROJECT=<your_gcp_project>
97+
GOOGLE_CLOUD_LOCATION=us-central1
98+
99+
For information on creating a Cloud Project, see the Google Cloud docs
100+
for
101+
[Creating and managing projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects).
102+
103+
1. Using text editor, edit the Agent Config file
104+
`my_agent/root_agent.yaml`, as shown below:
105+
106+
```
107+
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
108+
name: assistant_agent
109+
model: gemini-2.5-flash
110+
description: A helper agent that can answer users' questions.
111+
instruction: You are an agent to help answer users' various questions.
112+
```
113+
114+
You can discover more configuration options for your `root_agent.yaml` agent
115+
configuration file by referring to the ADK
116+
[samples repository](https://github.com/search?q=repo%3Agoogle%2Fadk-python+path%3A%2F%5Econtributing%5C%2Fsamples%5C%2F%2F+.yaml&type=code)
117+
or the
118+
[Agent Config syntax](https://google.github.io/adk-docs/api-reference/agentconfig/)
119+
reference.
120+
121+
### Run the agent
122+
123+
Once you have completed editing your Agent Config, you can run your agent using
124+
the web interface, command line terminal execution, or API server mode.
125+
126+
To run your Agent Config-defined agent:
127+
128+
1. In your terminal, navigate to the `my_agent/` directory containing the
129+
`root_agent.yaml` file.
130+
1. Type one of the following commands to run your agent:
131+
- `adk web` - Run web UI interface for your agent.
132+
- `adk run` - Run your agent in the terminal without a user
133+
interface.
134+
- `adk api_server` - Run your agent as a service that can be
135+
used by other applications.
136+
137+
For more information on the ways to run your agent, see the *Run Your Agent*
138+
topic in the
139+
[Quickstart](https://google.github.io/adk-docs/get-started/quickstart/#run-your-agent).
140+
For more information about the ADK command line options, see the [ADK CLI
141+
reference](https://google.github.io/adk-docs/api-reference/cli/).
142+
143+
## Example configs
144+
145+
This section shows examples of Agent Config files to get you started building
146+
agents. For additional and more complete examples, see the ADK
147+
[samples repository](https://github.com/search?q=repo%3Agoogle%2Fadk-python+path%3A%2F%5Econtributing%5C%2Fsamples%5C%2F%2F+root_agent.yaml&type=code).
148+
149+
### Built-in tool example
150+
151+
The following example uses a built-in ADK tool function for using google search
152+
to provide functionality to the agent. This agent automatically uses the search
153+
tool to reply to user requests.
154+
155+
```
156+
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
157+
name: search_agent
158+
model: gemini-2.0-flash
159+
description: 'an agent whose job it is to perform Google search queries and answer questions about the results.'
160+
instruction: You are an agent whose job is to perform Google search queries and answer questions about the results.
161+
tools:
162+
- name: google_search
163+
```
164+
165+
For more details, see the full code for this sample in the
166+
[ADK sample repository](https://github.com/google/adk-python/blob/main/contributing/samples/tool_builtin_config/root_agent.yaml).
167+
168+
### Custom tool example
169+
170+
The following example uses a custom tool built with Python code and listed in
171+
the `tools:` section of the config file. The agent uses this tool to check if a
172+
list of numbers provided by the user are prime numbers.
173+
174+
```
175+
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
176+
agent_class: LlmAgent
177+
model: gemini-2.5-flash
178+
name: prime_agent
179+
description: Handles checking if numbers are prime.
180+
instruction: |
181+
You are responsible for checking whether numbers are prime.
182+
When asked to check primes, you must call the check_prime tool with a list of integers.
183+
Never attempt to determine prime numbers manually.
184+
Return the prime number results to the root agent.
185+
tools:
186+
- name: ma_llm.check_prime
187+
```
188+
189+
For more details, see the full code for this sample in the
190+
[ADK sample repository](https://github.com/google/adk-python/blob/main/contributing/samples/multi_agent_llm_config/prime_agent.yaml).
191+
192+
### Sub-agents example
193+
194+
The following example shows an agent defined with two sub-agents in the
195+
`sub_agents:` section, and an example tool in the `tools:` section of the config
196+
file. This agent determines what the user wants, and delegates to one of the
197+
sub-agents to resolve the request. The sub-agents are defined using Agent Config
198+
YAML files.
199+
200+
```
201+
# yaml-language-server: $schema=https://raw.githubusercontent.com/google/adk-python/refs/heads/main/src/google/adk/agents/config_schemas/AgentConfig.json
202+
agent_class: LlmAgent
203+
model: gemini-2.5-flash
204+
name: root_agent
205+
description: Learning assistant that provides tutoring in code and math.
206+
instruction: |
207+
You are a learning assistant that helps students with coding and math questions.
208+
209+
You delegate coding questions to the code_tutor_agent and math questions to the math_tutor_agent.
210+
211+
Follow these steps:
212+
1. If the user asks about programming or coding, delegate to the code_tutor_agent.
213+
2. If the user asks about math concepts or problems, delegate to the math_tutor_agent.
214+
3. Always provide clear explanations and encourage learning.
215+
sub_agents:
216+
- config_path: code_tutor_agent.yaml
217+
- config_path: math_tutor_agent.yaml
218+
```
219+
220+
For more details, see the full code for this sample in the
221+
[ADK sample repository](https://github.com/google/adk-python/blob/main/contributing/samples/multi_agent_basic_config/root_agent.yaml).
222+
223+
## Deploy agent configs
224+
225+
You can deploy Agent Config agents with
226+
[Cloud Run](https://google.github.io/adk-docs/deploy/cloud-run/) and
227+
[Agent Engine](https://google.github.io/adk-docs/deploy/agent-engine/),
228+
using the same procedure as code-based agents. For more information on how
229+
to prepare and deploy Agent Config-based agents, see the
230+
[Cloud Run](https://google.github.io/adk-docs/deploy/cloud-run/) and
231+
[Agent Engine](https://google.github.io/adk-docs/deploy/agent-engine/)
232+
deployment guides.
233+
234+
## Known limitations {#known-limitations}
235+
236+
The Agent Config feature is experimental and includes the following
237+
limitations:
238+
239+
- **Model support:** Only Gemini models are currently supported.
240+
Integration with third-party models is in progress.
241+
- **Programming language:** The Agent Config feature currently supports
242+
only Python code for tools and other functionality requiring programming code.
243+
- **ADK Tool support:** The following ADK tools are supported by the Agent
244+
Config feature, but *not all tools are fully supported*:
245+
- `google_search`
246+
- `load_artifacts`
247+
- `url_context`
248+
- `exit_loop`
249+
- `preload_memory`
250+
- `get_user_choice`
251+
- `enterprise_web_search`
252+
- `load_web_page`: Requires a fully-qualified path to access web
253+
pages.
254+
- **Agent Type Support:** The `LangGraphAgent` and `A2aAgent` types are
255+
not yet supported.
256+
- `AgentTool`
257+
- `LongRunningFunctionTool`
258+
- `VertexAiSearchTool`
259+
- `MCPToolset`
260+
- `CrewaiTool`
261+
- `LangchainTool`
262+
- `ExampleTool`
263+
264+
## Next steps
265+
266+
For ideas on how and what to build with ADK Agent Configs, see the yaml-based
267+
agent definitions in the ADK
268+
[adk-samples](https://github.com/search?q=repo:google/adk-python+path:/%5Econtributing%5C/samples%5C//+root_agent.yaml&type=code)
269+
repository. For detailed information on the syntax and settings supported by
270+
the Agent Config format, see the
271+
[Agent Config syntax reference](https://google.github.io/adk-docs/api-reference/agentconfig/).

0 commit comments

Comments
 (0)