This allows to protect against any write operations (e.g. update or delete a table), useful for some agents that must only be used in a read-only mode, while the user may have write permissions.
PiperOrigin-RevId: 769803741
Merge https://github.com/google/adk-python/pull/1211
### Description
When using the Google.GenAI backend (GEMINI_API), file uploads fail if the `file_data` or `inline_data` parts of the request contain a `display_name`. The Gemini API (non-Vertex) does not support this attribute, causing a `ValueError`.
This commit updates the `_preprocess_request` method in the `Gemini` class to sanitize the request. It now iterates through all content parts and sets `display_name` to `None` if the determined backend is `GEMINI_API`. This ensures compatibility, similar to the existing handling of the `labels` attribute.
Fixes#1182
### Testing Plan
**1. Unit Tests**
- Added a new parameterized test `test_preprocess_request_handles_backend_specific_fields` to `tests/unittests/models/test_google_llm.py`.
- This test verifies:
- When the backend is `GEMINI_API`, `display_name` in `file_data` and `inline_data` is correctly set to `None`.
- When the backend is `VERTEX_AI`, `display_name` remains unchanged.
- All unit tests passed successfully.
```shell
pytest ./tests/unittests/models/test_google_llm.py ░▒▓ ✔ adk-python base system 21:14:02
============================================================================================ test session starts ============================================================================================
platform darwin -- Python 3.12.10, pytest-8.3.5, pluggy-1.6.0
rootdir: /Users/leo/PycharmProjects/adk-python
configfile: pyproject.toml
plugins: anyio-4.9.0, langsmith-0.3.42, asyncio-0.26.0, mock-3.14.0, xdist-3.6.1
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collected 20 items
tests/unittests/models/test_google_llm.py .................... [100%]
============================================================================================ 20 passed in 3.19s =============================================================================================
```
**2. Manual End-to-End (E2E) Test**
I manually verified the fix using `adk web`. The test was configured to use a **Google AI Studio API key**, which is the scenario where the bug occurs.
- **Before the fix:**
When uploading a file, the request failed with the error: `{"error": "display_name parameter is not supported in Gemini API."}`. This confirms the bug.
<img width="968" alt="Screenshot 2025-06-06 at 21 22 35" src="https://github.com/user-attachments/assets/f1ab2db2-d5ec-40fc-a182-9932562b21e1" />
- **After the fix:**
With the patch applied, the same file upload was processed successfully. The agent correctly analyzed the file and responded without errors.
<img width="973" alt="Screenshot 2025-06-06 at 21 23 24" src="https://github.com/user-attachments/assets/e03228f6-0b7d-4bf9-955a-ac24efb4fb72" />
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/1211 from ystory:fix/display-name d3efebe74aca635a7a255063e64f07cc44016f05
PiperOrigin-RevId: 769278445
Even though litellm type definitions and openai API specifies content as list of dictionaries (with type and relevant attributes potentially to allow multimodal inputs/outputs in addition to text), ollama has been demonstrating marshal errors. As a workaround this change simplifies the content as string when there is no more than one content part.
Fixes#642, #928, #376
PiperOrigin-RevId: 766890141
This is in response to the litellm v1.71.2 + ollama v0.9.0 sending function call chunks with 0 indices across multiple calls and lacking call ids.
Solutions introduced:
1. increment fallback index when accumulated arg becomes json parsable.
2. tolerate finish reason == stop when tool calls are present
3. fallback to index when tool call id is None
Fixes https://github.com/google/adk-python/issues/294
PiperOrigin-RevId: 766258344
--
8772b3de0b2fd04f246cc90c4c8032f9dc8cfed9 by Jaeyeon Kim <anencore94@gmail.com>:
fix: update unit test code for test_connection
- Fix for Unit Test Failures
--
8e0b45c2a64994bfda6401847e485fdd9edc8306 by Jaeyeon Kim <anencore94@gmail.com>:
fix useless changes
--
54efa004fa0fc9bcf78b49061221994650e162bc by Jaeyeon Kim <anencore94@gmail.com>:
fix conflict resolve issue
--
003ed4418c73b74bfba5ff055a364b62ddc18fa7 by Wei Sun (Jack) <weisun@google.com>:
Autoformat test_connections_client.py
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/578 from anencore94:bugfix/failed_unittests ba0e1d33ad905b0b046023b685c70f4ef05e4efa
PiperOrigin-RevId: 766221165
Copybara import of the project:
--
ffd6184d7e402b0787b0fa37fc09cd519adcc7f3 by Calvin Giles <calvin.giles@trademe.co.nz>:
fix: Call all tools in parallel calls during partial authentication
--
c71782a582ba825dbe2246cdb5be3f273ca90dca by seanzhou1023 <seanzhou1023@gmail.com>:
Update auth_preprocessor.py
--
843af6b1bc0bc6291cb9cb23acf11840098ba6dd by seanzhou1023 <seanzhou1023@gmail.com>:
Update test_functions_request_euc.py
--
955e3fa852420ecbf196583caa3cf86b7b80ab56 by seanzhou1023 <seanzhou1023@gmail.com>:
Update test_functions_request_euc.py
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/853 from calvingiles:fix-parallel-auth-tool-calls f44671e37b9fe44a25c9b1c0c25a26fc634b011c
PiperOrigin-RevId: 765639904