Open
Conversation
… execute_sql to support fine grained access controls PiperOrigin-RevId: 884166439
The metric takes into account all the turns of the multi-turn conversation. The class delegates the responsibility to Vertex Gen AI Eval SDK. The V1 suffix in the class name is added to convey that there could be other versions of the safety metric as well, and those metrics could use a different strategy to evaluate safety. Co-authored-by: Ankur Sharma <ankusharma@google.com> PiperOrigin-RevId: 884504910
Tool use: The class delegates the responsibility to Vertex Gen AI Eval SDK. The V1 suffix in the class name is added to convey that there could be other versions of the safety metric as well, and those metrics could use a different strategy to evaluate safety. Task trajectory: this metric is different from `Multi-Turn Overall Task Success`, in the sense that task success only concerns itself with the goal of whether the success was achieved or not. How that was achieved is not its concern. This metric on the other hand does care about the path that agent took to achieve the goal. Co-authored-by: Ankur Sharma <ankusharma@google.com> PiperOrigin-RevId: 884525532
Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 884557773
When using OAuth2Session with `client_secret_post`, Authlib automatically includes the client_id and client_secret in the request body. Explicitly passing `client_id` again results in a duplicate parameter in the token exchange request, which can cause issues with some OAuth providers. Close #4782 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 884574091
this sample can be used to test the latest gemini embedding model Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com> PiperOrigin-RevId: 884574396
Merge #4818 **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 **2. Or, if no issue exists, describe the change:** **Problem:** `src/google/adk/models/google_llm.py` includes a mitigation link for `429 RESOURCE_EXHAUSTED`, but the current URL points to a broken docs anchor: https://google.github.io/adk-docs/agents/models/#error-code-429-resource_exhausted <img width="1067" height="640" alt="image" src="https://github.com/user-attachments/assets/8aee07da-3007-4312-93d3-161321c01f2f" /> **Solution:** Update the link to the current Gemini-specific docs page so users are directed to the correct troubleshooting section: https://google.github.io/adk-docs/agents/models/google-gemini/#error-code-429-resource_exhausted <img width="1161" height="732" alt="image" src="https://github.com/user-attachments/assets/1badf7ab-9411-4f56-a719-6ba2a61ca7ce" /> ### Testing Plan This is a small string-only fix for a broken documentation link. No unit tests were added because there does not appear to be existing test coverage for this message and the change does not affect runtime behavior beyond the emitted URL. **Unit Tests:** - [ ] I have added or updated unit tests for my change. - [ ] All unit tests pass locally. _Please include a summary of passed `pytest` results._ **Manual End-to-End (E2E) Tests:** Confirmed the updated URL in the source points to the intended documentation page/anchor. ### 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. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] New and existing unit tests pass locally with my changes. - [x] I have manually tested my changes end-to-end. - [ ] Any dependent changes have been merged and published in downstream modules. ### Additional context This change only updates the documentation URL shown in the `RESOURCE_EXHAUSTED` guidance message. COPYBARA_INTEGRATE_REVIEW=#4818 from ftnext:fix-429-doc-link 1c53345 PiperOrigin-RevId: 884581120
PiperOrigin-RevId: 884597343
The previous test for unmapped LiteLLM finish_reason values was ineffective because LiteLLM's internal models normalize certain values (e.g., "eos" to "stop") before ADK processes them Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 884678119
Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 884686010
This change introduces a new `SpannerAdminToolset` with tools for managing Google Cloud Spanner resources. The toolset includes functions to list and get details of Spanner instances and instance configurations, and to create, list databases. The new toolset is marked as experimental. Unit tests for the new admin tools are also added PiperOrigin-RevId: 885116111
The Vertex AI session service does not natively support persisting usage_metadata. This change serializes usage_metadata into the custom_metadata field under the key '_usage_metadata' when appending events and deserializes it back when retrieving events. This allows usage information to be round-tripped through the Vertex AI session service. Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 885121070
…ntegration This change enables the LiteLLM adapter to correctly parse and generate Anthropic's structured "thinking_blocks" format, which includes a "signature" for each thought block. The "signature" is crucial for Anthropic models to maintain their reasoning state across multiple turns, particularly when tool calls are made Close #4801 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 885131757
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com> PiperOrigin-RevId: 885138365
When PR #2872 migrated RestApiTool from requests (sync) to httpx.AsyncClient (async), the _request function was left without an explicit timeout parameter. Unlike requests which has no default timeout, httpx defaults to 5 seconds — causing ReadTimeout errors for any API call exceeding that limit. This regression blocked users from upgrading past 1.23.0. Set timeout=None on httpx.AsyncClient to restore parity with the previous requests-based behavior (no timeout). Fixes #4431 Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com> PiperOrigin-RevId: 885287948
This change introduces optimistic concurrency control for session updates. Instead of automatically reloading and merging when an append is attempted on a session that has been modified in storage, the service now raises a ValueError. Close #4751 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 885334444
…tracing into environment simulation PiperOrigin-RevId: 885759367
…ing to LiveConnectConfig RunConfig.response_modalities is typed as list[str] for backward compatibility, but LiveConnectConfig.response_modalities expects list[Modality] (an enum). Assigning strings directly causes a Pydantic serialization warning on every live streaming session: PydanticSerializationUnexpectedValue(Expected `enum` - serialized value may not be as expected [field_name='response_modalities', input_value='AUDIO', input_type=str]) Convert each modality value to types.Modality at the assignment point in basic.py using types.Modality(m), which is a no-op for values that are already Modality enums and converts plain strings like "AUDIO" to Modality.AUDIO. The public RunConfig interface remains list[str] so existing callers are unaffected. Fixes: #4869 Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com> PiperOrigin-RevId: 885781014
Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 885801247
Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 885813216
Co-authored-by: Kathy Wu <wukathy@google.com> PiperOrigin-RevId: 885814460
Co-authored-by: Xuan Yang <xygoogle@google.com> PiperOrigin-RevId: 885829552
Merge #4780 ## Bug `AnthropicLlm.part_to_message_block()` only serializes `FunctionResponse.response` dicts that contain a `"content"` or `"result"` key. When neither key is present the variable `content` stays as `""` and an empty `ToolResultBlockParam` is sent to Claude. This silently drops the output of several `SkillToolset` tools: | Tool | Keys returned | Handled before this fix? | |---|---|---| | `load_skill` (success) | `skill_name`, `instructions`, `frontmatter` | **No** | | `run_skill_script` (success) | `skill_name`, `script_path`, `stdout`, `stderr`, `status` | **No** | | Any skill tool (error) | `error`, `error_code` | **No** | | `load_skill_resource` (success) | `skill_name`, `path`, `content` | Yes (`"content"` key) | Because `load_skill` is the entry-point for skill instructions, Claude models using `SkillToolset` **never received skill instructions**, making the feature completely non-functional with Anthropic models. ## Fix Added an `else` branch in `part_to_message_block()` that JSON-serializes the full response dict when neither `"content"` nor `"result"` is present: ```python elif response_data: # Fallback: serialize the entire response dict as JSON so that tools # returning arbitrary key structures (e.g. load_skill returning # {"skill_name", "instructions", "frontmatter"}) are not silently # dropped. content = json.dumps(response_data) ``` This is consistent with how Gemini handles it — the Gemini integration passes `types.Part` objects directly to the Google GenAI SDK which serializes them natively, so there is no key-based filtering at all. ## Testing plan Added 4 new unit tests to `tests/unittests/models/test_anthropic_llm.py`: - `test_part_to_message_block_arbitrary_dict_serialized_as_json` — covers the `load_skill` response shape - `test_part_to_message_block_run_skill_script_response` — covers the `run_skill_script` response shape - `test_part_to_message_block_error_response_not_dropped` — covers error dict responses - `test_part_to_message_block_empty_response_stays_empty` — ensures empty dict still produces empty content (no regression) All 35 tests in `test_anthropic_llm.py` pass: ``` 35 passed in 7.32s ``` Run with: ```bash uv sync --extra test pytest tests/unittests/models/test_anthropic_llm.py -v ``` Co-authored-by: Kathy Wu <wukathy@google.com> COPYBARA_INTEGRATE_REVIEW=#4780 from akashbangad:fix/anthropic-llm-skill-toolset-fallback c23ad37 PiperOrigin-RevId: 885831845
Renames the imported module from `agentic_sandbox` to `k8s_agent_sandbox` in `gke_code_executor.py` and updates the required version in `pyproject.toml` to `>=0.1.1.post3`. Closes #4883 Co-authored-by: Liang Wu <wuliang@google.com> PiperOrigin-RevId: 885840142
- Introduced a new `AuthScheme` named `GcpIamConnectorAuth` in `google.adk.integrations.iam_connector` package. - The feature is currently disabled through the newly added `GCP_IAM_CONNECTOR_AUTH`experimentation flag. - The newly added `GcpAuthProvider` class in `adk/integrations/iam_connector/gcp_auth_provider.py` is for internal ADK use and developer should not depend on it. PiperOrigin-RevId: 886070137
PiperOrigin-RevId: 886119834
The ADK experimental warnings can already be disabled with an environment variable, enable the same behavior for A2A to avoid log spam. Co-authored-by: Tim Niemueller <timdn@google.com> PiperOrigin-RevId: 886233489
This change introduces a separate async session factory for Spanner connections configured with `read_only=True` Close #4771 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 886267104
Co-authored-by: Sasha Sobran <asobran@google.com> PiperOrigin-RevId: 905101547
…s Plugin ### Changes **1. Pickle safety — try-preserve, fallback-drop** `__getstate__` tests whether `_user_credentials` is picklable: - **Picklable** (service-account, `AnonymousCredentials`): preserved — survives pickle and restored via `__setstate__` so the plugin uses the user's identity after unpickle. - **Non-picklable** (`compute_engine.Credentials` with `requests.Session`): dropped gracefully — falls back to ADC after unpickle. `_credentials` (the active/resolved credentials) is always cleared since it may hold resolved ADC state. On unpickle, `__setstate__` restores it from `_user_credentials` when available. **2. Fork safety — documented user-provided credential limitation** `_reset_runtime_state()` sets `_credentials = _user_credentials`. For ADC-resolved credentials (`_user_credentials is None`), this clears stale credentials for re-resolution. For user-provided credentials, the original object is kept — we cannot re-create it. The comment documents this: the user is responsible for providing fork-safe credentials. **3. GCS client — credentials passed correctly** `GCSOffloader.__init__` always creates a `storage.Client` eagerly (`storage_client or storage.Client(...)` at line 1329). This was also true before the credentials commit. The fix passes explicit credentials when available and lets ADC resolve when not, matching the `bigquery.Client` and `BigQueryWriteAsyncClient` patterns. **4. Benign race on `_credentials` resolution documented** When multiple event loops call `_create_loop_state()` concurrently, both can resolve ADC redundantly. This is idempotent and benign, now documented. Co-authored-by: Haiyuan Cao <haiyuan@google.com> PiperOrigin-RevId: 905111076
Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 905152209
Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 905187116
Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905207529
…ource The user_id for PubSub triggers is now derived from the subscription name with slashes replaced by double hyphens. Similarly, for Eventarc triggers, the source is sanitized by stripping leading/trailing slashes and replacing internal slashes with double hyphens. This ensures that the user_id is a valid identifier without path separators. Close #5324 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905219387
This change modifies the LLM event summarizer to extract the usage_metadata from the LLM's generate content response and include it in the newly created compacted Event Close #4014 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905222465
During session rewind, when restoring an artifact to a previous version, the runner now uses `artifact_service.load_artifact` to fetch the artifact's content. Previously, it would construct a `types.Part` with `file_data` using the artifact URI. This change is necessary because some artifact services, such as those backed by GCS or local files, do not support saving `types.Part` objects that contain `file_data` Close #4932 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905223401
This change introduces an `api_version` field in `GoogleLLMConfig`, allowing users to specify a custom API version for Gemini requests Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905226089
Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905226545
Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905227934
Parallel tool calls writing list values to the same state_delta key were silently dropped because deep_merge_dicts only recursed into dict values; lists hit the overwrite branch. Closes #5190 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905229706
Remove `location=self.location` from the `bigquery.Client()` constructor. When the client has no default location and `client.query(sql)` is called without an explicit `location` parameter, the BQ API infers the job location from the dataset referenced in the DDL statement. Traced through the BQ Python client: 1. `client.query(sql)` — `location` param defaults to `None`, falls back to `self.location` which is also `None` 2. `_to_query_request()` — when `location is None`, the `"location"` key is **not included** in the API request 3. BQ API — infers location from the dataset referenced in `CREATE OR REPLACE VIEW` **One line of production code changed.** Everything else is test updates. | Operation | Before | After | |---|---|---| | Table CRUD | Works | Same | | Storage Write API | Works | Same | | View creation (non-US dataset) | **Silent failure** | **Works** — BQ infers location | Co-authored-by: Haiyuan Cao <haiyuan@google.com> PiperOrigin-RevId: 905242480
Function call IDs are now preserved during session replay for Anthropic models, matching the behavior of Gemini models using the interactions API. Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905250493
_call_tool_in_thread_pool used None as a sentinel to distinguish "FunctionTool ran successfully" from "non-FunctionTool sync tool, needs async fallback". When a sync FunctionTool's function legitimately returned None, the sentinel check fell through to tool.run_async() and re-invoked the underlying function. Restructure the dispatch so the sync-FunctionTool path returns directly and the non-FunctionTool sync path falls through explicitly, removing the ambiguous sentinel. Close #5284 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905258186
Documents the existing subclass pattern (cached_property override of api_client) so users with non-default genai.Client config — location, project, credentials, http_options — find it without trial and error. Several #3628 commenters rediscovered this independently; making it discoverable in the class docstring should reduce repeat issues. Replaces an earlier draft of this CL that added a public client= field on Gemini. The framework already supports the use case via subclassing, so a docstring expansion is sufficient and avoids new public API. Close #3628 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905258437
Same fix applied to the matching helpers in google.adk.telemetry. Close #5412 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905265632
The rewind logic is updated to ensure that state keys set during session creation are not nullified when rewinding. Previously, any key not present in the state at the rewind point was removed. Now, only keys that have appeared in any event's state delta are considered for nullification during a rewind, preventing the removal of initial session state Close #4933 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905271916
This change enables the use of Anthropic's thinking feature by mapping the GenerateContentConfig.thinking_config to the Anthropic API's `thinking` parameter. It includes handling for both non-streaming and streaming responses, converting Anthropic's ThinkingBlock and ThinkingDelta into types.Part objects with `thought=True`. Redacted thinking blocks are preserved as Parts with the encrypted blob in `thought_signature`, so they round-trip back to Claude on subsequent turns. Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905273540
…rty module detection for sample scripts across different CI environments Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 905278958
PiperOrigin-RevId: 905280434
LiteLLM/OpenAI reject `audio_url` content blocks (the API accepts `input_audio` with raw base64 + a `format` field). Audio inline_data was either silently dropped or rejected with a BadRequestError. Close #5406 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905286679
When a tool execution fails in a parallel batch, we now cancel all other pending tools in that batch and propagate the exception, instead of letting them run as orphaned tasks. Co-authored-by: Sasha Sobran <asobran@google.com> PiperOrigin-RevId: 905286925
Parallel tool calls writing list values to the same state_delta key were silently dropped because deep_merge_dicts only recursed into dict values; lists hit the overwrite branch. Closes #5190 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905300264
This change introduces a new helper function `_summarize_events_with_trace` to wrap the event summarization process. This function creates a trace span and records metadata about the compaction trigger, summarizer type, event count, and configuration parameters both before and after the summarization occurs. The existing compaction logic is updated to use this new traced function. Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 905302520
The rewind logic is updated to ensure that state keys set during session creation are not nullified when rewinding. Previously, any key not present in the state at the rewind point was removed. Now, only keys that have appeared in any event's state delta are considered for nullification during a rewind, preventing the removal of initial session state Close #4933 PiperOrigin-RevId: 905322038
Co-authored-by: Shangjie Chen <deanchen@google.com> PiperOrigin-RevId: 905354260
Merge #5295 ## Summary Fixes #5294. This PR tightens `VertexAiRagMemoryService` memory scoping by replacing the ambiguous dot-delimited RAG `display_name` format with an encoded v1 format for new uploads. Search results are now parsed into exact `app_name`, `user_id`, and `session_id` components before being accepted. The change also keeps compatibility for old unambiguous legacy display names in the exact `app.user.session` form, while ignoring ambiguous legacy names that contain extra dot-delimited components. ## Why The previous client-side filter used: ```python context.source_display_name.startswith(f"{app_name}.{user_id}.") ``` That can collide for IDs such as `alice` and `alice.smith`, allowing memory stored under `demo.alice.smith.*` to pass a lookup for `demo` / `alice`. ## Tests ```text PYTHONPATH=src python -m pytest tests/unittests/memory -q 42 passed, 2 warnings python -m isort --check-only src/google/adk/memory/vertex_ai_rag_memory_service.py tests/unittests/memory/test_vertex_ai_rag_memory_service.py passed python -m pyink --check --config pyproject.toml src/google/adk/memory/vertex_ai_rag_memory_service.py tests/unittests/memory/test_vertex_ai_rag_memory_service.py passed git diff --check -- src/google/adk/memory/vertex_ai_rag_memory_service.py tests/unittests/memory/test_vertex_ai_rag_memory_service.py passed ``` ## Checklist - [x] I have read the CONTRIBUTING.md document. - [x] I have performed a self-review of my own code. - [x] I have added tests that prove my fix is effective. - [x] New and existing unit tests pass locally with my changes. COPYBARA_INTEGRATE_REVIEW=#5295 from petrmarinec:fix/vertex-rag-memory-scope 64a8f5a PiperOrigin-RevId: 905365796
Merge #5343 ## Summary Fixes #5341 — `convert_genai_part_to_a2a_part()` drops `Part(text='')` because the truthiness check `if part.text:` treats empty strings as falsy. ## Root Cause `Part(text='')` is valid and is produced in at least two places in the ADK: 1. **`code_executors/code_execution_utils.py`** — when code execution completes with `None` output 2. **`models/interactions_utils.py`** — when the Interactions API returns `None` text content Gemini 2.5 Flash (thinking mode) also emits empty text parts. When the converter drops all parts the A2A message ends up with zero parts and the client sees "broken thinking" with no content. ## Fix Change line 182 from `if part.text:` to `if part.text is not None:` so that empty strings are correctly wrapped as `TextPart` while `None` is still skipped. ## Test Added `test_convert_empty_text_part` — verifies that `Part(text='')` produces a valid `TextPart(text='')` instead of returning `None`. COPYBARA_INTEGRATE_REVIEW=#5343 from voidborne-d:fix/part-converter-empty-text dbb2f20 PiperOrigin-RevId: 905370961
… detection to schema resolution PiperOrigin-RevId: 905576545
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated sync of v1 changes from main into v2. The oncall is responsible for reviewing and merging this PR. Resolve conflicts in favor of the v2 implementation.