From c9eb67eaf9817a9eb28d5f3141275a19712b5ad3 Mon Sep 17 00:00:00 2001 From: guillaume blaquiere Date: Tue, 2 Dec 2025 14:16:45 +0100 Subject: [PATCH 1/4] fix: issue 3785. Add id_token field and fill it when available in the token exchange. --- src/google/adk/auth/auth_credential.py | 1 + src/google/adk/auth/oauth2_credential_util.py | 1 + 2 files changed, 2 insertions(+) diff --git a/src/google/adk/auth/auth_credential.py b/src/google/adk/auth/auth_credential.py index bc91d48f79..96b766fc3a 100644 --- a/src/google/adk/auth/auth_credential.py +++ b/src/google/adk/auth/auth_credential.py @@ -76,6 +76,7 @@ class OAuth2Auth(BaseModelWithConfig): auth_response_uri: Optional[str] = None auth_code: Optional[str] = None access_token: Optional[str] = None + id_token: Optional[str] = None refresh_token: Optional[str] = None expires_at: Optional[int] = None expires_in: Optional[int] = None diff --git a/src/google/adk/auth/oauth2_credential_util.py b/src/google/adk/auth/oauth2_credential_util.py index d90103a88c..b1330865c5 100644 --- a/src/google/adk/auth/oauth2_credential_util.py +++ b/src/google/adk/auth/oauth2_credential_util.py @@ -108,6 +108,7 @@ def update_credential_with_tokens( """ auth_credential.oauth2.access_token = tokens.get("access_token") auth_credential.oauth2.refresh_token = tokens.get("refresh_token") + auth_credential.oauth2.id_token = tokens.get("id_token", None) auth_credential.oauth2.expires_at = ( int(tokens.get("expires_at")) if tokens.get("expires_at") else None ) From f1c74e7aac193c3dec4a9ffd5b2bfd51d6dd9963 Mon Sep 17 00:00:00 2001 From: guillaume blaquiere Date: Tue, 2 Dec 2025 20:47:23 +0100 Subject: [PATCH 2/4] test: add id_token in test --- tests/unittests/auth/test_oauth2_credential_util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unittests/auth/test_oauth2_credential_util.py b/tests/unittests/auth/test_oauth2_credential_util.py index f1fd607ff5..e335512227 100644 --- a/tests/unittests/auth/test_oauth2_credential_util.py +++ b/tests/unittests/auth/test_oauth2_credential_util.py @@ -137,6 +137,7 @@ def test_update_credential_with_tokens(self): tokens = OAuth2Token({ "access_token": "new_access_token", "refresh_token": "new_refresh_token", + "id_token": "some_id_token", "expires_at": expected_expires_at, "expires_in": 3600, }) @@ -145,5 +146,6 @@ def test_update_credential_with_tokens(self): assert credential.oauth2.access_token == "new_access_token" assert credential.oauth2.refresh_token == "new_refresh_token" + assert credential.oauth2.id_token == "some_id_token" assert credential.oauth2.expires_at == expected_expires_at assert credential.oauth2.expires_in == 3600 From c208c778844d920311cfb81f8d4d0bf44998f048 Mon Sep 17 00:00:00 2001 From: guillaume blaquiere Date: Fri, 5 Dec 2025 09:40:43 +0100 Subject: [PATCH 3/4] chore: autoformat.sh --- contributing/samples/gepa/experiment.py | 1 - contributing/samples/gepa/run_experiment.py | 1 - 2 files changed, 2 deletions(-) diff --git a/contributing/samples/gepa/experiment.py b/contributing/samples/gepa/experiment.py index 2f5d03a772..f68b349d9c 100644 --- a/contributing/samples/gepa/experiment.py +++ b/contributing/samples/gepa/experiment.py @@ -43,7 +43,6 @@ from tau_bench.types import EnvRunResult from tau_bench.types import RunConfig import tau_bench_agent as tau_bench_agent_lib - import utils diff --git a/contributing/samples/gepa/run_experiment.py b/contributing/samples/gepa/run_experiment.py index cfd850b3a3..1bc4ee58c8 100644 --- a/contributing/samples/gepa/run_experiment.py +++ b/contributing/samples/gepa/run_experiment.py @@ -25,7 +25,6 @@ from absl import flags import experiment from google.genai import types - import utils _OUTPUT_DIR = flags.DEFINE_string( From 2973e2cf7d67af17fcb430d401f88727f159e765 Mon Sep 17 00:00:00 2001 From: guillaume blaquiere Date: Sat, 24 Jan 2026 22:53:40 +0100 Subject: [PATCH 4/4] chore: fix unit test --- pyproject.toml | 1 + tests/unittests/agents/test_remote_a2a_agent.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e3e9ec3d6..e708c95ee7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -208,6 +208,7 @@ known_third_party = ["google.adk"] [tool.pytest.ini_options] testpaths = ["tests"] +pythonpath = "src" asyncio_default_fixture_loop_scope = "function" asyncio_mode = "auto" diff --git a/tests/unittests/agents/test_remote_a2a_agent.py b/tests/unittests/agents/test_remote_a2a_agent.py index 7643125d81..b884bc4048 100644 --- a/tests/unittests/agents/test_remote_a2a_agent.py +++ b/tests/unittests/agents/test_remote_a2a_agent.py @@ -17,6 +17,7 @@ import tempfile from unittest.mock import AsyncMock from unittest.mock import create_autospec +from unittest.mock import MagicMock from unittest.mock import Mock from unittest.mock import patch @@ -1002,7 +1003,7 @@ async def test_handle_a2a_response_with_task_submitted_and_no_update(self): mock_a2a_task, self.agent.name, self.mock_context, - self.mock_a2a_part_converter, + self.agent._a2a_part_converter, ) # Check the parts are updated as Thought assert result.content.parts[0].thought is True @@ -1770,7 +1771,7 @@ async def test_run_async_impl_successful_request(self): ) # Tuple with parts and context_id # Mock A2A client - mock_a2a_client = create_autospec(spec=A2AClient, instance=True) + mock_a2a_client = MagicMock(spec=A2AClient) mock_response = Mock() mock_send_message = AsyncMock() mock_send_message.__aiter__.return_value = [mock_response] @@ -1909,7 +1910,7 @@ async def test_run_async_impl_with_meta_provider(self): ) # Tuple with parts and context_id # Mock A2A client - mock_a2a_client = create_autospec(spec=A2AClient, instance=True) + mock_a2a_client = MagicMock(spec=A2AClient) mock_response = Mock() mock_send_message = AsyncMock() mock_send_message.__aiter__.return_value = [mock_response] @@ -2046,7 +2047,7 @@ async def test_run_async_impl_successful_request(self): ) # Tuple with parts and context_id # Mock A2A client - mock_a2a_client = create_autospec(spec=A2AClient, instance=True) + mock_a2a_client = MagicMock(spec=A2AClient) mock_response = Mock() mock_send_message = AsyncMock() mock_send_message.__aiter__.return_value = [mock_response]