Skip to content

Commit a4ac50a

Browse files
authored
Merge branch 'main' into raflFaisal/generaliseContainerEnvForAgent
2 parents 74642ff + 1601476 commit a4ac50a

File tree

96 files changed

+5250
-892
lines changed

Some content is hidden

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

96 files changed

+5250
-892
lines changed

.github/workflows/pyink.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
name: Check Pyink Formatting
216

317
on:

.github/workflows/python-unit-tests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
name: Python Unit Tests
216

317
on:

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
# Changelog
22

3+
## 0.5.0
4+
5+
### ⚠ BREAKING CHANGES
6+
7+
* Updated artifact and memory service interface to be async. Agents that
8+
interact with these services through callbacks or tools will now need to
9+
adjust their invocation methods to be async (using await), or ensure calls
10+
are wrapped in an asynchronous executor like asyncio.run(). Any service that
11+
extends the base interface must also be updated.
12+
13+
### Features
14+
15+
* Introduced the ability to chain model callbacks.
16+
* Added support for async agent and model callbacks.
17+
* Added input transcription support for live/streaming.
18+
* Captured all agent code error and display on UI.
19+
* Set param required tag to False by default in openapi_tool.
20+
* Updated evaluation functions to be asynchronous.
21+
22+
### Bug Fixes
23+
24+
* Ensured a unique ID is generated for every event.
25+
* Fixed the issue when openapi_specparser has parameter.required as None.
26+
* Updated the 'type' value on the items/properties nested structures for Anthropic models to adhere to JSON schema.
27+
* Fix litellm error issues.
28+
29+
### Miscellaneous Chores
30+
31+
* Regenerated API docs.
32+
* Created a `developer` folder and added samples.
33+
* Updated the contributing guide.
34+
* Docstring improvements, typo fixings, GitHub action to enforce code styles on formatting and imports, etc.
35+
336
## 0.4.0
437

538
### ⚠ BREAKING CHANGES

CONTRIBUTING.md

Lines changed: 51 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ We'd love to accept your patches and contributions to this project.
44

55
## Table of Contents
66

7-
- [Before you begin](#before-you-begin)
8-
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
7+
- [Before you begin](#before-you-begin)
8+
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
99
- [Review our community guidelines](#review-our-community-guidelines)
10-
- [Contribution workflow](#contribution-workflow)
11-
- [Finding Issues to Work On](#finding-issues-to-work-on)
12-
- [Requirement for PRs](#requirement-for-prs)
13-
- [Large or Complex Changes](#large-or-complex-changes)
14-
- [Testing Requirements](#testing-requirements)
15-
- [Unit Tests](#unit-tests)
16-
- [End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
17-
- [Documentation](#documentation)
18-
- [Development Setup](#development-setup)
10+
- [Contribution workflow](#contribution-workflow)
11+
- [Finding Issues to Work On](#finding-issues-to-work-on)
12+
- [Requirement for PRs](#requirement-for-prs)
13+
- [Large or Complex Changes](#large-or-complex-changes)
14+
- [Testing Requirements](#testing-requirements)
15+
- [Unit Tests](#unit-tests)
16+
- [End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
17+
- [Documentation](#documentation)
18+
- [Development Setup](#development-setup)
1919
- [Code reviews](#code-reviews)
2020

21-
21+
2222
## Before you begin
2323

2424
### Sign our Contributor License Agreement
@@ -44,13 +44,13 @@ This project follows
4444

4545
### Finding Issues to Work On
4646

47-
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help wanted`** (general contributions).
47+
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help wanted`** (general contributions).
4848
- For other issues, please kindly ask before contributing to avoid duplication.
4949

5050

5151
### Requirement for PRs
5252

53-
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
53+
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
5454
- Small, focused PRs. Keep changes minimal—one concern per PR.
5555
- For bug fixes or features, please provide logs or screenshot after the fix is applied to help reviewers better understand the fix.
5656
- Please include a `testing plan` section in your PR to talk about how you will test. This will save time for PR review. See `Testing Requirements` section for more details.
@@ -72,12 +72,12 @@ Please add or update unit tests for your change. Please include a summary of pas
7272

7373
Requirements for unit tests:
7474

75-
- **Coverage:** Cover new features, edge cases, error conditions, and typical use cases.
76-
- **Location:** Add or update tests under `tests/unittests/`, following existing naming conventions (e.g., `test_<module>_<feature>.py`).
77-
- **Framework:** Use `pytest`. Tests should be:
78-
- Fast and isolated.
79-
- Written clearly with descriptive names.
80-
- Free of external dependencies (use mocks or fixtures as needed).
75+
- **Coverage:** Cover new features, edge cases, error conditions, and typical use cases.
76+
- **Location:** Add or update tests under `tests/unittests/`, following existing naming conventions (e.g., `test_<module>_<feature>.py`).
77+
- **Framework:** Use `pytest`. Tests should be:
78+
- Fast and isolated.
79+
- Written clearly with descriptive names.
80+
- Free of external dependencies (use mocks or fixtures as needed).
8181
- **Quality:** Aim for high readability and maintainability; include docstrings or comments for complex scenarios.
8282

8383
#### Manual End-to-End (E2E) Tests
@@ -86,15 +86,15 @@ Manual E2E tests ensure integrated flows work as intended. Your tests should cov
8686

8787
Depending on your change:
8888

89-
- **ADK Web:**
90-
- Use the `adk web` to verify functionality.
91-
- Capture and attach relevant screenshots demonstrating the UI/UX changes or outputs.
89+
- **ADK Web:**
90+
- Use the `adk web` to verify functionality.
91+
- Capture and attach relevant screenshots demonstrating the UI/UX changes or outputs.
9292
- Label screenshots clearly in your PR description.
9393

9494
- **Runner:**
9595
- Provide the testing setup. For example, the agent definition, and the runner setup.
96-
- Execute the `runner` tool to reproduce workflows.
97-
- Include the command used and console output showing test results.
96+
- Execute the `runner` tool to reproduce workflows.
97+
- Include the command used and console output showing test results.
9898
- Highlight sections of the log that directly relate to your change.
9999

100100
### Documentation
@@ -112,13 +112,21 @@ For any changes that impact user-facing documentation (guides, API reference, tu
112112

113113
```shell
114114
python -m venv .venv
115+
```
116+
117+
```shell
115118
source .venv/bin/activate
116-
pip install uv
119+
```
120+
121+
**windows**
122+
```shell
123+
source .\.venv\Scripts\activate
117124
```
118125

119126
3. **Install dependencies:**
120127

121128
```shell
129+
pip install uv
122130
uv sync --all-extras
123131
```
124132
4. **Run unit tests:**
@@ -131,8 +139,23 @@ For any changes that impact user-facing documentation (guides, API reference, tu
131139
```shell
132140
uv run pyink --config pyproject.toml ./src
133141
```
134-
135-
## Code reviews
142+
143+
6. **Build the package**
144+
```shell
145+
uv build
146+
```
147+
148+
7. **Local Testing**
149+
Have a simple testing folder setup as mentioned in the [quickstart](https://google.github.io/adk-docs/get-started/quickstart/)
150+
then install the local package with changes after building it using the below command to test the changes.
151+
152+
```shell
153+
uv pip install <YOUR_WHL_FILE_PATH>
154+
155+
[eg]: uv pip install <ADK_PROJECT_PATH>/dist/google_adk-0.4.0-py3-none-any.whl
156+
```
157+
158+
### Code reviews
136159

137160
All submissions, including submissions by project members, require review. We
138161
use GitHub pull requests for this purpose. Consult
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Application Integration Agent Sample
2+
3+
## Introduction
4+
5+
This sample demonstrates how to use the `ApplicationIntegrationToolset` within an ADK agent to interact with external applications, specifically Jira in this case. The agent (`agent.py`) is configured to manage Jira issues using a pre-configured Application Integration connection.
6+
7+
## Prerequisites
8+
9+
1. **Set up Integration Connection:**
10+
* You need an existing [Integration connection](https://cloud.google.com/integration-connectors/docs/overview) configured to interact with your Jira instance. Follow the [documentation](https://google.github.io/adk-docs/tools/google-cloud-tools/#use-integration-connectors) to provision the Integration Connector in Google Cloud and then use this [documentation](https://cloud.google.com/integration-connectors/docs/connectors/jiracloud/configure) to create an JIRA connection. Note the `Connection Name`, `Project ID`, and `Location` of your connection.
11+
*
12+
13+
2. **Configure Environment Variables:**
14+
* Create a `.env` file in the same directory as `agent.py` (or add to your existing one).
15+
* Add the following variables to the `.env` file, replacing the placeholder values with your actual connection details:
16+
17+
```dotenv
18+
CONNECTION_NAME=<YOUR_JIRA_CONNECTION_NAME>
19+
CONNECTION_PROJECT=<YOUR_GOOGLE_CLOUD_PROJECT_ID>
20+
CONNECTION_LOCATION=<YOUR_CONNECTION_LOCATION>
21+
```
22+
23+
## How to Use
24+
25+
1. **Install Dependencies:** Ensure you have the necessary libraries installed (e.g., `google-adk`, `python-dotenv`).
26+
2. **Run the Agent:** Execute the agent script from your terminal:
27+
```bash
28+
python agent.py
29+
```
30+
3. **Interact:** Once the agent starts, you can interact with it by typing prompts related to Jira issue management.
31+
32+
## Sample Prompts
33+
34+
Here are some examples of how you can interact with the agent:
35+
36+
* `Can you list me all the issues ?`
37+
* `Can you list me all the projects ?`
38+
* `Can you create an issue: "Bug in product XYZ" in project ABC ?`
39+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
from . import agent
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
"""Sample agent using Application Integration toolset."""
16+
17+
import os
18+
19+
from dotenv import load_dotenv
20+
from google.adk.agents.llm_agent import LlmAgent
21+
from google.adk.tools.application_integration_tool import ApplicationIntegrationToolset
22+
23+
24+
# Load environment variables from .env file
25+
load_dotenv()
26+
27+
connection_name = os.getenv("CONNECTION_NAME")
28+
connection_project = os.getenv("CONNECTION_PROJECT")
29+
connection_location = os.getenv("CONNECTION_LOCATION")
30+
31+
32+
jira_tool = ApplicationIntegrationToolset(
33+
project=connection_project,
34+
location=connection_location,
35+
connection=connection_name,
36+
entity_operations={"Issues": [], "Projects": []},
37+
tool_name="jira_issue_manager",
38+
)
39+
40+
root_agent = LlmAgent(
41+
model="gemini-2.0-flash",
42+
name="Issue_Management_Agent",
43+
instruction="""
44+
You are an agent that helps manage issues in a JIRA instance.
45+
Be accurate in your responses based on the tool response. You can perform any formatting in the response that is appropriate or if asked by the user.
46+
If there is an error in the tool response, understand the error and try and see if you can fix the error and then and execute the tool again. For example if a variable or parameter is missing, try and see if you can find it in the request or user query or default it and then execute the tool again or check for other tools that could give you the details.
47+
If there are any math operations like count or max, min in the user request, call the tool to get the data and perform the math operations and then return the result in the response. For example for maximum, fetch the list and then do the math operation.
48+
""",
49+
tools=jira_tool.get_tools(),
50+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
from . import agent
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
16+
from google.adk import Agent
17+
from google.adk.tools.tool_context import ToolContext
18+
from google.genai import types
19+
20+
21+
async def log_query(tool_context: ToolContext, query: str):
22+
"""Roll a die with the specified number of sides."""
23+
await tool_context.save_artifact('query', types.Part(text=query))
24+
25+
26+
root_agent = Agent(
27+
model='gemini-2.0-flash-exp',
28+
name='log_agent',
29+
description='Log user query.',
30+
instruction="""Always log the user query and reploy "kk, I've logged."
31+
""",
32+
tools=[log_query],
33+
generate_content_config=types.GenerateContentConfig(
34+
safety_settings=[
35+
types.SafetySetting( # avoid false alarm about rolling dice.
36+
category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
37+
threshold=types.HarmBlockThreshold.OFF,
38+
),
39+
]
40+
),
41+
)

0 commit comments

Comments
 (0)