You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
Compare commits
310 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d809eb9d9 | |||
| f67ccf32c3 | |||
| 5115474f2b | |||
| de7c9c6509 | |||
| 9eef4464c6 | |||
| 1bfc7590b4 | |||
| 3f21a52853 | |||
| 74454170a3 | |||
| ae7d19a4c6 | |||
| 171b1145ee | |||
| 9932015f3b | |||
| 3f117391a5 | |||
| 0497fc578c | |||
| 3b5232c14f | |||
| 9e767b3fe1 | |||
| 2ad1f79422 | |||
| e278ca9541 | |||
| 9324801b75 | |||
| f592de4cc0 | |||
| 57de9634de | |||
| 729001fc0b | |||
| 0d7d7918b6 | |||
| 482099c925 | |||
| 021aaddf32 | |||
| 74b8841e62 | |||
| 186b5de826 | |||
| 03f167c1d3 | |||
| 93e8f020ed | |||
| a1ddf0b6cc | |||
| 801549f734 | |||
| f83504dffb | |||
| 11ca528090 | |||
| 76116c8008 | |||
| 939b45a1c8 | |||
| 015c667917 | |||
| 66a6f94fbc | |||
| 9e9dfa7472 | |||
| 5ee17a3268 | |||
| 370eed1c7a | |||
| 6e0ea01fcb | |||
| 2f006264ce | |||
| d0f117ebbc | |||
| dcb50effef | |||
| f384793649 | |||
| 05a853bc91 | |||
| 12507dc6cc | |||
| 755ce74550 | |||
| b72573c57d | |||
| eb076a9ee8 | |||
| fe5a5494e9 | |||
| f0e11c72ab | |||
| 770ecd8bb3 | |||
| e62e15e720 | |||
| a786f75968 | |||
| 01a21e40d0 | |||
| 69f7ed8d0e | |||
| ebfe8fe51c | |||
| cb000e5a94 | |||
| 01cf186299 | |||
| 04820cb0a7 | |||
| 509db3f9fb | |||
| 4d5760917d | |||
| d27fe90d37 | |||
| 1c23556225 | |||
| a71d9ea9a1 | |||
| fccd17df6f | |||
| 4c6820e78c | |||
| bdd678db31 | |||
| f298d07579 | |||
| c399c50be5 | |||
| 05917cabbd | |||
| 1804ca39a6 | |||
| 5b3204c356 | |||
| d161a2c3f7 | |||
| 95f994d7ca | |||
| 3ea9eca929 | |||
| 2214c1558f | |||
| 4a0751941b | |||
| 9c2358e2a5 | |||
| 3686608f8d | |||
| ada24d7171 | |||
| ee674ce0ef | |||
| 2cb74dd20e | |||
| 293f406148 | |||
| bc43a1196a | |||
| dc90c91ed1 | |||
| 22e4210b47 | |||
| b67182c50f | |||
| 71bd808a14 | |||
| b33bdb9a03 | |||
| fc40226ec0 | |||
| 14cf910ce6 | |||
| 00e0035c8a | |||
| 30947b48b8 | |||
| 825f5d4f2e | |||
| 6f00df3df0 | |||
| da55b5a943 | |||
| d046367826 | |||
| 9647426500 | |||
| 1f0fd7bfce | |||
| 66553b18c6 | |||
| 933f01b89f | |||
| d6cf660506 | |||
| 931fb338f8 | |||
| af978fe194 | |||
| 4def3f1bd3 | |||
| ff9de71869 | |||
| f6bdd555fb | |||
| cf06cc507a | |||
| 303af440ee | |||
| 82b8e304ec | |||
| 4188673b0f | |||
| 39f78dc28f | |||
| c4d5e3b298 | |||
| 08c9cf86c3 | |||
| dd8e9b71e5 | |||
| d740b93e03 | |||
| 2d84b13219 | |||
| 80813a75cf | |||
| d35b99e6dd | |||
| 722028801a | |||
| 57d1315533 | |||
| d19927b1bc | |||
| 6a04ff84ba | |||
| 27b229719e | |||
| 05a0c6b307 | |||
| df0892a7b8 | |||
| 660c2efa4d | |||
| 1237d5334f | |||
| 993f9971bb | |||
| 5462862795 | |||
| c39f24f072 | |||
| 847c8fd11a | |||
| f15f64af0f | |||
| 70a6bfae90 | |||
| 4c4cfb74ae | |||
| 812485fdfa | |||
| cdb4cac237 | |||
| 16014764b6 | |||
| 9a8c77e04a | |||
| 4c191ba6b9 | |||
| 2a0524692b | |||
| 166df01236 | |||
| c4ecef54bc | |||
| 415104743d | |||
| 33acb26565 | |||
| ac97fc638f | |||
| dc5c23c675 | |||
| 8c78945ec9 | |||
| 7dffb59096 | |||
| 4d7298e4f2 | |||
| 8963300518 | |||
| 2cbbf88135 | |||
| 0299020cc4 | |||
| 5fd6a448de | |||
| 85ccacbf2d | |||
| d45084f311 | |||
| a61d20e3df | |||
| 41564de689 | |||
| 7f76af4d76 | |||
| e7d9cf359a | |||
| cc1ef3f2ad | |||
| 26f55fb5ab | |||
| a4adb739c0 | |||
| 180c2a934b | |||
| c565473bf8 | |||
| 357143c2aa | |||
| d5b3a89fe7 | |||
| e4317c9eb7 | |||
| 794a70edcd | |||
| f96cdc675c | |||
| 1393965720 | |||
| e2ba484b43 | |||
| 28abc306c3 | |||
| fcca0afdac | |||
| 905c20dad6 | |||
| 6dec235c13 | |||
| dbea793cf5 | |||
| a930633fad | |||
| fb3915da3b | |||
| 5824c89ee4 | |||
| 97d29a1d9f | |||
| a7b4c98253 | |||
| ad4226b3d8 | |||
| 9bec05ce86 | |||
| 81aa11f070 | |||
| 6f182821c4 | |||
| 88fe4c58a0 | |||
| a6b3c23f74 | |||
| 5846b24b71 | |||
| 24024f7fc4 | |||
| c74879d849 | |||
| 6595cda037 | |||
| 60d23c028f | |||
| eff5903175 | |||
| da677b7a34 | |||
| 4289e02854 | |||
| bcf1deb582 | |||
| 879064343c | |||
| 8f94a0c7b3 | |||
| 4f48ea1c08 | |||
| 3fddac5813 | |||
| 9b52ce28f5 | |||
| e8fb4ed3fc | |||
| 42f87a9c94 | |||
| d387ab0c38 | |||
| f12300113d | |||
| 6c0a0d69ca | |||
| 23b41c3f94 | |||
| 14933ba470 | |||
| b691904e57 | |||
| 641781bced | |||
| c4e09a2edb | |||
| acbbdb7266 | |||
| 27ce65ff50 | |||
| 926b0ef1a6 | |||
| dbbeb190b0 | |||
| 2a9ddec7e3 | |||
| 2ea4315e9f | |||
| 67b6fbbe01 | |||
| fcbf57466e | |||
| 504aa6ba06 | |||
| 08ac9a117e | |||
| 4ae8d72a8d | |||
| 21736067f9 | |||
| 9a9f7a3765 | |||
| aa7a98ad9d | |||
| a5bf6e3608 | |||
| f872577f68 | |||
| e6109b1dd6 | |||
| ca993277de | |||
| a49d339251 | |||
| 04e4c85b4e | |||
| 3ad939d34c | |||
| 2062aa38a7 | |||
| db5ea6bc56 | |||
| 5c069cca8f | |||
| 22cab9e9a4 | |||
| a9da7a8fc3 | |||
| 956fb912e8 | |||
| 49d8c0fbb2 | |||
| 645402903a | |||
| c531bb6ef1 | |||
| 7cc3167e54 | |||
| 353ff50611 | |||
| bbeb6525ea | |||
| 0e9096d865 | |||
| 923d806637 | |||
| 463797be25 | |||
| dc53678606 | |||
| 21d2047ddc | |||
| a5f191650b | |||
| 1e752b1378 | |||
| 5ab43e804a | |||
| 220b327a73 | |||
| 1664b45562 | |||
| 23f0383284 | |||
| f7b436a985 | |||
| 2af777af6d | |||
| 32dc145ace | |||
| 6742ab9236 | |||
| daed456125 | |||
| 30b1722cca | |||
| 5eca8214a8 | |||
| e0a360a1a2 | |||
| 1cd61242ef | |||
| e31cd0b5f8 | |||
| dfb283e6e0 | |||
| 6e317d69de | |||
| 732059cf59 | |||
| 6b86bcc549 | |||
| 45a465e9b0 | |||
| e50c463ed4 | |||
| 995dc8276b | |||
| 2ee1c65e05 | |||
| b8514f26fe | |||
| 443bc08d2b | |||
| 27b214df3e | |||
| 61d4be2d76 | |||
| d057f2d825 | |||
| 290058eb05 | |||
| 3e85df2641 | |||
| 9a44831a08 | |||
| 4e8b944e09 | |||
| 26bab52ca8 | |||
| 577222509c | |||
| cfbcc17644 | |||
| 089c1e6428 | |||
| d810ff7b28 | |||
| e0d223d117 | |||
| 9cd802fcea | |||
| eecb9e65be | |||
| ee2a75368a | |||
| b68f3aa11f | |||
| a39977876b | |||
| 05142a07cc | |||
| 59117b9b96 | |||
| e80d0e4993 | |||
| 278b513493 | |||
| e637b4df25 | |||
| 9cbaaf378f | |||
| 924549e346 | |||
| 972620d464 | |||
| 7a34c3f5b9 | |||
| 3f30e0825d | |||
| 20a8a11e49 | |||
| 9002ace7e5 | |||
| 28837231dd | |||
| f63ec37153 | |||
| 553bede77e |
@@ -0,0 +1,35 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
** Please make sure you read the contribution guide and file the issues in the rigth place. **
|
||||
[Contribution guide.](https://google.github.io/adk-docs/contributing-guide/)
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Install '...'
|
||||
2. Run '....'
|
||||
3. Open '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Python version(python -V):
|
||||
- ADK version(pip show google-adk):
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
** Please make sure you read the contribution guide and file the issues in the rigth place. **
|
||||
[Contribution guide.](https://google.github.io/adk-docs/contributing-guide/)
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,73 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
name: Check Pyink Formatting
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'src/**/*.py'
|
||||
- 'tests/**/*.py'
|
||||
- 'pyproject.toml'
|
||||
|
||||
jobs:
|
||||
pyink-check:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
- name: Install pyink
|
||||
run: |
|
||||
pip install pyink
|
||||
|
||||
- name: Detect changed Python files
|
||||
id: detect_changes
|
||||
run: |
|
||||
git fetch origin ${{ github.base_ref }}
|
||||
CHANGED_FILES=$(git diff --diff-filter=ACMR --name-only origin/${{ github.base_ref }}...HEAD | grep -E '\.py$' || true)
|
||||
echo "CHANGED_FILES=${CHANGED_FILES}" >> $GITHUB_ENV
|
||||
|
||||
- name: Run pyink on changed files
|
||||
if: env.CHANGED_FILES != ''
|
||||
run: |
|
||||
echo "Changed Python files:"
|
||||
echo "$CHANGED_FILES"
|
||||
|
||||
# Run pyink --check
|
||||
set +e
|
||||
pyink --check --config pyproject.toml $CHANGED_FILES
|
||||
RESULT=$?
|
||||
set -e
|
||||
|
||||
if [ $RESULT -ne 0 ]; then
|
||||
echo ""
|
||||
echo "❌ Pyink formatting check failed!"
|
||||
echo "👉 To fix formatting, run locally:"
|
||||
echo ""
|
||||
echo " pyink --config pyproject.toml $CHANGED_FILES"
|
||||
echo ""
|
||||
exit $RESULT
|
||||
fi
|
||||
|
||||
- name: No changed Python files detected
|
||||
if: env.CHANGED_FILES == ''
|
||||
run: |
|
||||
echo "No Python files changed. Skipping pyink check."
|
||||
@@ -0,0 +1,54 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
name: Python Unit Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.9", "3.10", "3.11"]
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install uv
|
||||
run: curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
uv venv .venv
|
||||
source .venv/bin/activate
|
||||
uv sync --extra test --extra eval
|
||||
|
||||
- name: Run unit tests with pytest
|
||||
run: |
|
||||
source .venv/bin/activate
|
||||
pytest tests/unittests \
|
||||
--ignore=tests/unittests/artifacts/test_artifact_service.py \
|
||||
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
# Python
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
*.so
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Virtual Environment
|
||||
venv/
|
||||
ENV/
|
||||
env/
|
||||
.env
|
||||
.venv
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
.DS_Store
|
||||
|
||||
# Testing
|
||||
.coverage
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.pytest_cache/
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
logs/
|
||||
log/
|
||||
|
||||
# Local development settings
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Google Cloud specific
|
||||
.gcloudignore
|
||||
.gcloudignore.local
|
||||
|
||||
# Documentation
|
||||
docs/_build/
|
||||
site/
|
||||
|
||||
# Misc
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
*.bak
|
||||
*.tmp
|
||||
*.temp
|
||||
+199
@@ -0,0 +1,199 @@
|
||||
# Changelog
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Evaluation dataset schema is finalized with strong-type pydantic models.
|
||||
(previously saved eval file needs re-generation, for both adk eval cli and
|
||||
the eval tab in adk web UI).
|
||||
* `BuiltInCodeExecutor` (in code_executors package) replaces
|
||||
`BuiltInCodeExecutionTool` (previously in tools package).
|
||||
* All methods in services are now async, including session service, artifact
|
||||
service and memory service.
|
||||
* `list_events` and `close_session` methods are removed from session service.
|
||||
* agent.py file structure with MCP tools are now easier and simpler ([now](https://github.com/google/adk-python/blob/3b5232c14f48e1d5b170f3698d91639b079722c8/contributing/samples/mcp_stdio_server_agent/agent.py#L33) vs [before](https://github.com/google/adk-python/blob/a4adb739c0d86b9ae4587547d2653d568f6567f2/contributing/samples/mcp_agent/agent.py#L41)).
|
||||
Old format is not working anymore.
|
||||
* `Memory` schema and `MemoryService` is redesigned.
|
||||
* Mark various class attributes as private in the classes in the `tools` package.
|
||||
* Disabled session state injection if instruction provider is used.
|
||||
(so that you can have `{var_name}` in the instruction, which is required for code snippets)
|
||||
* Toolbox integration is revamped: tools/toolbox_tool.py → tools/toolbox_toolset.py.
|
||||
* Removes the experimental `remote_agent.py`. We'll redesign it and bring it back.
|
||||
|
||||
### Features
|
||||
|
||||
* Dev UI:
|
||||
* A brand new trace view for overall agent invocation.
|
||||
* A revamped evaluation tab and comparison view for checking eval results.
|
||||
* Introduced `BaseToolset` to allow dynamically add/remove tools for agents.
|
||||
* Revamped MCPToolset with the new BaseToolset interface.
|
||||
* Revamped GoogleApiTool, GoogleApiToolset and ApplicationIntegrationToolset with the new BaseToolset interface.
|
||||
* Resigned agent.py file structure when needing MCPToolset.
|
||||
* Added ToolboxToolset.
|
||||
* Redesigned strong-typed agent evaluation schema.
|
||||
* Allows users to create more cohesive eval sets.
|
||||
* Allows evals to be extended for non-text modality.
|
||||
* Allows for a structured interaction with the uber eval system.
|
||||
* Redesigned Memory schema and MemoryService interfaces.
|
||||
* Added token usage to LlmResponse.
|
||||
* Allowed specifying `--adk_version` in `adk deploy cloud_run` cli. Default is the current version.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fixed `adk deploy cloud_run` failing bug.
|
||||
* Fixed logs not being printed due to `google-auth` library.
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* Display full help text when adk cli receives invalid arguments.
|
||||
* `adk web` now binds `127.0.0.1` by default, instead of 0.0.0.0.
|
||||
* `InMemoryRunner` now takes `BaseAgent` in constructor.
|
||||
* Various docstring improvements.
|
||||
* Various UI tweaks.
|
||||
* Various bug fixes.
|
||||
* Update various contributing/samples for contributors to validate the implementation.
|
||||
|
||||
|
||||
## 0.5.0
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Updated artifact and memory service interface to be async. Agents that
|
||||
interact with these services through callbacks or tools will now need to
|
||||
adjust their invocation methods to be async (using await), or ensure calls
|
||||
are wrapped in an asynchronous executor like asyncio.run(). Any service that
|
||||
extends the base interface must also be updated.
|
||||
|
||||
### Features
|
||||
|
||||
* Introduced the ability to chain model callbacks.
|
||||
* Added support for async agent and model callbacks.
|
||||
* Added input transcription support for live/streaming.
|
||||
* Captured all agent code error and display on UI.
|
||||
* Set param required tag to False by default in openapi_tool.
|
||||
* Updated evaluation functions to be asynchronous.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Ensured a unique ID is generated for every event.
|
||||
* Fixed the issue when openapi_specparser has parameter.required as None.
|
||||
* Updated the 'type' value on the items/properties nested structures for Anthropic models to adhere to JSON schema.
|
||||
* Fix litellm error issues.
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* Regenerated API docs.
|
||||
* Created a `developer` folder and added samples.
|
||||
* Updated the contributing guide.
|
||||
* Docstring improvements, typo fixings, GitHub action to enforce code styles on formatting and imports, etc.
|
||||
|
||||
## 0.4.0
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
* Set the max size of strings in database columns. MySQL mandates that all VARCHAR-type fields must specify their lengths.
|
||||
* Extract content encode/decode logic to a shared util, resolve issues with JSON serialization, and update key length for DB table to avoid key too long issue in mysql.
|
||||
* Enhance `FunctionTool` to verify if the model is providing all the mandatory arguments.
|
||||
|
||||
### Features
|
||||
* Update ADK setup guide to improve onboarding experience.
|
||||
* feat: add ordering to recent events in database session service.
|
||||
* feat(llm_flows): support async before/after tool callbacks.
|
||||
* feat: Added --replay and --resume options to adk run cli. Check adk run --help for more details.
|
||||
* Created a new Integration Connector Tool (underlying of the ApplicationIntegrationToolSet) so that we do not force LLM to provide default value.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Don't send content with empty text to LLM.
|
||||
* Fix google search reading undefined for `renderedContent`.
|
||||
|
||||
### Miscellaneous Chores
|
||||
* Docstring improvements, typo fixings, github action to enfore code styles on formatting and imports, etc.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Auth: expose `access_token` and `refresh_token` at top level of auth
|
||||
credentials, instead of a `dict`
|
||||
([commit](https://github.com/google/adk-python/commit/956fb912e8851b139668b1ccb8db10fd252a6990)).
|
||||
|
||||
### Features
|
||||
|
||||
* Added support for running agents with MCPToolset easily on `adk web`.
|
||||
* Added `custom_metadata` field to `LlmResponse`, which can be used to tag
|
||||
LlmResponse via `after_model_callback`.
|
||||
* Added `--session_db_url` to `adk deploy cloud_run` option.
|
||||
* Many Dev UI improvements:
|
||||
* Better google search result rendering.
|
||||
* Show websocket close reason in Dev UI.
|
||||
* Better error message showing for audio/video.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fixed MCP tool json schema parsing issue.
|
||||
* Fixed issues in DatabaseSessionService that leads to crash.
|
||||
* Fixed functions.py.
|
||||
* Fixed `skip_summarization` behavior in `AgentTool`.
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* README.md improvements.
|
||||
* Various code improvements.
|
||||
* Various typo fixes.
|
||||
* Bump min version of google-genai to 1.11.0.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* Fix typo in method name in `Event`: has_trailing_code_exeuction_result --> has_trailing_code_execution_result.
|
||||
|
||||
### Features
|
||||
|
||||
* `adk` CLI:
|
||||
* Introduce `adk create` cli tool to help creating agents.
|
||||
* Adds `--verbosity` option to `adk deploy cloud_run` to show detailed cloud
|
||||
run deploy logging.
|
||||
* Improve the initialization error message for `DatabaseSessionService`.
|
||||
* Lazy loading for Google 1P tools to minimize the initial latency.
|
||||
* Support emitting state-change-only events from planners.
|
||||
* Lots of Dev UI updates, including:
|
||||
* Show planner thoughts and actions in the Dev UI.
|
||||
* Support MCP tools in Dev UI.
|
||||
(NOTE: `agent.py` interface is temp solution and is subject to change)
|
||||
* Auto-select the only app if only one app is available.
|
||||
* Show grounding links generated by Google Search Tool.
|
||||
* `.env` file is reloaded on every agent run.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* `LiteLlm`: arg parsing error and python 3.9 compatibility.
|
||||
* `DatabaseSessionService`: adds the missing fields; fixes event with empty
|
||||
content not being persisted.
|
||||
* Google API Discovery response parsing issue.
|
||||
* `load_memory_tool` rendering issue in Dev UI.
|
||||
* Markdown text overflows in Dev UI.
|
||||
|
||||
### Miscellaneous Chores
|
||||
|
||||
* Adds unit tests in Github action.
|
||||
* Improves test coverage.
|
||||
* Various typo fixes.
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Features
|
||||
|
||||
* Initial release of the Agent Development Kit (ADK).
|
||||
* Multi-agent, agent-as-workflow, and custom agent support
|
||||
* Tool authentication support
|
||||
* Rich tool support, e.g. built-in tools, google-cloud tools, third-party tools, and MCP tools
|
||||
* Rich callback support
|
||||
* Built-in code execution capability
|
||||
* Asynchronous runtime and execution
|
||||
* Session, and memory support
|
||||
* Built-in evaluation support
|
||||
* Development UI that makes local development easy
|
||||
* Deploy to Google Cloud Run, Agent Engine
|
||||
* (Experimental) Live(Bidi) audio/video agent support and Compositional Function Calling(CFC) support
|
||||
+132
-2
@@ -2,6 +2,23 @@
|
||||
|
||||
We'd love to accept your patches and contributions to this project.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Before you begin](#before-you-begin)
|
||||
- [Sign our Contributor License Agreement](#sign-our-contributor-license-agreement)
|
||||
- [Review our community guidelines](#review-our-community-guidelines)
|
||||
- [Contribution workflow](#contribution-workflow)
|
||||
- [Finding Issues to Work On](#finding-issues-to-work-on)
|
||||
- [Requirement for PRs](#requirement-for-prs)
|
||||
- [Large or Complex Changes](#large-or-complex-changes)
|
||||
- [Testing Requirements](#testing-requirements)
|
||||
- [Unit Tests](#unit-tests)
|
||||
- [End-to-End (E2E) Tests](#manual-end-to-end-e2e-tests)
|
||||
- [Documentation](#documentation)
|
||||
- [Development Setup](#development-setup)
|
||||
- [Code reviews](#code-reviews)
|
||||
|
||||
|
||||
## Before you begin
|
||||
|
||||
### Sign our Contributor License Agreement
|
||||
@@ -23,11 +40,124 @@ sign a new one.
|
||||
This project follows
|
||||
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).
|
||||
|
||||
## Contribution process
|
||||
## Contribution workflow
|
||||
|
||||
### Finding Issues to Work On
|
||||
|
||||
- Browse issues labeled **`good first issue`** (newcomer-friendly) or **`help wanted`** (general contributions).
|
||||
- For other issues, please kindly ask before contributing to avoid duplication.
|
||||
|
||||
|
||||
### Requirement for PRs
|
||||
|
||||
- All PRs, other than small documentation or typo fixes, should have a Issue assoicated. If not, please create one.
|
||||
- Small, focused PRs. Keep changes minimal—one concern per PR.
|
||||
- For bug fixes or features, please provide logs or screenshot after the fix is applied to help reviewers better understand the fix.
|
||||
- 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.
|
||||
|
||||
### Large or Complex Changes
|
||||
For substantial features or architectural revisions:
|
||||
|
||||
- Open an Issue First: Outline your proposal, including design considerations and impact.
|
||||
- Gather Feedback: Discuss with maintainers and the community to ensure alignment and avoid duplicate work
|
||||
|
||||
### Testing Requirements
|
||||
|
||||
To maintain code quality and prevent regressions, all code changes must include comprehensive tests and verifiable end-to-end (E2E) evidence.
|
||||
|
||||
|
||||
#### Unit Tests
|
||||
|
||||
Please add or update unit tests for your change. Please include a summary of passed `pytest` results.
|
||||
|
||||
Requirements for unit tests:
|
||||
|
||||
- **Coverage:** Cover new features, edge cases, error conditions, and typical use cases.
|
||||
- **Location:** Add or update tests under `tests/unittests/`, following existing naming conventions (e.g., `test_<module>_<feature>.py`).
|
||||
- **Framework:** Use `pytest`. Tests should be:
|
||||
- Fast and isolated.
|
||||
- Written clearly with descriptive names.
|
||||
- Free of external dependencies (use mocks or fixtures as needed).
|
||||
- **Quality:** Aim for high readability and maintainability; include docstrings or comments for complex scenarios.
|
||||
|
||||
#### Manual End-to-End (E2E) Tests
|
||||
|
||||
Manual E2E tests ensure integrated flows work as intended. Your tests should cover all scenarios. Sometimes, it's also good to ensure relevant functionality is not impacted.
|
||||
|
||||
Depending on your change:
|
||||
|
||||
- **ADK Web:**
|
||||
- Use the `adk web` to verify functionality.
|
||||
- Capture and attach relevant screenshots demonstrating the UI/UX changes or outputs.
|
||||
- Label screenshots clearly in your PR description.
|
||||
|
||||
- **Runner:**
|
||||
- Provide the testing setup. For example, the agent definition, and the runner setup.
|
||||
- Execute the `runner` tool to reproduce workflows.
|
||||
- Include the command used and console output showing test results.
|
||||
- Highlight sections of the log that directly relate to your change.
|
||||
|
||||
### Documentation
|
||||
|
||||
For any changes that impact user-facing documentation (guides, API reference, tutorials), please open a PR in the [adk-docs](https://github.com/google/adk-docs) repository to update relevant part before or alongside your code PR.
|
||||
|
||||
### Development Setup
|
||||
1. **Clone the repository:**
|
||||
|
||||
```shell
|
||||
git clone git@github.com:google/adk-python.git
|
||||
cd adk-python
|
||||
```
|
||||
2. **Create and activate a virtual environment:**
|
||||
|
||||
```shell
|
||||
python -m venv .venv
|
||||
```
|
||||
|
||||
```shell
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
**windows**
|
||||
```shell
|
||||
source .\.venv\Scripts\activate
|
||||
```
|
||||
|
||||
3. **Install dependencies:**
|
||||
|
||||
```shell
|
||||
pip install uv
|
||||
uv sync --all-extras
|
||||
```
|
||||
4. **Run unit tests:**
|
||||
|
||||
```shell
|
||||
uv run pytest ./tests/unittests
|
||||
```
|
||||
5. **Run pyink to format codebase:**
|
||||
|
||||
```shell
|
||||
uv run pyink --config pyproject.toml ./src
|
||||
```
|
||||
|
||||
6. **Build the package**
|
||||
```shell
|
||||
uv build
|
||||
```
|
||||
|
||||
7. **Local Testing**
|
||||
Have a simple testing folder setup as mentioned in the [quickstart](https://google.github.io/adk-docs/get-started/quickstart/)
|
||||
then install the local package with changes after building it using the below command to test the changes.
|
||||
|
||||
```shell
|
||||
uv pip install <YOUR_WHL_FILE_PATH>
|
||||
|
||||
[eg]: uv pip install <ADK_PROJECT_PATH>/dist/google_adk-0.4.0-py3-none-any.whl
|
||||
```
|
||||
|
||||
### Code reviews
|
||||
|
||||
All submissions, including submissions by project members, require review. We
|
||||
use GitHub pull requests for this purpose. Consult
|
||||
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
|
||||
information on using pull requests.
|
||||
information on using pull requests.
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
# Agent Development Kit (ADK)
|
||||
|
||||
[](LICENSE)
|
||||
[](https://github.com/google/adk-python/actions/workflows/python-unit-tests.yml)
|
||||
[](https://www.reddit.com/r/agentdevelopmentkit/)
|
||||
|
||||
<html>
|
||||
<h1 align="center">
|
||||
<img src="assets/agent-development-kit.png" width="256"/>
|
||||
</h1>
|
||||
<h2 align="center">
|
||||
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/agent-development-kit.png" width="256"/>
|
||||
</h2>
|
||||
<h3 align="center">
|
||||
An open-source, code-first Python toolkit for building, evaluating, and deploying sophisticated AI agents with flexibility and control.
|
||||
</h3>
|
||||
@@ -16,88 +18,132 @@
|
||||
</h3>
|
||||
</html>
|
||||
|
||||
The Agent Development Kit (ADK) is designed for developers seeking fine-grained control and flexibility when building advanced AI agents that are tightly integrated with services in Google Cloud. It allows you to define agent behavior, orchestration, and tool use directly in code, enabling robust debugging, versioning, and deployment anywhere – from your laptop to the cloud.
|
||||
Agent Development Kit (ADK) is a flexible and modular framework for developing and deploying AI agents. While optimized for Gemini and the Google ecosystem, ADK is model-agnostic, deployment-agnostic, and is built for compatibility with other frameworks. ADK was designed to make agent development feel more like software development, to make it easier for developers to create, deploy, and orchestrate agentic architectures that range from simple tasks to complex workflows.
|
||||
|
||||
|
||||
---
|
||||
|
||||
## ✨ Key Features
|
||||
|
||||
* **Code-First Development:** Define agents, tools, and orchestration logic for maximum control, testability, and versioning.
|
||||
* **Multi-Agent Architecture:** Build modular and scalable applications by composing multiple specialized agents in flexible hierarchies.
|
||||
* **Rich Tool Ecosystem:** Equip agents with diverse capabilities using pre-built tools, custom Python functions, API specifications, or integrating existing tools.
|
||||
* **Flexible Orchestration:** Define workflows using built-in agents for predictable pipelines, or leverage LLM-driven dynamic routing for adaptive behavior.
|
||||
* **Integrated Developer Experience:** Develop, test, and debug locally with a CLI and visual web UI.
|
||||
* **Built-in Evaluation:** Measure agent performance by evaluating response quality and step-by-step execution trajectory.
|
||||
* **Deployment Ready:** Containerize and deploy your agents anywhere – scale with Vertex AI Agent Engine, Cloud Run, or Docker.
|
||||
* **Native Streaming Support:** Build real-time, interactive experiences with native support for bidirectional streaming (text and audio).
|
||||
* **State, Memory & Artifacts:** Manage short-term conversational context, configure long-term memory, and handle file uploads/downloads.
|
||||
* **Extensibility:** Customize agent behavior deeply with callbacks and easily integrate third-party tools and services.
|
||||
- **Rich Tool Ecosystem**: Utilize pre-built tools, custom functions,
|
||||
OpenAPI specs, or integrate existing tools to give agents diverse
|
||||
capabilities, all for tight integration with the Google ecosystem.
|
||||
|
||||
- **Code-First Development**: Define agent logic, tools, and orchestration
|
||||
directly in Python for ultimate flexibility, testability, and versioning.
|
||||
|
||||
- **Modular Multi-Agent Systems**: Design scalable applications by composing
|
||||
multiple specialized agents into flexible hierarchies.
|
||||
|
||||
- **Deploy Anywhere**: Easily containerize and deploy agents on Cloud Run or
|
||||
scale seamlessly with Vertex AI Agent Engine.
|
||||
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
You can install the ADK using `pip`:
|
||||
### Stable Release (Recommended)
|
||||
|
||||
You can install the latest stable version of ADK using `pip`:
|
||||
|
||||
```bash
|
||||
pip install google-adk
|
||||
```
|
||||
|
||||
## 🏁 Getting Started
|
||||
The release cadence is weekly.
|
||||
|
||||
Create your first agent (`my_agent/agent.py`):
|
||||
This version is recommended for most users as it represents the most recent official release.
|
||||
|
||||
### Development Version
|
||||
Bug fixes and new features are merged into the main branch on GitHub first. If you need access to changes that haven't been included in an official PyPI release yet, you can install directly from the main branch:
|
||||
|
||||
```bash
|
||||
pip install git+https://github.com/google/adk-python.git@main
|
||||
```
|
||||
|
||||
Note: The development version is built directly from the latest code commits. While it includes the newest fixes and features, it may also contain experimental changes or bugs not present in the stable release. Use it primarily for testing upcoming changes or accessing critical fixes before they are officially released.
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
Explore the full documentation for detailed guides on building, evaluating, and
|
||||
deploying agents:
|
||||
|
||||
* **[Documentation](https://google.github.io/adk-docs)**
|
||||
|
||||
## 🏁 Feature Highlight
|
||||
|
||||
### Define a single agent:
|
||||
|
||||
```python
|
||||
# my_agent/agent.py
|
||||
from google.adk.agents import Agent
|
||||
from google.adk.tools import google_search
|
||||
|
||||
root_agent = Agent(
|
||||
name="search_assistant",
|
||||
model="gemini-2.0-flash-exp", # Or your preferred Gemini model
|
||||
model="gemini-2.0-flash", # Or your preferred Gemini model
|
||||
instruction="You are a helpful assistant. Answer user questions using Google Search when needed.",
|
||||
description="An assistant that can search the web.",
|
||||
tools=[google_search]
|
||||
)
|
||||
```
|
||||
|
||||
Create `my_agent/__init__.py`:
|
||||
### Define a multi-agent system:
|
||||
|
||||
Define a multi-agent system with coordinator agent, greeter agent, and task execution agent. Then ADK engine and the model will guide the agents works together to accomplish the task.
|
||||
|
||||
```python
|
||||
# my_agent/__init__.py
|
||||
from . import agent
|
||||
from google.adk.agents import LlmAgent, BaseAgent
|
||||
|
||||
# Define individual agents
|
||||
greeter = LlmAgent(name="greeter", model="gemini-2.0-flash", ...)
|
||||
task_executor = LlmAgent(name="task_executor", model="gemini-2.0-flash", ...)
|
||||
|
||||
# Create parent agent and assign children via sub_agents
|
||||
coordinator = LlmAgent(
|
||||
name="Coordinator",
|
||||
model="gemini-2.0-flash",
|
||||
description="I coordinate greetings and tasks.",
|
||||
sub_agents=[ # Assign sub_agents here
|
||||
greeter,
|
||||
task_executor
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Run it via the CLI (from the directory *containing* `my_agent`):
|
||||
### Development UI
|
||||
|
||||
A built-in development UI to help you test, evaluate, debug, and showcase your agent(s).
|
||||
|
||||
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/adk-web-dev-ui-function-call.png"/>
|
||||
|
||||
### Evaluate Agents
|
||||
|
||||
```bash
|
||||
adk run my_agent
|
||||
adk eval \
|
||||
samples_for_testing/hello_world \
|
||||
samples_for_testing/hello_world/hello_world_eval_set_001.evalset.json
|
||||
```
|
||||
|
||||
Or launch the Web UI from the folder that contains `my_agent` folder:
|
||||
## 🤖 A2A and ADK integration
|
||||
|
||||
```bash
|
||||
adk web
|
||||
```
|
||||
|
||||
For a full step-by-step guide, check out the [quickstart](https://google.github.io/adk-docs/get-started/quickstart/) or [sample agents](https://github.com/google/adk-samples).
|
||||
|
||||
## 📚 Resources
|
||||
|
||||
Explore the full documentation for detailed guides on building, evaluating, and deploying agents:
|
||||
|
||||
* **[Get Started](https://google.github.io/adk-docs/get-started/)**
|
||||
* **[Browse Sample Agents](https://github.com/google/adk-samples)**
|
||||
* **[Evaluate Agents](https://google.github.io/adk-docs/guides/evaluate-agents/)**
|
||||
* **[Deploy Agents](https://google.github.io/adk-docs/deploy/)**
|
||||
* **[API Reference](https://google.github.io/adk-docs/api-reference/)**
|
||||
For remote agent-to-agent communication, ADK integrates with the
|
||||
[A2A protocol](https://github.com/google/A2A/).
|
||||
See this [example](https://github.com/google/A2A/tree/main/samples/python/agents/google_adk)
|
||||
for how they can work together.
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our [**Contributing Guidelines**](./CONTRIBUTING.md) to get started.
|
||||
We welcome contributions from the community! Whether it's bug reports, feature requests, documentation improvements, or code contributions, please see our
|
||||
- [General contribution guideline and flow](https://google.github.io/adk-docs/contributing-guide/#questions).
|
||||
- Then if you want to contribute code, please read [Code Contributing Guidelines](./CONTRIBUTING.md) to get started.
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## Preview
|
||||
|
||||
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the [Service Specific Terms](https://cloud.google.com/terms/service-terms#1). Pre-GA features are available "as is" and might have limited support. For more information, see the [launch stage descriptions](https://cloud.google.com/products?hl=en#product-launch-stages).
|
||||
|
||||
---
|
||||
|
||||
*Happy Agent Building!*
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 413 KiB |
@@ -0,0 +1,39 @@
|
||||
# Application Integration Agent Sample
|
||||
|
||||
## Introduction
|
||||
|
||||
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.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. **Set up Integration Connection:**
|
||||
* 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.
|
||||
*
|
||||
|
||||
2. **Configure Environment Variables:**
|
||||
* Create a `.env` file in the same directory as `agent.py` (or add to your existing one).
|
||||
* Add the following variables to the `.env` file, replacing the placeholder values with your actual connection details:
|
||||
|
||||
```dotenv
|
||||
CONNECTION_NAME=<YOUR_JIRA_CONNECTION_NAME>
|
||||
CONNECTION_PROJECT=<YOUR_GOOGLE_CLOUD_PROJECT_ID>
|
||||
CONNECTION_LOCATION=<YOUR_CONNECTION_LOCATION>
|
||||
```
|
||||
|
||||
## How to Use
|
||||
|
||||
1. **Install Dependencies:** Ensure you have the necessary libraries installed (e.g., `google-adk`, `python-dotenv`).
|
||||
2. **Run the Agent:** Execute the agent script from your terminal:
|
||||
```bash
|
||||
python agent.py
|
||||
```
|
||||
3. **Interact:** Once the agent starts, you can interact with it by typing prompts related to Jira issue management.
|
||||
|
||||
## Sample Prompts
|
||||
|
||||
Here are some examples of how you can interact with the agent:
|
||||
|
||||
* `Can you list me all the issues ?`
|
||||
* `Can you list me all the projects ?`
|
||||
* `Can you create an issue: "Bug in product XYZ" in project ABC ?`
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Sample agent using Application Integration toolset."""
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from google.adk.agents.llm_agent import LlmAgent
|
||||
from google.adk.tools.application_integration_tool import ApplicationIntegrationToolset
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
connection_name = os.getenv("CONNECTION_NAME")
|
||||
connection_project = os.getenv("CONNECTION_PROJECT")
|
||||
connection_location = os.getenv("CONNECTION_LOCATION")
|
||||
|
||||
|
||||
jira_toolset = ApplicationIntegrationToolset(
|
||||
project=connection_project,
|
||||
location=connection_location,
|
||||
connection=connection_name,
|
||||
entity_operations={"Issues": [], "Projects": []},
|
||||
tool_name_prefix="jira_issue_manager",
|
||||
)
|
||||
|
||||
root_agent = LlmAgent(
|
||||
model="gemini-2.0-flash",
|
||||
name="Issue_Management_Agent",
|
||||
instruction="""
|
||||
You are an agent that helps manage issues in a JIRA instance.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
""",
|
||||
tools=[jira_toolset],
|
||||
)
|
||||
Regular → Executable
+41
@@ -0,0 +1,41 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
from google.adk import Agent
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
from google.genai import types
|
||||
|
||||
|
||||
async def log_query(tool_context: ToolContext, query: str):
|
||||
"""Roll a die with the specified number of sides."""
|
||||
await tool_context.save_artifact('query', types.Part(text=query))
|
||||
|
||||
|
||||
root_agent = Agent(
|
||||
model='gemini-2.0-flash',
|
||||
name='log_agent',
|
||||
description='Log user query.',
|
||||
instruction="""Always log the user query and reploy "kk, I've logged."
|
||||
""",
|
||||
tools=[log_query],
|
||||
generate_content_config=types.GenerateContentConfig(
|
||||
safety_settings=[
|
||||
types.SafetySetting( # avoid false alarm about rolling dice.
|
||||
category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
||||
threshold=types.HarmBlockThreshold.OFF,
|
||||
),
|
||||
]
|
||||
),
|
||||
)
|
||||
@@ -0,0 +1,51 @@
|
||||
# OAuth Sample
|
||||
|
||||
## Introduction
|
||||
|
||||
This sample tests and demos the OAuth support in ADK via two tools:
|
||||
|
||||
* 1. bigquery_datasets_list:
|
||||
|
||||
List user's datasets.
|
||||
|
||||
* 2. bigquery_datasets_get:
|
||||
Get a dataset's details.
|
||||
|
||||
* 3. bigquery_datasets_insert:
|
||||
Create a new dataset.
|
||||
|
||||
* 4. bigquery_tables_list:
|
||||
List all tables in a dataset.
|
||||
|
||||
* 5. bigquery_tables_get:
|
||||
Get a table's details.
|
||||
|
||||
* 6. bigquery_tables_insert:
|
||||
Insert a new table into a dataset.
|
||||
|
||||
## How to use
|
||||
|
||||
* 1. Follow https://developers.google.com/identity/protocols/oauth2#1.-obtain-oauth-2.0-credentials-from-the-dynamic_data.setvar.console_name. to get your client id and client secret.
|
||||
Be sure to choose "web" as your client type.
|
||||
|
||||
* 2. Configure your .env file to add two variables:
|
||||
|
||||
* GOOGLE_CLIENT_ID={your client id}
|
||||
* GOOGLE_CLIENT_SECRET={your client secret}
|
||||
|
||||
Note: done't create a separate .env , instead put it to the same .env file that stores your Vertex AI or Dev ML credentials
|
||||
|
||||
* 3. Follow https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred to add http://localhost/dev-ui to "Authorized redirect URIs".
|
||||
|
||||
Note: localhost here is just a hostname that you use to access the dev ui, replace it with the actual hostname you use to access the dev ui.
|
||||
|
||||
* 4. For 1st run, allow popup for localhost in Chrome.
|
||||
|
||||
## Sample prompt
|
||||
|
||||
* `Do I have any datasets in project sean-dev-agent ?`
|
||||
* `Do I have any tables under it ?`
|
||||
* `could you get me the details of this table ?`
|
||||
* `Can you help to create a new dataset in the same project? id : sean_test , location: us`
|
||||
* `could you show me the details of this new dataset ?`
|
||||
* `could you create a new table under this dataset ? table name : sean_test_table. column1 : name is id , type is integer, required. column2 : name is info , type is string, required. column3 : name is backup , type is string, optional.`
|
||||
@@ -0,0 +1,78 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
|
||||
from dotenv import load_dotenv
|
||||
from google.adk import Agent
|
||||
from google.adk.tools.google_api_tool import BigQueryToolset
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
# Access the variable
|
||||
oauth_client_id = os.getenv("OAUTH_CLIENT_ID")
|
||||
oauth_client_secret = os.getenv("OAUTH_CLIENT_SECRET")
|
||||
tools_to_expose = [
|
||||
"bigquery_datasets_list",
|
||||
"bigquery_datasets_get",
|
||||
"bigquery_datasets_insert",
|
||||
"bigquery_tables_list",
|
||||
"bigquery_tables_get",
|
||||
"bigquery_tables_insert",
|
||||
]
|
||||
bigquery_toolset = BigQueryToolset(
|
||||
client_id=oauth_client_id,
|
||||
client_secret=oauth_client_secret,
|
||||
tool_filter=tools_to_expose,
|
||||
)
|
||||
|
||||
root_agent = Agent(
|
||||
model="gemini-2.0-flash",
|
||||
name="bigquery_agent",
|
||||
instruction="""
|
||||
You are a helpful Google BigQuery agent that help to manage users' data on Google BigQuery.
|
||||
Use the provided tools to conduct various operations on users' data in Google BigQuery.
|
||||
|
||||
Scenario 1:
|
||||
The user wants to query their biguqery datasets
|
||||
Use bigquery_datasets_list to query user's datasets
|
||||
|
||||
Scenario 2:
|
||||
The user wants to query the details of a specific dataset
|
||||
Use bigquery_datasets_get to get a dataset's details
|
||||
|
||||
Scenario 3:
|
||||
The user wants to create a new dataset
|
||||
Use bigquery_datasets_insert to create a new dataset
|
||||
|
||||
Scenario 4:
|
||||
The user wants to query their tables in a specific dataset
|
||||
Use bigquery_tables_list to list all tables in a dataset
|
||||
|
||||
Scenario 5:
|
||||
The user wants to query the details of a specific table
|
||||
Use bigquery_tables_get to get a table's details
|
||||
|
||||
Scenario 6:
|
||||
The user wants to insert a new table into a dataset
|
||||
Use bigquery_tables_insert to insert a new table into a dataset
|
||||
|
||||
Current user:
|
||||
<User>
|
||||
{userInfo?}
|
||||
</User>
|
||||
""",
|
||||
tools=[bigquery_toolset],
|
||||
)
|
||||
Regular → Executable
Executable
+198
@@ -0,0 +1,198 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import random
|
||||
|
||||
from google.adk import Agent
|
||||
from google.adk.planners import BuiltInPlanner
|
||||
from google.adk.planners import PlanReActPlanner
|
||||
from google.adk.tools.tool_context import ToolContext
|
||||
from google.genai import types
|
||||
|
||||
|
||||
def roll_die(sides: int, tool_context: ToolContext) -> int:
|
||||
"""Roll a die and return the rolled result.
|
||||
|
||||
Args:
|
||||
sides: The integer number of sides the die has.
|
||||
|
||||
Returns:
|
||||
An integer of the result of rolling the die.
|
||||
"""
|
||||
result = random.randint(1, sides)
|
||||
if not 'rolls' in tool_context.state:
|
||||
tool_context.state['rolls'] = []
|
||||
|
||||
tool_context.state['rolls'] = tool_context.state['rolls'] + [result]
|
||||
return result
|
||||
|
||||
|
||||
async def check_prime(nums: list[int]) -> str:
|
||||
"""Check if a given list of numbers are prime.
|
||||
|
||||
Args:
|
||||
nums: The list of numbers to check.
|
||||
|
||||
Returns:
|
||||
A str indicating which number is prime.
|
||||
"""
|
||||
primes = set()
|
||||
for number in nums:
|
||||
number = int(number)
|
||||
if number <= 1:
|
||||
continue
|
||||
is_prime = True
|
||||
for i in range(2, int(number**0.5) + 1):
|
||||
if number % i == 0:
|
||||
is_prime = False
|
||||
break
|
||||
if is_prime:
|
||||
primes.add(number)
|
||||
return (
|
||||
'No prime numbers found.'
|
||||
if not primes
|
||||
else f"{', '.join(str(num) for num in primes)} are prime numbers."
|
||||
)
|
||||
|
||||
|
||||
async def before_agent_callback(callback_context):
|
||||
print('@before_agent_callback')
|
||||
return None
|
||||
|
||||
|
||||
async def after_agent_callback(callback_context):
|
||||
print('@after_agent_callback')
|
||||
return None
|
||||
|
||||
|
||||
async def before_model_callback(callback_context, llm_request):
|
||||
print('@before_model_callback')
|
||||
return None
|
||||
|
||||
|
||||
async def after_model_callback(callback_context, llm_response):
|
||||
print('@after_model_callback')
|
||||
return None
|
||||
|
||||
|
||||
def after_agent_cb1(callback_context):
|
||||
print('@after_agent_cb1')
|
||||
|
||||
|
||||
def after_agent_cb2(callback_context):
|
||||
print('@after_agent_cb2')
|
||||
# ModelContent (or Content with role set to 'model') must be returned.
|
||||
# Otherwise, the event will be excluded from the context in the next turn.
|
||||
return types.ModelContent(
|
||||
parts=[
|
||||
types.Part(
|
||||
text='(stopped) after_agent_cb2',
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def after_agent_cb3(callback_context):
|
||||
print('@after_agent_cb3')
|
||||
|
||||
|
||||
def before_agent_cb1(callback_context):
|
||||
print('@before_agent_cb1')
|
||||
|
||||
|
||||
def before_agent_cb2(callback_context):
|
||||
print('@before_agent_cb2')
|
||||
|
||||
|
||||
def before_agent_cb3(callback_context):
|
||||
print('@before_agent_cb3')
|
||||
|
||||
|
||||
def before_tool_cb1(tool, args, tool_context):
|
||||
print('@before_tool_cb1')
|
||||
|
||||
|
||||
def before_tool_cb2(tool, args, tool_context):
|
||||
print('@before_tool_cb2')
|
||||
|
||||
|
||||
def before_tool_cb3(tool, args, tool_context):
|
||||
print('@before_tool_cb3')
|
||||
|
||||
|
||||
def after_tool_cb1(tool, args, tool_context, tool_response):
|
||||
print('@after_tool_cb1')
|
||||
|
||||
|
||||
def after_tool_cb2(tool, args, tool_context, tool_response):
|
||||
print('@after_tool_cb2')
|
||||
return {'test': 'after_tool_cb2', 'response': tool_response}
|
||||
|
||||
|
||||
def after_tool_cb3(tool, args, tool_context, tool_response):
|
||||
print('@after_tool_cb3')
|
||||
|
||||
|
||||
root_agent = Agent(
|
||||
model='gemini-2.0-flash',
|
||||
name='data_processing_agent',
|
||||
description=(
|
||||
'hello world agent that can roll a dice of 8 sides and check prime'
|
||||
' numbers.'
|
||||
),
|
||||
instruction="""
|
||||
You roll dice and answer questions about the outcome of the dice rolls.
|
||||
You can roll dice of different sizes.
|
||||
You can use multiple tools in parallel by calling functions in parallel(in one request and in one round).
|
||||
It is ok to discuss previous dice roles, and comment on the dice rolls.
|
||||
When you are asked to roll a die, you must call the roll_die tool with the number of sides. Be sure to pass in an integer. Do not pass in a string.
|
||||
You should never roll a die on your own.
|
||||
When checking prime numbers, call the check_prime tool with a list of integers. Be sure to pass in a list of integers. You should never pass in a string.
|
||||
You should not check prime numbers before calling the tool.
|
||||
When you are asked to roll a die and check prime numbers, you should always make the following two function calls:
|
||||
1. You should first call the roll_die tool to get a roll. Wait for the function response before calling the check_prime tool.
|
||||
2. After you get the function response from roll_die tool, you should call the check_prime tool with the roll_die result.
|
||||
2.1 If user asks you to check primes based on previous rolls, make sure you include the previous rolls in the list.
|
||||
3. When you respond, you must include the roll_die result from step 1.
|
||||
You should always perform the previous 3 steps when asking for a roll and checking prime numbers.
|
||||
You should not rely on the previous history on prime results.
|
||||
""",
|
||||
tools=[
|
||||
roll_die,
|
||||
check_prime,
|
||||
],
|
||||
# planner=BuiltInPlanner(
|
||||
# thinking_config=types.ThinkingConfig(
|
||||
# include_thoughts=True,
|
||||
# ),
|
||||
# ),
|
||||
generate_content_config=types.GenerateContentConfig(
|
||||
safety_settings=[
|
||||
types.SafetySetting( # avoid false alarm about rolling dice.
|
||||
category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
||||
threshold=types.HarmBlockThreshold.OFF,
|
||||
),
|
||||
]
|
||||
),
|
||||
before_agent_callback=[
|
||||
before_agent_cb1,
|
||||
before_agent_cb2,
|
||||
before_agent_cb3,
|
||||
],
|
||||
after_agent_callback=[after_agent_cb1, after_agent_cb2, after_agent_cb3],
|
||||
before_model_callback=before_model_callback,
|
||||
after_model_callback=after_model_callback,
|
||||
before_tool_callback=[before_tool_cb1, before_tool_cb2, before_tool_cb3],
|
||||
after_tool_callback=[after_tool_cb1, after_tool_cb2, after_tool_cb3],
|
||||
)
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import asyncio
|
||||
import time
|
||||
import warnings
|
||||
|
||||
import agent
|
||||
from dotenv import load_dotenv
|
||||
from google.adk import Runner
|
||||
from google.adk.artifacts import InMemoryArtifactService
|
||||
from google.adk.cli.utils import logs
|
||||
from google.adk.sessions import InMemorySessionService
|
||||
from google.adk.sessions import Session
|
||||
from google.genai import types
|
||||
|
||||
load_dotenv(override=True)
|
||||
warnings.filterwarnings('ignore', category=UserWarning)
|
||||
logs.log_to_tmp_folder()
|
||||
|
||||
|
||||
async def main():
|
||||
app_name = 'my_app'
|
||||
user_id_1 = 'user1'
|
||||
session_service = InMemorySessionService()
|
||||
artifact_service = InMemoryArtifactService()
|
||||
runner = Runner(
|
||||
app_name=app_name,
|
||||
agent=agent.root_agent,
|
||||
artifact_service=artifact_service,
|
||||
session_service=session_service,
|
||||
)
|
||||
session_11 = await session_service.create_session(
|
||||
app_name=app_name, user_id=user_id_1
|
||||
)
|
||||
|
||||
async def run_prompt(session: Session, new_message: str):
|
||||
content = types.Content(
|
||||
role='user', parts=[types.Part.from_text(text=new_message)]
|
||||
)
|
||||
print('** User says:', content.model_dump(exclude_none=True))
|
||||
async for event in runner.run_async(
|
||||
user_id=user_id_1,
|
||||
session_id=session.id,
|
||||
new_message=content,
|
||||
):
|
||||
if event.content.parts and event.content.parts[0].text:
|
||||
print(f'** {event.author}: {event.content.parts[0].text}')
|
||||
|
||||
start_time = time.time()
|
||||
print('Start time:', start_time)
|
||||
print('------------------------------------')
|
||||
await run_prompt(session_11, 'Hi')
|
||||
await run_prompt(session_11, 'Roll a die with 100 sides')
|
||||
await run_prompt(session_11, 'Roll a die again with 100 sides.')
|
||||
await run_prompt(session_11, 'What numbers did I got?')
|
||||
print(
|
||||
await artifact_service.list_artifact_keys(
|
||||
app_name=app_name, user_id=user_id_1, session_id=session_11.id
|
||||
)
|
||||
)
|
||||
end_time = time.time()
|
||||
print('------------------------------------')
|
||||
print('End time:', end_time)
|
||||
print('Total time:', end_time - start_time)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user