Compare commits

...

35 Commits

Author SHA1 Message Date
Yifan Wang a5bf6e3608 ADK changes
PiperOrigin-RevId: 751099184
2025-04-24 12:48:31 -07:00
Ankur Sharma f872577f68 Currently if a model calls a FunctionTool without all the mandatory parameters, the code will just break. This change basically adds the capability for the FunctionTool to identify if the model is missing required arguments, and in that case, instead of breaking the execution, it provides a error message to the model so it could fix the request and retry.
PiperOrigin-RevId: 751023475
2025-04-24 09:31:40 -07:00
Wei Sun (Jack) e6109b1dd6 Copybara import of the project:
--
005028831b2e0873414db62af9ec02ef47a670d2 by Wei Sun (Jack) <weisun@google.com>:

Excludes tests/unittests/tools/application_integration_tool/clients/test_connections_client.py from python-unit-tests.yml
--
42ed38ff814f1a4811468d78cf1872869279919d by Wei Sun (Jack) <weisun@google.com>:

reorder skipped tests in python-unit-tests.yml

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/368 from google:fix-unittests 42ed38ff814f1a4811468d78cf1872869279919d
PiperOrigin-RevId: 750782234
2025-04-23 17:35:34 -07:00
Google Team Member ca993277de ADK changes
PiperOrigin-RevId: 750763037
2025-04-23 16:28:57 -07:00
Wei Sun a49d339251 bump version number to 0.3.0.
PiperOrigin-RevId: 750661619
2025-04-23 11:22:54 -07:00
Wei Sun (Jack) 04e4c85b4e Merge pull request #355 from wyf7107/live-error-toast
fix: Add error toast message when live does not work with certain models
2025-04-22 22:26:38 -07:00
Yifan 3ad939d34c Copybara import of the project:
--
dc53678606 by Yifan Wang <wanyif@google.com>:

Update Google Search Tool display to the correct one

--
bbeb6525ea by Yifan Wang <wanyif@google.com>:

add license header to complied js file

--
db5ea6bc56 by Yifan Wang <wanyif@google.com>:

fix: Enable error toast when live does not work with certain models
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/355 from wyf7107:live-error-toast 2062aa38a7
PiperOrigin-RevId: 750449832
2025-04-22 22:09:59 -07:00
Yifan 2062aa38a7 Merge branch 'main' into live-error-toast 2025-04-22 21:19:43 -07:00
Yifan Wang db5ea6bc56 fix: Enable error toast when live does not work with certain models 2025-04-22 21:16:20 -07:00
Hangfei Lin 5c069cca8f chore: Update README.md (#353)
add instruction about our releases.
2025-04-22 18:18:44 -07:00
Hangfei Lin 22cab9e9a4 chore: Update README.md (#328)
* chore: Update README.md

chore: update readme for contributing guideline

* chore: Update CONTRIBUTING.md

chore: Update CONTRIBUTING.md

* Update CONTRIBUTING.md
2025-04-22 17:20:24 -07:00
Shangjie Chen a9da7a8fc3 feat: Add session_db_url to adk deploy option.
PiperOrigin-RevId: 750355535
2025-04-22 15:53:09 -07:00
Xiang (Sean) Zhou 956fb912e8 feat(auth)!: expose access_token and refresh_token at top level of auth credentails
BREAKING CHANGE: `token` attribute of OAuth2Auth credentials used to be a dict containing both access_token and refresh_token, given that may cause confusions, now we replace it with access_token and refresh_token at top level of the auth credentials

PiperOrigin-RevId: 750346172
2025-04-22 15:23:21 -07:00
Wei Sun 49d8c0fbb2 bump min version of google-genai sdk to latest.
PiperOrigin-RevId: 750324961
2025-04-22 14:17:27 -07:00
Yifan Wang 645402903a ADK changes
PiperOrigin-RevId: 750287732
2025-04-22 12:32:01 -07:00
Yifan c531bb6ef1 Merge branch 'main' into google-search-display 2025-04-22 12:18:57 -07:00
Yifan 7cc3167e54 Copybara import of the project:
--
dc53678606 by Yifan Wang <wanyif@google.com>:

Update Google Search Tool display to the correct one

--
bbeb6525ea by Yifan Wang <wanyif@google.com>:

add license header to complied js file

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/325 from wyf7107:google-search-display 353ff50611
PiperOrigin-RevId: 750284170
2025-04-22 12:17:25 -07:00
Yifan 353ff50611 Merge branch 'main' into google-search-display 2025-04-22 11:30:38 -07:00
Yifan Wang bbeb6525ea add license header to complied js file 2025-04-22 11:21:22 -07:00
Vignesh Iyer 0e9096d865 chore: add support for overriding skip_summarization in AgentTool (#324) 2025-04-22 09:41:31 -07:00
Vignesh Iyer 923d806637 Copybara import of the project:
--
94c7f9579c56cb20252fd61b5fe568f73d864679 by Vignesh Iyer <vgnshiyer@gmail.com>:

chore: add support for overriding `skip_summarization` in AgentTool
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/324 from vgnshiyer:main 94c7f9579c56cb20252fd61b5fe568f73d864679
PiperOrigin-RevId: 750060638
2025-04-21 23:24:25 -07:00
Yifan 463797be25 Merge branch 'main' into google-search-display 2025-04-21 20:53:06 -07:00
Yifan Wang dc53678606 Update Google Search Tool display to the correct one 2025-04-21 20:50:26 -07:00
Che Liu 21d2047ddc ADK changes
PiperOrigin-RevId: 749973427
2025-04-21 17:28:53 -07:00
Wei Sun a5f191650b chore: update the readme for a2a integration.
PiperOrigin-RevId: 749856734
2025-04-21 11:17:04 -07:00
Wei Sun 1e752b1378 chore: Fixes type hints in google_api_tool_set.py.
PiperOrigin-RevId: 749844560
2025-04-21 10:42:48 -07:00
Hangfei Lin 5ab43e804a chore: update the readme for a2a integration (#319)
chore: update the readme for a2a integration
2025-04-21 09:55:30 -07:00
Nilanjan De 220b327a73 chore: fix typos (#272)
Co-authored-by: Hangfei Lin <hangfei@google.com>
2025-04-21 09:26:02 -07:00
Nilanjan De 1664b45562 Copybara import of the project:
--
16994cb2d5d646341f5285ca71d72697d81d18fe by Nilanjan De <nilanjan.de@gmail.com>:

chore: fix typos
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/272 from n1lanjan:fix-typos a1ab655b08ec08c5dd2da71aab9a2386e3610e84
PiperOrigin-RevId: 749690489
2025-04-20 22:53:15 -07:00
Hangfei Lin 23f0383284 fix: The previous commit has a merge conflict. Fix it by adding this back.
The previous commit has a merge conflict. Fix it by adding this back.
2025-04-20 17:08:25 -07:00
Hangfei Lin f7b436a985 No public description
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/282 from hangfei:main 7b9c5e3bff76ed475fb57d45333a9ab135cac32d
PiperOrigin-RevId: 749616712
2025-04-20 16:05:06 -07:00
Wei Sun 2af777af6d No public description
PiperOrigin-RevId: 749409258
2025-04-19 16:34:44 -07:00
Shangjie Chen 32dc145ace No public description
PiperOrigin-RevId: 749399264
2025-04-19 15:16:19 -07:00
Wei Sun 6742ab9236 No public description
PiperOrigin-RevId: 749202950
2025-04-18 18:08:03 -07:00
Rasheedat atinuke jamiu daed456125 Fix AttributeError in run_live when using AgentTool (#274)
Co-authored-by: Hangfei Lin <hangfei@google.com>
2025-04-18 13:37:17 -07:00
48 changed files with 1109 additions and 281 deletions
+4 -2
View File
@@ -35,5 +35,7 @@ jobs:
run: |
source .venv/bin/activate
pytest tests/unittests \
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py \
--ignore=tests/unittests/artifacts/test_artifact_service.py
--ignore=tests/unittests/artifacts/test_artifact_service.py \
--ignore=tests/unittests/tools/application_integration_tool/clients/test_connections_client.py \
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py
+35 -2
View File
@@ -1,5 +1,38 @@
# Changelog
## 0.3.0
### âš  BREAKING CHANGES
* Auth: expose `access_token` and `refresh_token` at top level of auth
credentails, 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 impprovements.
* Various code improvements.
* Various typo fixes.
* Bump min version of google-genai to 1.11.0.
## 0.2.0
### âš  BREAKING CHANGES
@@ -45,12 +78,12 @@
* 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. bult-in tools, google-cloud tools, third-party tools, and MCP tools
* 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 devlopment easy
* Development UI that makes local development easy
* Deploy to Google Cloud Run, Agent Engine
* (Experimental) Live(Bidi) auido/video agent support and Compositional Function Calling(CFC) support
+14 -1
View File
@@ -25,9 +25,22 @@ This project follows
## Contribution process
### 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 add corresponding testing for your code change if it's not covered by existing tests.
### 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
### 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.
+25 -2
View File
@@ -45,12 +45,27 @@ debugging, versioning, and deployment anywhere – from your laptop to the cloud
## 🚀 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
```
The release cadence is weekly.
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
@@ -112,10 +127,18 @@ adk eval \
samples_for_testing/hello_world/hello_world_eval_set_001.evalset.json
```
## 🤖 A2A and ADK integration
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
+1 -1
View File
@@ -45,7 +45,7 @@ confidence=
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
+1 -1
View File
@@ -33,7 +33,7 @@ dependencies = [
"google-cloud-secret-manager>=2.22.0", # Fetching secrets in RestAPI Tool
"google-cloud-speech>=2.30.0", # For Audo Transcription
"google-cloud-storage>=2.18.0, <3.0.0", # For GCS Artifact service
"google-genai>=1.9.0", # Google GenAI SDK
"google-genai>=1.11.0", # Google GenAI SDK
"graphviz>=0.20.2", # Graphviz for graph rendering
"mcp>=1.5.0;python_version>='3.10'", # For MCP Toolset
"opentelemetry-api>=1.31.0", # OpenTelemetry
@@ -23,7 +23,6 @@ from .readonly_context import ReadonlyContext
if TYPE_CHECKING:
from google.genai import types
from ..events.event import Event
from ..events.event_actions import EventActions
from ..sessions.state import State
from .invocation_context import InvocationContext
+2 -1
View File
@@ -66,7 +66,8 @@ class OAuth2Auth(BaseModelWithConfig):
redirect_uri: Optional[str] = None
auth_response_uri: Optional[str] = None
auth_code: Optional[str] = None
token: Optional[Dict[str, Any]] = None
access_token: Optional[str] = None
refresh_token: Optional[str] = None
class ServiceAccountCredential(BaseModelWithConfig):
+7 -3
View File
@@ -82,7 +82,8 @@ class AuthHandler:
or not auth_credential.oauth2
or not auth_credential.oauth2.client_id
or not auth_credential.oauth2.client_secret
or auth_credential.oauth2.token
or auth_credential.oauth2.access_token
or auth_credential.oauth2.refresh_token
):
return self.auth_config.exchanged_auth_credential
@@ -93,7 +94,7 @@ class AuthHandler:
redirect_uri=auth_credential.oauth2.redirect_uri,
state=auth_credential.oauth2.state,
)
token = client.fetch_token(
tokens = client.fetch_token(
token_endpoint,
authorization_response=auth_credential.oauth2.auth_response_uri,
code=auth_credential.oauth2.auth_code,
@@ -102,7 +103,10 @@ class AuthHandler:
updated_credential = AuthCredential(
auth_type=AuthCredentialTypes.OAUTH2,
oauth2=OAuth2Auth(token=dict(token)),
oauth2=OAuth2Auth(
access_token=tokens.get("access_token"),
refresh_token=tokens.get("refresh_token"),
),
)
return updated_credential
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+6 -1
View File
@@ -54,7 +54,7 @@ COPY "agents/{app_name}/" "/app/agents/{app_name}/"
EXPOSE {port}
CMD adk {command} --port={port} {trace_to_cloud_option} "/app/agents"
CMD adk {command} --port={port} {session_db_option} {trace_to_cloud_option} "/app/agents"
"""
@@ -85,6 +85,7 @@ def to_cloud_run(
trace_to_cloud: bool,
with_ui: bool,
verbosity: str,
session_db_url: str,
):
"""Deploys an agent to Google Cloud Run.
@@ -112,6 +113,7 @@ def to_cloud_run(
trace_to_cloud: Whether to enable Cloud Trace.
with_ui: Whether to deploy with UI.
verbosity: The verbosity level of the CLI.
session_db_url: The database URL to connect the session.
"""
app_name = app_name or os.path.basename(agent_folder)
@@ -144,6 +146,9 @@ def to_cloud_run(
port=port,
command='web' if with_ui else 'api_server',
install_agent_deps=install_agent_deps,
session_db_option=f'--session_db_url={session_db_url}'
if session_db_url
else '',
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
)
dockerfile_path = os.path.join(temp_folder, 'Dockerfile')
+1 -1
View File
@@ -256,7 +256,7 @@ def run_evals(
)
if final_eval_status == EvalStatus.PASSED:
result = "âś… Passsed"
result = "âś… Passed"
else:
result = "❌ Failed"
+28 -12
View File
@@ -245,12 +245,13 @@ def cli_eval(
@click.option(
"--session_db_url",
help=(
"Optional. The database URL to store the session.\n\n - Use"
" 'agentengine://<agent_engine_resource_id>' to connect to Vertex"
" managed session service.\n\n - Use 'sqlite://<path_to_sqlite_file>'"
" to connect to a SQLite DB.\n\n - See"
" https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls"
" for more details on supported DB URLs."
"""Optional. The database URL to store the session.
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
),
)
@click.option(
@@ -366,12 +367,13 @@ def cli_web(
@click.option(
"--session_db_url",
help=(
"Optional. The database URL to store the session.\n\n - Use"
" 'agentengine://<agent_engine_resource_id>' to connect to Vertex"
" managed session service.\n\n - Use 'sqlite://<path_to_sqlite_file>'"
" to connect to a SQLite DB.\n\n - See"
" https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls"
" for more details on supported DB URLs."
"""Optional. The database URL to store the session.
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
),
)
@click.option(
@@ -541,6 +543,18 @@ def cli_api_server(
default="WARNING",
help="Optional. Override the default verbosity level.",
)
@click.option(
"--session_db_url",
help=(
"""Optional. The database URL to store the session.
- Use 'agentengine://<agent_engine_resource_id>' to connect to Agent Engine sessions.
- Use 'sqlite://<path_to_sqlite_file>' to connect to a SQLite DB.
- See https://docs.sqlalchemy.org/en/20/core/engines.html#backend-specific-urls for more details on supported DB URLs."""
),
)
@click.argument(
"agent",
type=click.Path(
@@ -558,6 +572,7 @@ def cli_deploy_cloud_run(
trace_to_cloud: bool,
with_ui: bool,
verbosity: str,
session_db_url: str,
):
"""Deploys an agent to Cloud Run.
@@ -579,6 +594,7 @@ def cli_deploy_cloud_run(
trace_to_cloud=trace_to_cloud,
with_ui=with_ui,
verbosity=verbosity,
session_db_url=session_db_url,
)
except Exception as e:
click.secho(f"Deploy failed: {e}", fg="red", err=True)
+6
View File
@@ -756,6 +756,12 @@ def get_fast_api_app(
except Exception as e:
logger.exception("Error during live websocket communication: %s", e)
traceback.print_exc()
WEBSOCKET_INTERNAL_ERROR_CODE = 1011
WEBSOCKET_MAX_BYTES_FOR_REASON = 123
await websocket.close(
code=WEBSOCKET_INTERNAL_ERROR_CODE,
reason=str(e)[:WEBSOCKET_MAX_BYTES_FOR_REASON],
)
finally:
for task in pending:
task.cancel()
+2 -2
View File
@@ -55,7 +55,7 @@ def load_json(file_path: str) -> Union[Dict, List]:
class AgentEvaluator:
"""An evaluator for Agents, mainly intented for helping with test cases."""
"""An evaluator for Agents, mainly intended for helping with test cases."""
@staticmethod
def find_config_for_test_file(test_file: str):
@@ -91,7 +91,7 @@ class AgentEvaluator:
look for 'root_agent' in the loaded module.
eval_dataset: The eval data set. This can be either a string representing
full path to the file containing eval dataset, or a directory that is
recusively explored for all files that have a `.test.json` suffix.
recursively explored for all files that have a `.test.json` suffix.
num_runs: Number of times all entries in the eval dataset should be
assessed.
agent_name: The name of the agent.
@@ -35,7 +35,7 @@ class ResponseEvaluator:
Args:
raw_eval_dataset: The dataset that will be evaluated.
evaluation_criteria: The evaluation criteria to be used. This method
support two criterias, `response_evaluation_score` and
support two criteria, `response_evaluation_score` and
`response_match_score`.
print_detailed_results: Prints detailed results on the console. This is
usually helpful during debugging.
@@ -56,7 +56,7 @@ class ResponseEvaluator:
Value range: [0, 5], where 0 means that the agent's response is not
coherent, while 5 means it is . High values are good.
A note on raw_eval_dataset:
The dataset should be a list session, where each sesssion is represented
The dataset should be a list session, where each session is represented
as a list of interaction that need evaluation. Each evaluation is
represented as a dictionary that is expected to have values for the
following keys:
@@ -31,10 +31,9 @@ class TrajectoryEvaluator:
):
r"""Returns the mean tool use accuracy of the eval dataset.
Tool use accuracy is calculated by comparing the expected and actuall tool
use trajectories. An exact match scores a 1, 0 otherwise. The final number
is an
average of these individual scores.
Tool use accuracy is calculated by comparing the expected and the actual
tool use trajectories. An exact match scores a 1, 0 otherwise. The final
number is an average of these individual scores.
Value range: [0, 1], where 0 is means none of the too use entries aligned,
and 1 would mean all of them aligned. Higher value is good.
@@ -45,7 +44,7 @@ class TrajectoryEvaluator:
usually helpful during debugging.
A note on eval_dataset:
The dataset should be a list session, where each sesssion is represented
The dataset should be a list session, where each session is represented
as a list of interaction that need evaluation. Each evaluation is
represented as a dictionary that is expected to have values for the
following keys:
@@ -94,7 +94,7 @@ can answer it.
If another agent is better for answering the question according to its
description, call `{_TRANSFER_TO_AGENT_FUNCTION_NAME}` function to transfer the
question to that agent. When transfering, do not generate any text other than
question to that agent. When transferring, do not generate any text other than
the function call.
"""
@@ -115,7 +115,7 @@ class BaseLlmFlow(ABC):
yield event
# send back the function response
if event.get_function_responses():
logger.debug('Sending back last function resonse event: %s', event)
logger.debug('Sending back last function response event: %s', event)
invocation_context.live_request_queue.send_content(event.content)
if (
event.content

Some files were not shown because too many files have changed in this diff Show More