Skip to content

Commit 110d1b8

Browse files
authored
Merge branch 'main' into kaz-11230736
2 parents 23fa6d6 + 30c8ba2 commit 110d1b8

35 files changed

Lines changed: 1458 additions & 65 deletions
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Go Snippets Build on PR and Schedule
16+
17+
on:
18+
# Run on pull requests targeting the main branch.
19+
pull_request:
20+
branches: [ "main" ]
21+
22+
# Run on a weekly schedule (every Sunday at 3:00 AM UTC).
23+
schedule:
24+
- cron: '0 3 * * 0'
25+
26+
jobs:
27+
# This job builds and runs the Go snippets.
28+
test:
29+
runs-on: ubuntu-latest
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
with:
35+
# Fetch the entire history to compare branches in the PR.
36+
fetch-depth: 0
37+
38+
- name: Set up Go
39+
uses: actions/setup-go@v5
40+
with:
41+
go-version: '1.22'
42+
43+
- name: Cache Go modules
44+
uses: actions/cache@v3
45+
with:
46+
path: ~/go/pkg/mod
47+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
48+
restore-keys: |
49+
${{ runner.os }}-go-
50+
51+
# --- PR-Specific Checks ---
52+
# These steps only run for pull request events.
53+
54+
- name: Find new, un-tested Go files (PR only)
55+
if: github.event_name == 'pull_request'
56+
run: |
57+
echo "Checking for any new Go files that are not in the build script..."
58+
./tools/go-snippets/check_go_snippets.sh
59+
60+
- name: Get changed Go snippet files (PR only)
61+
if: github.event_name == 'pull_request'
62+
id: changed-files
63+
run: |
64+
# This command gets the list of changed .go files in the snippets directory
65+
# between the PR's head and the base branch.
66+
# The output is an escaped, space-separated string suitable for shell commands.
67+
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} -- 'examples/go/snippets/**/*.go' | xargs)
68+
echo "changed_files=${CHANGED_FILES}" >> $GITHUB_OUTPUT
69+
echo "Detected changes in: ${CHANGED_FILES}"
70+
71+
- name: Build changed Go snippets (PR only)
72+
if: github.event_name == 'pull_request' && steps.changed-files.outputs.changed_files != ''
73+
run: |
74+
echo "Building only the changed Go files..."
75+
./tools/go-snippets/runner.sh build ${{ steps.changed-files.outputs.changed_files }}
76+
77+
# --- Scheduled Checks ---
78+
# These steps only run on the weekly schedule.
79+
80+
- name: Build all Go snippets (Scheduled)
81+
if: github.event_name == 'schedule'
82+
run: |
83+
echo "Running weekly build for all Go snippets..."
84+
./tools/go-snippets/runner.sh build

docs/agents/llm-agents.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -445,15 +445,8 @@ Control whether the agent receives the prior conversation history.
445445
....
446446
```
447447

448-
### Code Execution
449-
450-
<div class="language-support-tag">
451-
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v0.1.0</span>
452-
</div>
453-
454-
* **`code_executor` (Optional):** Provide a `BaseCodeExecutor` instance to allow the agent to execute code blocks found in the LLM's response. ([See Tools/Built-in tools](../tools/built-in-tools.md)).
455-
456448
Example for using built-in-planner:
449+
457450
```python
458451
from dotenv import load_dotenv
459452

@@ -572,6 +565,26 @@ call_agent("If it's raining in New York right now, what is the current temperatu
572565

573566
```
574567

568+
### Code Execution
569+
570+
<div class="language-support-tag">
571+
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v0.1.0</span><span class="lst-java">Java v0.1.0</span>
572+
</div>
573+
574+
- **`code_executor` (Optional):** Provide a `BaseCodeExecutor` instance to allow the agent to execute code blocks found in the LLM's response. ([See Tools/Built-in tools](../tools/built-in-tools.md)).
575+
576+
== "Python"
577+
578+
```py
579+
--8<-- "examples/python/snippets/tools/built-in-tools/code_execution.py"
580+
```
581+
582+
=== "Java"
583+
584+
```java
585+
--8<-- "examples/java/snippets/src/main/java/tools/CodeExecutionAgentApp.java:full_code"
586+
```
587+
575588
## Putting It Together: Example
576589

577590
??? "Code"

docs/agents/models.md

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public class DirectAnthropicAgent {
322322
## Using Apigee gateway for AI models
323323
324324
<div class="language-support-tag">
325-
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v1.18.0</span>
325+
<span class="lst-supported">Supported in ADK</span><span class="lst-python">Python v1.18.0</span><span class="lst-java">Java v0.4.0</span>
326326
</div>
327327
328328
[Apigee](https://docs.cloud.google.com/apigee/docs/api-platform/get-started/what-apigee) acts as a powerful [AI Gateway](https://cloud.google.com/solutions/apigee-ai), transforming how you manage and govern your generative AI model traffic. By exposing your AI model endpoint (like Vertex AI or the Gemini API) through an Apigee proxy, you immediately gain enterprise-grade capabilities:
@@ -341,30 +341,55 @@ public class DirectAnthropicAgent {
341341
342342
**Example:**
343343
344-
```python
344+
=== "Python"
345345
346-
from google.adk.agents import LlmAgent
347-
from google.adk.models.apigee_llm import ApigeeLlm
348-
349-
# Instantiate the ApigeeLlm wrapper
350-
model = ApigeeLlm(
351-
# Specify the Apigee route to your model. For more info, check out the ApigeeLlm documentation (https://github.com/google/adk-python/tree/main/contributing/samples/hello_world_apigeellm).
352-
model="apigee/gemini-2.5-flash",
353-
# The proxy URL of your deployed Apigee proxy including the base path
354-
proxy_url=f"https://{APIGEE_PROXY_URL}",
355-
# Pass necessary authentication/authorization headers (like an API key)
356-
custom_headers={"foo": "bar"}
357-
)
346+
```python
358347
359-
# Pass the configured model wrapper to your LlmAgent
360-
agent = LlmAgent(
361-
model=model,
362-
name="my_governed_agent",
363-
instruction="You are a helpful assistant powered by Gemini and governed by Apigee.",
364-
# ... other agent parameters
365-
)
348+
from google.adk.agents import LlmAgent
349+
from google.adk.models.apigee_llm import ApigeeLlm
350+
351+
# Instantiate the ApigeeLlm wrapper
352+
model = ApigeeLlm(
353+
# Specify the Apigee route to your model. For more info, check out the ApigeeLlm documentation (https://github.com/google/adk-python/tree/main/contributing/samples/hello_world_apigeellm).
354+
model="apigee/gemini-2.5-flash",
355+
# The proxy URL of your deployed Apigee proxy including the base path
356+
proxy_url=f"https://{APIGEE_PROXY_URL}",
357+
# Pass necessary authentication/authorization headers (like an API key)
358+
custom_headers={"foo": "bar"}
359+
)
366360
367-
```
361+
# Pass the configured model wrapper to your LlmAgent
362+
agent = LlmAgent(
363+
model=model,
364+
name="my_governed_agent",
365+
instruction="You are a helpful assistant powered by Gemini and governed by Apigee.",
366+
# ... other agent parameters
367+
)
368+
369+
```
370+
371+
=== "Java"
372+
373+
```java
374+
import com.google.adk.agents.LlmAgent;
375+
import com.google.adk.models.ApigeeLlm;
376+
import com.google.common.collect.ImmutableMap;
377+
378+
ApigeeLlm apigeeLlm =
379+
ApigeeLlm.builder()
380+
.modelName("apigee/gemini-2.5-flash") // Specify the Apigee route to your model. For more info, check out the ApigeeLlm documentation
381+
.proxyUrl(APIGEE_PROXY_URL) //The proxy URL of your deployed Apigee proxy including the base path
382+
.customHeaders(ImmutableMap.of("foo", "bar")) //Pass necessary authentication/authorization headers (like an API key)
383+
.build();
384+
LlmAgent agent =
385+
LlmAgent.builder()
386+
.model(apigeeLlm)
387+
.name("my_governed_agent")
388+
.description("my_governed_agent")
389+
.instruction("You are a helpful assistant powered by Gemini and governed by Apigee.")
390+
// tools will be added next
391+
.build();
392+
```
368393
369394
With this configuration, every API call from your agent will be routed through Apigee first, where all necessary policies (security, rate limiting, logging) are executed before the request is securely forwarded to the underlying AI model endpoint.
370395

docs/assets/tools-apify.png

9.67 KB
Loading

docs/assets/tools-atlassian.png

36.4 KB
Loading

docs/assets/tools-linear.png

7.96 KB
Loading

docs/context/compaction.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ of this context data grows, agent processing times typically also increase.
1010
More and more data is sent to the generative AI model used by the agent,
1111
increasing processing time and slowing down responses. The ADK Context
1212
Compaction feature is designed to reduce the size of context as an agent
13-
is running by summarizing older parts of the agent workflow event history.
13+
is running by summarizing older parts of the agent workflow event history.
1414

1515
The Context Compaction feature uses a *sliding window* approach for collecting
1616
and summarizing agent workflow event data within a
@@ -47,7 +47,7 @@ background each time the session reaches the interval.
4747
If you set `compaction_interval` to 3 and `overlap_size` to 1, the event data is
4848
compressed upon completion of events 3, 6, 9, and so on. The overlap setting
4949
increases size of the second summary compression, and each summary afterwards,
50-
as shown in Figure 1.
50+
as shown in Figure 1.
5151

5252
![Context compaction example illustration](/adk-docs/assets/context-compaction.svg)
5353
**Figure 1.** Ilustration of event compaction configuration with a interval of 3
@@ -65,19 +65,19 @@ With this example configuration, the context compression tasks happen as follows
6565

6666
The configuration settings for this feature control how frequently event data is compressed
6767
and how much data is retained as the agent workflow runs. Optionally, you can configure
68-
a compactor object
68+
a compactor object
6969

7070
* **`compaction_interval`**: Set the number of completed events that triggers compaction
71-
of the prior event data.
71+
of the prior event data.
7272
* **`overlap_size`**: Set how many of the previously compacted events are included in a
7373
newly compacted context set.
74-
* **`compactor`**: (Optional) Define a compactor object including a specific AI model
75-
to use for summarization. For more information, see
76-
[Define a compactor](#define-compactor).
74+
* **`summarizer`**: (Optional) Define a summarizer object including a specific AI model
75+
to use for summarization. For more information, see
76+
[Define a Summarizer](#define-summarizer).
7777

7878
### Define a Summarizer {#define-summarizer}
79-
You can customize the process of context compression by defining a summarizer.
80-
The LlmEventSummarizer class allows you to specify a particular model for summarization.
79+
You can customize the process of context compression by defining a summarizer.
80+
The LlmEventSummarizer class allows you to specify a particular model for summarization.
8181
The following code example demonstrates how to define and configure a custom summarizer:
8282

8383
```python
@@ -96,12 +96,12 @@ app = App(
9696
name='my-agent',
9797
root_agent=root_agent,
9898
events_compaction_config=EventsCompactionConfig(
99-
summarizer=my_summarizer,
10099
compaction_interval=3,
101-
overlap_size=1
100+
overlap_size=1,
101+
summarizer=my_summarizer,
102102
),
103103
)
104-
```
104+
```
105105

106106
You can further refine the operation of the `SlidingWindowCompactor` by
107107
by modifying its summarizer class `LlmEventSummarizer` including changing

docs/deploy/cloud-run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ To deploy your agent, you can use either the `adk deploy cloud_run` command _(re
1111

1212
## Agent sample
1313

14-
For each of the commands, we will reference a the `Capital Agent` sample defined on the [LLM agent](../agents/llm-agents.md) page. We will assume it's in a directory (eg: `capital_agent`).
14+
For each of the commands, we will reference the `Capital Agent` sample defined on the [LLM agent](../agents/llm-agents.md) page. We will assume it's in a directory (eg: `capital_agent`).
1515

1616
To proceed, confirm that your agent code is configured as follows:
1717

docs/get-started/go.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ upper left corner and type a request.
162162

163163
![adk-web-dev-ui-chat.png](/adk-docs/assets/adk-web-dev-ui-chat.png)
164164

165+
!!! warning "Caution: ADK Web for development only"
166+
167+
ADK Web is ***not meant for use in production deployments***. You should
168+
use ADK Web for development and debugging purposes only.
169+
165170
## Next: Build your agent
166171

167172
Now that you have ADK installed and your first agent running, try building

docs/get-started/java.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,11 @@ upper left corner and type a request.
268268

269269
![adk-web-dev-ui-chat.png](/adk-docs/assets/adk-web-dev-ui-chat.png)
270270

271+
!!! warning "Caution: ADK Web for development only"
272+
273+
ADK Web is ***not meant for use in production deployments***. You should
274+
use ADK Web for development and debugging purposes only.
275+
271276
## Next: Build your agent
272277

273278
Now that you have ADK installed and your first agent running, try building

0 commit comments

Comments
 (0)