Skip to content

Commit 91030bd

Browse files
authored
Merge branch 'main' into upgrade-github-actions-node24
2 parents 1ce319a + ca9d1ec commit 91030bd

File tree

1,137 files changed

+48784
-8073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,137 files changed

+48784
-8073
lines changed

docs/agents/config.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Build agents with Agent Config
22

33
<div class="language-support-tag">
4-
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v1.11.0</span><span class="lst-preview">Experimental</span>
4+
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v1.11.0</span><span class="lst-java">Java v0.3.0</span><span class="lst-preview">Experimental</span>
55
</div>
66

77
The ADK Agent Config feature lets you build an ADK workflow without writing
88
code. An Agent Config uses a YAML format text file with a brief description of
99
the agent, allowing just about anyone to assemble and run an ADK agent. The
1010
following is a simple example of a basic Agent Config definition:
1111

12-
```
12+
```yaml
1313
name: assistant_agent
1414
model: gemini-2.5-flash
1515
description: A helper agent that can answer users' questions.
@@ -144,6 +144,41 @@ topic in the
144144
For more information about the ADK command line options, see the
145145
[ADK CLI reference](/adk-docs/api-reference/cli/).
146146
147+
### Run programmatically
148+
149+
You can also bypass the CLI and dynamically load and execute a configuration-based agent directly in your code. The utility loads the configuration and instantiates the proper agent class (such as `LlmAgent`) transparently as a `BaseAgent` subclass.
150+
151+
=== "Python"
152+
153+
```python
154+
import asyncio
155+
from google.adk.agents import config_agent_utils
156+
from google.adk.agents import Runner
157+
158+
async def main():
159+
# Load the agent directly from the YAML config file
160+
agent = config_agent_utils.from_config("my_agent/root_agent.yaml")
161+
# ...
162+
163+
if __name__ == "__main__":
164+
asyncio.run(main())
165+
```
166+
167+
=== "Java"
168+
169+
```java
170+
import com.google.adk.agents.BaseAgent;
171+
import com.google.adk.agents.ConfigAgentUtils;
172+
173+
public class AgentApp {
174+
public static void main(String[] args) throws Exception {
175+
// Load the agent directly from the YAML config file
176+
BaseAgent agent = ConfigAgentUtils.fromConfig("my_agent/root_agent.yaml");
177+
// ...
178+
}
179+
}
180+
```
181+
147182
## Example configs
148183
149184
This section shows examples of Agent Config files to get you started building
@@ -243,7 +278,7 @@ limitations:
243278
- **Model support:** Only Gemini models are currently supported.
244279
Integration with third-party models is in progress.
245280
- **Programming language:** The Agent Config feature currently supports
246-
only Python code for tools and other functionality requiring programming code.
281+
Python and Java code for tools and other functionality requiring programming code.
247282
- **ADK Tool support:** The following ADK tools are supported by the Agent
248283
Config feature, but *not all tools are fully supported*:
249284
- `google_search`

docs/agents/models/google-gemini.md

Lines changed: 126 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -200,37 +200,89 @@ To mitigate this, you can do one of the following:
200200
You would use this option if you are instantiating this model adapter by
201201
yourself.
202202
203-
```python
204-
root_agent = Agent(
205-
model='gemini-2.5-flash',
206-
...
207-
generate_content_config=types.GenerateContentConfig(
208-
...
209-
http_options=types.HttpOptions(
210-
...
211-
retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2),
212-
...
213-
),
214-
...
215-
)
216-
```
203+
=== "Python"
204+
205+
```python
206+
root_agent = Agent(
207+
model='gemini-2.5-flash',
208+
# ...
209+
generate_content_config=types.GenerateContentConfig(
210+
# ...
211+
http_options=types.HttpOptions(
212+
# ...
213+
retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2),
214+
# ...
215+
),
216+
# ...
217+
)
218+
```
219+
220+
=== "Java"
221+
222+
```java
223+
import com.google.adk.agents.LlmAgent;
224+
import com.google.genai.types.GenerateContentConfig;
225+
import com.google.genai.types.HttpOptions;
226+
import com.google.genai.types.HttpRetryOptions;
227+
228+
// ...
229+
230+
LlmAgent rootAgent = LlmAgent.builder()
231+
.model("gemini-2.5-flash")
232+
// ...
233+
.generateContentConfig(GenerateContentConfig.builder()
234+
// ...
235+
.httpOptions(HttpOptions.builder()
236+
// ...
237+
.retryOptions(HttpRetryOptions.builder().initialDelay(1.0).attempts(2).build())
238+
// ...
239+
.build())
240+
// ...
241+
.build())
242+
.build();
243+
```
217244
218245
**Option 2:** Retry options on this model adapter.
219246
220247
You would use this option if you were instantiating the instance of adapter
221248
by yourself.
222249
223-
```python
224-
from google.genai import types
250+
=== "Python"
225251
226-
# ...
252+
```python
253+
from google.genai import types
227254
228-
agent = Agent(
229-
model=Gemini(
230-
retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2),
255+
# ...
256+
257+
agent = Agent(
258+
model=Gemini(
259+
retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2),
260+
)
231261
)
232-
)
233-
```
262+
```
263+
264+
=== "Java"
265+
266+
```java
267+
import com.google.adk.agents.LlmAgent;
268+
import com.google.adk.models.Gemini;
269+
import com.google.genai.Client;
270+
import com.google.genai.types.HttpOptions;
271+
import com.google.genai.types.HttpRetryOptions;
272+
273+
// ...
274+
275+
LlmAgent agent = LlmAgent.builder()
276+
.model(Gemini.builder()
277+
.modelName("gemini-2.5-flash")
278+
.apiClient(Client.builder()
279+
.httpOptions(HttpOptions.builder()
280+
.retryOptions(HttpRetryOptions.builder().initialDelay(1.0).attempts(2).build())
281+
.build())
282+
.build())
283+
.build())
284+
.build();
285+
```
234286
235287
## Gemini Interactions API {#interactions-api}
236288
@@ -248,23 +300,45 @@ You can enable the Interactions API by setting the `use_interactions_api=True`
248300
parameter in the Gemini model configuration, as shown in the following code
249301
snippet:
250302
251-
```python
252-
from google.adk.agents.llm_agent import Agent
253-
from google.adk.models.google_llm import Gemini
254-
from google.adk.tools.google_search_tool import GoogleSearchTool
303+
=== "Python"
255304
256-
root_agent = Agent(
257-
model=Gemini(
258-
model="gemini-2.5-flash",
259-
use_interactions_api=True, # Enable Interactions API
260-
),
261-
name="interactions_test_agent",
262-
tools=[
263-
GoogleSearchTool(bypass_multi_tools_limit=True), # Converted to function tool
264-
get_current_weather, # Custom function tool
265-
],
266-
)
267-
```
305+
```python
306+
from google.adk.agents.llm_agent import Agent
307+
from google.adk.models.google_llm import Gemini
308+
from google.adk.tools.google_search_tool import GoogleSearchTool
309+
310+
root_agent = Agent(
311+
model=Gemini(
312+
model="gemini-2.5-flash",
313+
use_interactions_api=True, # Enable Interactions API
314+
),
315+
name="interactions_test_agent",
316+
tools=[
317+
GoogleSearchTool(bypass_multi_tools_limit=True), # Converted to function tool
318+
get_current_weather, # Custom function tool
319+
],
320+
)
321+
```
322+
323+
=== "Java"
324+
325+
```java
326+
import com.google.adk.agents.LlmAgent;
327+
import com.google.adk.models.Gemini;
328+
import com.google.adk.tools.GoogleSearchTool;
329+
330+
// Note: Interactions API support in Java ADK is currently under development.
331+
LlmAgent rootAgent = LlmAgent.builder()
332+
.model(Gemini.builder()
333+
.modelName("gemini-2.5-flash")
334+
.build())
335+
.name("interactions_test_agent")
336+
.tools(
337+
GoogleSearchTool.INSTANCE, // Search tool
338+
getCurrentWeather // Custom function tool
339+
)
340+
.build();
341+
```
268342
269343
For a complete code sample, see the
270344
[Interactions API sample](https://github.com/google/adk-python/tree/main/contributing/samples/interactions_api).
@@ -278,10 +352,20 @@ tool, within the same agent. You can work around this limitation by configuring
278352
the built-in tool to operate as a custom tool using the `bypass_multi_tools_limit`
279353
parameter:
280354
281-
```python
282-
# Use bypass_multi_tools_limit=True to convert google_search to a function tool
283-
GoogleSearchTool(bypass_multi_tools_limit=True)
284-
```
355+
=== "Python"
356+
357+
```python
358+
# Use bypass_multi_tools_limit=True to convert google_search to a function tool
359+
GoogleSearchTool(bypass_multi_tools_limit=True)
360+
```
361+
362+
=== "Java"
363+
364+
```java
365+
// Note: bypassMultiToolsLimit is Python-specific.
366+
// In Java, simply use the tool instance.
367+
GoogleSearchTool.INSTANCE;
368+
```
285369
286370
In this example, this option converts the built-in google_search to a function
287371
calling tool (via GoogleSearchAgentTool), which allows it to work alongside

0 commit comments

Comments
 (0)