1268 Commits

Author SHA1 Message Date
Sasha Sobran e6537decc9 chore(release): configure release-please for v2.0.0 GA
Change-Id: If39d565130df657d08e4367394c33771e68ad364
2026-05-19 13:36:37 +00:00
Sasha Sobran 162279358c chore: switch main to v2.0.0 GA (transition to v2)
Co-authored-by: Bo Yang <ybo@google.com>
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
Co-authored-by: George Weale <gweale@google.com>
Co-authored-by: Swapnil Agarwal <swapnilag@google.com>
Co-authored-by: Xuan Yang <xygoogle@google.com>
Co-authored-by: Shangjie Chen <deanchen@google.com>
Co-authored-by: Yifan Wang <wanyif@google.com>
Co-authored-by: Kathy Wu <wukathy@google.com>
2026-05-19 02:01:33 +00:00
Xuan Yang 07a9a01b3c fix: Preserve live_session_id in function call handling
Fixes https://github.com/google/adk-python/issues/5702

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 917452441
2026-05-18 15:17:43 -07:00
Google Team Member 03b915b1bd fix(anthropic): map negative thinking_budget to adaptive thinking
- Claude Opus 4.7 rejects `thinking.type: "enabled"` with a 400 error
  and requires `thinking.type: "adaptive"`; adaptive is also the
  recommended mode for Opus 4.6 / Sonnet 4.6 where `"enabled"` is
  deprecated.
- The genai `ThinkingConfig.thinking_budget = -1` (AUTOMATIC) sentinel
  is the natural mapping for adaptive: the model picks the depth
  itself. Callers opt in with `-1`; positive values keep the existing
  `"enabled"` path so older models are unchanged.
- Bump `anthropic>=0.78` in `pyproject.toml`; 0.78 introduced
  `ThinkingConfigAdaptiveParam`. The previous floor (`>=0.43`) let
  Kokoro install `anthropic==0.75.0`, which crashes the new tests
  with `AttributeError: module 'anthropic.types' has no attribute
  'ThinkingConfigAdaptiveParam'`.

PiperOrigin-RevId: 917449729
2026-05-18 15:12:26 -07:00
George Weale 57d8fc7d81 perf(models): guard debug log evaluation with isEnabledFor
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 917411239
2026-05-18 13:57:16 -07:00
Google Team Member baf7efbaa9 feat: Added config option to include tool calls/responses in conversation history passed to user simulator
PiperOrigin-RevId: 917340645
2026-05-18 11:31:14 -07:00
Google Team Member 48f1b30251 feat: Simplify data retrieved handling of ask_data_agent tool and ask_data_insights tool
PiperOrigin-RevId: 917326615
2026-05-18 11:04:04 -07:00
Google Team Member 59f7347a63 fix(small): Convert events to the A2A format while respecting user vs agent role
PiperOrigin-RevId: 917275872
2026-05-18 09:28:29 -07:00
Jorge Israel Frómeta Moya 3d07960a70 fix: use tool_responses role for gemma4 models in LiteLLM integration
Merge https://github.com/google/adk-python/pull/5655
Closes: #5650

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/5655 from jfrometa88:main d74b5216b0937ff371b25cc8f272ee8ab33c8dc9
PiperOrigin-RevId: 917231422
2026-05-18 07:54:00 -07:00
Google Team Member 790c9bef9a feat: add general support for Gemini Live API in ADK evaluate
* Implements live inference in evaluation_generator.py using Runner.run_live().
* Updates base_eval_service.py, local_eval_service.py to support live mode data structures and connection handling.

Testing: Added unit tests:
* test_generates_inferences_with_user_simulator_live
* test_live_session_manually_triggers_callbacks
* test_live_session_manually_triggers_callbacks_with_tools
* test_perform_inference_with_use_live
* test_perform_inference_single_eval_item_live
* test_perform_inference_single_eval_item_non_live
PiperOrigin-RevId: 916231029
2026-05-15 16:14:21 -07:00
Google Team Member a5cddb8e86 chore: Remove experimental tag from SkillToolset
PiperOrigin-RevId: 916227202
2026-05-15 16:05:59 -07:00
Sasha Sobran 4309159700 fix(tools): Prevent AnyIO CancelScope task boundary violations during MCP session creation failure
Co-authored-by: Sasha Sobran <asobran@google.com>
PiperOrigin-RevId: 916220631
2026-05-15 15:50:01 -07:00
George Weale ec54bd439e perf(utils): cache find_context_parameter introspection
Adds @functools.lru_cache to find_context_parameter so the inspect.signature
+ typing.get_type_hints lookup runs once per function, not on every MCP
confirmation callback or declaration build. No public surface change.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 916204929
2026-05-15 15:14:36 -07:00
Kathy Wu 2388090cd2 chore: Remove experimental tag from SkillToolset
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 916198410
2026-05-15 15:00:19 -07:00
George Weale 7e61b51702 fix(tools): preserve code_execution_result and executable_code in AgentTool
AgentTool.run_async only extracted text parts from the inner agent's
response, silently dropping code_execution_result.output and
executable_code.code. Outer agents using an inner agent with a code
executor saw nothing.

Close #5481

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 916196604
2026-05-15 14:56:02 -07:00
George Weale 0cb9ae94b3 fix(models): treat empty GenerateContentResponse without prompt feedback as successful
Previously, an empty `candidates` list without `prompt_feedback` resulted in an `UNKNOWN_ERROR`. This change updates the logic to handle such cases as a successful completion with no generated content, which is valid for certain model interactions like tool-driven turns.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 916115022
2026-05-15 11:55:40 -07:00
Amaad Martin 0524797ac7 fix(agents): fix visibility of output_key state delta in callbacks
Co-authored-by: Amaad Martin <amaadmartin@google.com>
PiperOrigin-RevId: 916112779
2026-05-15 11:51:28 -07:00
George Weale 9a1e75f242 fix(models): preserve string content in Anthropic tool_result blocks
`part_to_message_block` iterated `content` char-by-char when a tool
returned it as a plain string (e.g. `LoadSkillResourceTool`'s
`{"content": <file text>}`), producing `"H\ne\nl\nl\no"` instead of
`"Hello"`. Guard the list branch with `isinstance(..., list)` and add
a sibling branch that passes a scalar string through directly, matching
Anthropic's `content: str | list[ContentBlockParam]` shape.

Close #5358

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 916109239
2026-05-15 11:44:41 -07:00
George Weale bb2efb6bd2 fix: Prevent compaction of events involved in Human-in-the-Loop interactions
This change introduces logic to identify events containing requests for tool confirmation or auth credentials. The compaction process will now stop before any such "Human-in-the-Loop" (HITL) events, ensuring that the full context of the interaction is preserved and not summarized away. This applies to both sliding window and token threshold compaction strategies.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 916108771
2026-05-15 11:43:53 -07:00
George Weale eed9bd319f fix(evaluation): handle none config in per_turn_user_simulator_quality
When judge_model_config is None, LlmRequest raises a ValidationError
because it requires a config. We now construct a default GenerateContentConfig
if one isn't provided.

Close #5677

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 916087055
2026-05-15 11:00:49 -07:00
Google Team Member 85f397d20f fix: avoid pre-serializing dict values in Interactions API to prevent double-escaping
PiperOrigin-RevId: 916037238
2026-05-15 09:17:19 -07:00
Google Team Member 115124cdf4 feat: add support for A2aAgentExecutor factory in to_a2a() function
PiperOrigin-RevId: 916015512
2026-05-15 08:22:25 -07:00
Kathy Wu 88ebd426be feat: Implement GCPSkillRegistry in ADK
This CL implements the  class in the integrations folder, used specifically for the Skill Registry API.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 915627057
2026-05-14 14:47:42 -07:00
Google Team Member 9f38973081 feat: Make Agent Skill description validation more informative
PiperOrigin-RevId: 915616175
2026-05-14 14:24:45 -07:00
Kathy Wu 8de1ae8f80 chore: change name of skill cache to "fetched_skill_cache" to reduce confusion from BaseToolset's invocation_cache
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 915578052
2026-05-14 13:11:27 -07:00
Google Team Member cfe8d2cc2b feat: Add mTLS support to Google Cloud Telemetry exporter
This change enables the Google Cloud Telemetry exporter to use mTLS endpoints. It checks for the availability of client certificates and respects the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variables to determine whether to use the mTLS-specific endpoint and configure the session accordingly.

PiperOrigin-RevId: 915541335
2026-05-14 11:54:45 -07:00
Shangjie Chen e04a4683f4 chore: Remove deprecated CLI flags and version-based service URI handling
This change removes support for the deprecated `--session_db_url`, `--artifact_storage_uri`, and `--verbosity` flags from the ADK CLI. It also simplifies the service URI handling in `cli_deploy.py` by always using the new `--session_service_uri`, `--artifact_service_uri`, and `--memory_service_uri` flags, regardless of the ADK version.

The deprecated flags has been more than 1 year

Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 915100881
2026-05-13 15:48:39 -07:00
Kathy Wu e377cb5ec0 fix: fallback to project id if crendetials don't contain quota project
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 914934690
2026-05-13 10:25:49 -07:00
Google Team Member 6e534723dd feat: add support for non-ADK produced input-required events
This CL introduces logic to handle scenarios where a non-ADK agent transitions to the `TaskState.input_required` or `TaskState.auth_required` states. It intercepts these events and converts them into a synthetic ADK `FunctionCall` event.

PiperOrigin-RevId: 914877123
2026-05-13 08:25:10 -07:00
knQzx 327c45f9f4 fix(models): preserve tool_use IDs for Anthropic models on session resume
When resuming a session with Anthropic (Claude) models, tool_use IDs were
getting stripped during content replay, causing BadRequestError from the
Anthropic API. Two fixes: (1) preserve function call IDs in the contents
flow for AnthropicLlm models, (2) sanitize invalid/empty tool_use IDs
to match Anthropic's required pattern (^[a-zA-Z0-9_-]+$) instead of
passing empty strings.

Fixes #5074

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 914550905
2026-05-12 16:57:53 -07:00
Kathy Wu 380d261e59 feat: Implement Skill Registry in ADK
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 914515552
2026-05-12 15:42:27 -07:00
Stephen Allen cd78d87b96 feat(a2a): add support for persistent task stores
Merge https://github.com/google/adk-python/pull/5597

**Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.**

### Link to Issue or Description of Change

**1. Link to an existing issue (if applicable):**

- Related: https://github.com/google/adk-python/issues/4971

**2. Or, if no issue exists, describe the change:**

_If applicable, please follow the issue templates to provide as much detail as
possible._

**Problem:**
A2A support lacked pluggable or persistent task store backends, forcing a strict default to `InMemoryTaskStore`.

**Solution:**
Extended `ServiceRegistry` and `ServiceFactory` to support URI-driven configuration for A2A task stores. Added built-in support for `memory://`, `postgresql://`, `mysql://`, and `sqlite://` schemes. Plumbed the options down into `to_a2a()` and `get_fast_api_app()`, ensuring connection strings are securely redacted from application logs.

### Testing Plan

**Unit Tests:**

- [x] I have added or updated unit tests for my change.
- [x] All unit tests pass locally.

Summary: Ran `pytest` against `test_agent_to_a2a.py`, `test_fast_api.py`, `test_service_registry.py`, and `test_service_factory.py`. All 131 unit tests passed successfully.

**Manual End-to-End (E2E) Tests:**

Compiled the package distribution wheel via `uv build` and successfully validated its installation inside a clean isolated sandbox environment via `uv pip install dist/google_adk-1.32.0-py3-none-any.whl[a2a]`. Verified that the application instantiates default in-memory stores and custom persistent URI stores

### Checklist

- [x] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code, particularly in hard-to-understand areas.
- [x] I have added tests that prove my fix is effective or that my feature works.
- [x] New and existing unit tests pass locally with my changes.
- [x] I have manually tested my changes end-to-end.
- [x] Any dependent changes have been merged and published in downstream modules.

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/5597 from allen-stephen:feat/a2a-task-store-support f53ba0fa35fa3c28e4923b6850a5873fd5293525
PiperOrigin-RevId: 914496800
2026-05-12 15:03:55 -07:00
George Weale 76b9f0baa0 fix(cache): enforce CacheMetadata active-state invariant
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 914400439
2026-05-12 11:51:05 -07:00
Amy Wu 8dd9147443 fix(live): ensure sub live agent doesn't inherit session resumption handle from parent live agent to avoid interrupting the conversation
PiperOrigin-RevId: 914367901
2026-05-12 10:50:55 -07:00
d 🔹 218ea76e30 fix(auth): persist refreshed OAuth2 credentials to store
Merge https://github.com/google/adk-python/pull/5350
Fixes #5329

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/5350 from voidborne-d:fix/persist-refreshed-oauth2-credential 0ef3d8c19616b45f932b15ee2a200bc74c8334b3
PiperOrigin-RevId: 913922074
2026-05-11 15:51:09 -07:00
Sasha Sobran 33cf6cb610 fix: raise eagerly on importing AgentRegistry if a2a-sdk is missing
- Clean up the unused private _ProtocolType import

Co-authored-by: Sasha Sobran <asobran@google.com>
PiperOrigin-RevId: 913817935
2026-05-11 12:07:41 -07:00
George Weale 9c5de58cfa fix(cache): handle fingerprint-only metadata in performance analyzer
The analyzer crashed on `sum([None, ...])` whenever any event had
fingerprint-only cache metadata (cache_name=None, invocations_used=None),
which happens on every session's first turn. Also fixes `cache_refreshes`
over-counting None as a unique cache instance.

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 912722966
2026-05-08 15:26:12 -07:00
Kathy Wu e7316dc077 feat: Support OAuth PKCE in McpToolset
Generates a random code verifier and code challenge during the initial auth request. During token exchange, the client sends the original code verifier so the server can verify it matches the previously sent challenge. This prevents attacks by ensuring that only the client that initiated the request can obtain the final access token.

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 912703679
2026-05-08 14:43:19 -07:00
Kathy Wu 88421f80a0 fix: Filter out video events with inline data from being stored in session
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 912249311
2026-05-07 18:00:59 -07:00
Kathy Wu e833995391 fix: Update expressmode api call to include default api key param
Express mode API was updated to require "get_default_api_key: True" for returning api key

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 912153767
2026-05-07 14:27:45 -07:00
Google Team Member 83ae40525a feat: Make ADK environment tools truncation limit configurable
PiperOrigin-RevId: 912036870
2026-05-07 10:36:03 -07:00
Google Team Member fb92aad9c5 fix(simulation): Add error message when LlmBackedUserSimulator returns empty response
PiperOrigin-RevId: 911999966
2026-05-07 09:21:42 -07:00
Wei Sun (Jack) 3117e09136 chore: further fix header-check via 2025 --> 2026
Co-authored-by: Wei Sun (Jack) <weisun@google.com>
PiperOrigin-RevId: 911737937
2026-05-06 22:16:55 -07:00
Google Team Member b58ce57b67 chore: Enable gemini EAP models for gemini-builtin tools
PiperOrigin-RevId: 911554133
2026-05-06 14:35:42 -07:00
Xuan Yang 211e2ceb70 fix: skipping state_delta overwrite on function_response-only events
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 911411431
2026-05-06 10:22:37 -07:00
Google Team Member 83f981761b fix: Raise a clear actionable error when CustomAuthScheme lacks a registered AuthProvider
PiperOrigin-RevId: 911115744
2026-05-05 22:45:03 -07:00
Kathy Wu 01f1fc9c91 fix: Only append skills to system instruction if ListSkillsTool isn't available
This reduces the token usage of having skills appended to the instruction on every call

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 910904229
2026-05-05 14:11:06 -07:00
George Weale 3a1eadce66 fix: use asyncio.sleep to avoid blocking event loop
Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 910839657
2026-05-05 12:19:00 -07:00
Kathy Wu 398f28feb4 fix: Use project and location instead of API key when deploying to agent engine
Deploying using API key has been leading to "Deploy failed: 'NoneType' object has no attribute 'before_request'" errors because creating cloud resources requires ADC credentials (project id and region)

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 910821145
2026-05-05 11:49:11 -07:00
Xuan Yang 92c06fe55d fix: Mock subprocess.run in test_cli_deploy to avoid gcloud calls
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 910796426
2026-05-05 11:10:44 -07:00