Commit Graph

208 Commits

Author SHA1 Message Date
Mateusz Czubak d3b500bd68 feat: expose credential service in readonly context 2025-07-08 11:32:50 +02:00
Hangfei Lin bf39c00610 test: Add tests for live streaming configs
This PR extends the existing Streaming tests to consider new configurations that have been added, including:

- `output_audio_transcription`
- `input_audio_transcription`
- `realtime_input_config`
- `enable_affective_dialog`
- `proactivity`

These configurations are tested individually and also combined, to cover all the possibilities, increasing the testing coverage and ensuring everything is working as expected.

In addition, the new configuration values are also validated to be sure they are properly initialized.

PiperOrigin-RevId: 780178334
2025-07-07 11:01:46 -07:00
Sindri Snær Gunnarsson 362fb3f2b7 fix: scenario where a user can access another users events given the same session id
test: refine test_session_state in test_session_state to catch event leakage

fix: revert app name to my_app for test_session_state test

style: fix pyink style warnings

fix: add app_name to filter as per suggestion from rpedela-recurly
2025-07-02 18:56:08 +00:00
Ankur Sharma 0bd05df471 feat: Add Safety evaluator metric
We add a new metric for evaluating safety of Agent's response to ADK Eval. We delegate the actual implementation to Vertex Gen AI Eval SDK, so using this metric will require GCP project.

As a part of this change, we created (refactored) a simple Facade for vertex gen ai eval sdk.

PiperOrigin-RevId: 778580406
2025-07-02 11:30:31 -07:00
Ankur Sharma 62c4a85917 chore: Update ResponseEvaluator to use newer version of Eval SDK
Also,
- removed functionality that was marked deprecated from the ResponseEvaluator class.
- Added unit test cases

PiperOrigin-RevId: 778568884
2025-07-02 11:00:27 -07:00
google-labs-jules[bot] 0959b06dbd Fix: Handle unexpected 'parameters' argument in FunctionTool.run_async
The LLM occasionally includes an unexpected 'parameters' argument when calling tools, specifically observed with 'transfer_to_agent'. This change makes FunctionTool.run_async more robust by filtering arguments against the function signature before invocation.

This resolves issue #1637.

Update test_function_tool.py

fix typing

fix: add `from __future__ import annotations`
2025-07-02 00:22:09 +00:00
Ankur Sharma b0d88bf172 feat: BaseEvalService declaration and surrounding data models
Also, adds a metric registry.

PiperOrigin-RevId: 778186012
2025-07-01 14:13:48 -07:00
Hangfei Lin 9b75e24d8c fix: Avoid pydantic.ValidationError when the model stream returns empty final chunk
Bug: When a model emits a stream of tokens, it sometimes emits a final chunk of whitespace or no content. The agent was trying to parse that content into JSON, causing a validation error.

Fix: If a model is expected to return JSON and the last streamed token is empty/whitespace, the agent will no longer try to parse it, and exit gracefully.

New unit tests confirm the scenario and the fix.

PiperOrigin-RevId: 777609415
2025-06-30 09:50:04 -07:00
Google Team Member dc43d518c9 feat: Support protected write in BigQuery execute_sql tool
This change adds a new enum value which the agent builder can pass in the `BigQueryToolConfig` to allow limited writes to the `execute_sql` tool.

PiperOrigin-RevId: 776661744
2025-06-27 11:44:30 -07:00
Xuan Yang 3f621ae6f2 fix: treat SQLite database update time as UTC for session's last update time
Fixes https://github.com/google/adk-python/issues/1180

We are using `func.now()` to set the `onupdate` time for db, when SQLAlchemy generates the SQL to build the database, it actually translates `func.now()` into `NOW()` or `CURRENT_TIMESTAMP`. The value it returns depends on the database server settings. For example, if the global/default timezone for a db is set to be UTC, the update time will be set to be a UCT time; if the global time zone for a db is set to be a local time zone (e.g. America/Los_Angeles), the update time will be a local time.

Normally, the best practice is to set database server to use UTC. Applications will convert it into different time zones as needed.

For SQLite, there is no way to config the default timezone, it will just treat it as UTC. But because it is a naive datetime (with no timezone info), python will assume it is a local time and then covert it into a UTC, which is why we see the bug (e.g. we create a session at 2025-06-17 12:49:33 local time, but when we read the session, its last update time is 2025-06-17 19:49:33 local time).

The solution is converting the native datatime to be timezone aware before `.timestamp()`.

The change in this CL only affects SQLite database.

PiperOrigin-RevId: 776654443
2025-06-27 11:22:23 -07:00
Keisuke Oohashi 4e765ae2f3 fix: raise ValueError when sessionId and userId are incorrect combination(#1653)
Merge https://github.com/google/adk-python/pull/1655

Fix #1653

When session_id and user_id are incorrect combination on vertex ai session service, it should not return the session.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1655 from soundTricker:fix/1653-invalid-session 7a3dee2fc75602a2685ea922799cc5f5ba666e97
PiperOrigin-RevId: 776648361
2025-06-27 11:06:15 -07:00
Xiang (Sean) Zhou c13c9875cf feat: Add remote a2a agent
PiperOrigin-RevId: 776643130
2025-06-27 10:52:01 -07:00
Xiang (Sean) Zhou 045aea9b15 fix: Support API-Key for MCP Tool authentication
PiperOrigin-RevId: 776641474
2025-06-27 10:47:42 -07:00
Xiang (Sean) Zhou 20279d9a50 fix: Save output in state via output_key only when the event is authored by current agent
PiperOrigin-RevId: 776640671
2025-06-27 10:45:34 -07:00
Xiang (Sean) Zhou 09e487df3c chore: Use context_id as session_id and construct temp user_id from context_id
PiperOrigin-RevId: 776639713
2025-06-27 10:42:15 -07:00
Xiang (Sean) Zhou e79651cd86 feat: Add A2A endpoints to fast api server when --a2a option is specified (WIP)
PiperOrigin-RevId: 776211580
2025-06-26 11:18:44 -07:00
Xiang (Sean) Zhou 5356f20ead chore: Add a2a log utils for formatting a2a reqeust/response logs
PiperOrigin-RevId: 776026554
2025-06-26 01:12:23 -07:00
Xiang (Sean) Zhou 630f1674cb chore: Add a2a agent executor
PiperOrigin-RevId: 775983689
2025-06-25 22:32:17 -07:00
Xiang (Sean) Zhou 2f55de6ded chore: Add a2a task result aggregator
PiperOrigin-RevId: 775975982
2025-06-25 22:02:28 -07:00
Ankur Sharma 04de3e197d fix: Adding detailed information on each metric evaluation
Additionally, few other small changes.
*   Updated a test fixture to support the latest eval data schema. Somehow I missed doing that previously.
*   Updated the `evaluation_generator.py` to use `run_async`, instead of `run`.
*   Also, raise an informed error when dependencies required eval are not installed.
*   Also, changed the behavior of AgentEvaluator.evaluate method to run all the evals, instead of failing at the first eval metric failure.

PiperOrigin-RevId: 775919127
2025-06-25 18:32:02 -07:00
SimonWei 3901fade71 fix: converts litellm generate config err
Merge https://github.com/google/adk-python/pull/1509

Fixs: #1302

Previous PR: https://github.com/google/adk-python/pull/1450

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1509 from simonwei97:fix/litellm-gen-config-converting-err 3120887f29a21789f1b4a7c54af3ed35eb5055e3
PiperOrigin-RevId: 775903671
2025-06-25 17:40:48 -07:00
Xiang (Sean) Zhou a71dbdf9e2 chore: Enhance a2a event converter
a. fix function call long running id matching logic
b. fix error code conversion logic
c. add input required and auth required status conversion logic
d. add a2a Task/Message to ADK event converter
f. set task id and context id from input argument

PiperOrigin-RevId: 775860563
2025-06-25 15:32:17 -07:00
Xiang (Sean) Zhou 832a633351 chore: Enhance a2a part converters
a. fix binary data conversion
b. support thoughts, code execution result, executable codes conversion

PiperOrigin-RevId: 775827259
2025-06-25 13:58:49 -07:00
Xiang (Sean) Zhou a623467299 chore: Enhance a2a context id parsing and construction logic
PiperOrigin-RevId: 775718282
2025-06-25 09:19:16 -07:00
Xiang (Sean) Zhou f54b9b6ad1 chore: Add unit tests for contents.py
PiperOrigin-RevId: 775713101
2025-06-25 09:06:01 -07:00