Skip to content

chore: sync main -> v2#4915

Open
Jacksunwei wants to merge 112 commits intov2from
main
Open

chore: sync main -> v2#4915
Jacksunwei wants to merge 112 commits intov2from
main

Conversation

@Jacksunwei
Copy link
Copy Markdown
Collaborator

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.

google-genai-bot and others added 30 commits March 10, 2026 21:29
…viderRegistry within CredentialManager

The flow for integrating a new auth method will be as follows. The ADK framework contributor will
1. extend the `AuthScheme` to create their own within `adk/auth/auth_scheme.py`
2. implement `BaseAuthProvider` within their dedicated directory in `adk/integrations/auth`
3. do the static registration of the new scheme and provider with AuthProviderRegistry of CredentialManager.

PiperOrigin-RevId: 881775983
PiperOrigin-RevId: 881782296
The _update_type_string function now recursively processes "properties" at any level of the schema, ensuring that all "type" fields within nested objects are correctly lowercased. This improves handling of complex

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 882050939
Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 882192675
This change adds logic to extract and re-embed the `thought_signature` field associated with function calls in Gemini models when converting between LiteLLM's ChatCompletionMessageToolCall and ADK's types.Part

Close #4650

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 882212223
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 882212923
The `can_use_output_schema_with_tools` function now checks if a model is a LiteLlm instance by inspecting its type's Method Resolution Order, rather than directly importing `LiteLlm`

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 882253446
V4 still uses deprecated Node.js 20.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 882275971
Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 882293566
Co-authored-by: Liang Wu <18244712+wuliang229@users.noreply.github.com>
Co-authored-by: Guoyi Lou <guoyilou@google.com>
PiperOrigin-RevId: 882787811
Merge #4622

Co-authored-by: Xuan Yang <xygoogle@google.com>
COPYBARA_INTEGRATE_REVIEW=#4622 from rohityan:feat/IssueWatchdog 5609370
PiperOrigin-RevId: 882987318
This change introduces a new interceptor that adds the 'https://google.github.io/adk-docs/a2a/a2a-extension/' extension to the request headers in the A2A client from the RemoteAgent side. To send this extension along with requests, the RemoteAgent has to be instantiated with the `use_legacy` flag set to False. The AgentExecutor will default to the new implementation when this extension is requested by the client, but this behavior can be disabled via the `use_legacy` flag.
The 'force_new' flag on the agent_executor side can be used to bypass the presence of the extension, and always activate the new version of the agent_executor.

PiperOrigin-RevId: 883021792
Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 883246168
…creation due to missing version field

Co-authored-by: Achuth Narayan Rajagopal <achuthr@google.com>
PiperOrigin-RevId: 883336463
Merge #4833

Syncs version bump and CHANGELOG from release v1.27.1 to main.

COPYBARA_INTEGRATE_REVIEW=#4833 from google:release/v1.27.1 bc1b500
PiperOrigin-RevId: 883394436
Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 883401159
Merge #4718

### Link to Issue or Description of Change

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

- Closes: N/A
- Related: N/A

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

**Problem**

ADK’s MCP integration currently does not expose the MCP sampling callback capability.
This prevents agent-side LLM sampling handlers from being used when interacting with MCP servers that support sampling.

The MCP Python SDK supports sampling callbacks, but these parameters are not propagated through the ADK MCP integration layers.

**Solution**

Add sampling callback support by propagating the parameters through the MCP stack:

- Add `sampling_callback` and `sampling_capabilities` parameters to `McpToolset`
- Forward them to `MCPSessionManager`
- Forward them to `SessionContext`
- Pass them into `ClientSession` initialization

This enables agent-side sampling handling when interacting with MCP servers.

---

### Testing Plan

**Unit Tests**

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

Added `test_mcp_sampling_callback.py` to verify that the sampling callback is correctly invoked.

Example result:
pytest tests/unittests/tools/mcp_tool/test_mcp_sampling_callback.py
1 passed

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

Manual testing was performed using a FastMCP sampling example server where the sampling callback was invoked from the agent side and returned the expected response.

---

### Checklist

- [x] I have read the CONTRIBUTING.md document.
- [x] I have performed a self-review of my own code.
- [x] I have commented my code where necessary.
- [x] I have added tests proving the feature works.
- [x] Unit tests pass locally.
- [x] I have manually tested the change end-to-end.

---

### Additional context

This change aligns ADK MCP support with the sampling capabilities available in the MCP Python SDK and enables agent implementations to handle sampling requests via a callback.

Co-authored-by: Kathy Wu <wukathy@google.com>
COPYBARA_INTEGRATE_REVIEW=#4718 from Piyushmrya:fix-mcp-sampling-callback 18f477f
PiperOrigin-RevId: 883401178
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 883401885
Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 883403479
Closes issue #4805

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 883403628
…-2-preview

The gemini-embedding-2-preview model requires the Vertex AI
:embedContent endpoint instead of the legacy :predict endpoint used
by older models (text-embedding-004, text-embedding-005).

In google-genai <1.64.0, embed_content() unconditionally routed to
:predict on Vertex AI, which returns FAILED_PRECONDITION for this
model.

v1.64.0 (googleapis/python-genai@af40cc6) introduced model-aware
dispatch in embed_content(): models with "gemini" in the name are
routed to :embedContent via t_is_vertex_embed_content_model(), while
older text-embedding-* models continue to use :predict.

This version also enforces a single-content-per-call limit for the
embedContent API, which is why FilesRetrieval sets embed_batch_size=1.

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 883689438
…provision an Agent Engine if neither agent_engine_resource_name nor sandbox_resource_name is provided

The AgentEngineSandboxCodeExecutor now has three initialization modes:
1.  Create both an Agent Engine and sandbox if neither resource name is provided.
2.  Creating a new sandbox within a provided agent_engine_resource_name.
3.  Using a provided sandbox_resource_name.

PiperOrigin-RevId: 884088248
… 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
google-genai-bot and others added 30 commits March 26, 2026 10:16
PiperOrigin-RevId: 889912199
- Migrate `tools/bigquery` to `integrations/bigquery` to match standard ADK layout.
- Update unit tests to fully assert integration migration.

Co-authored-by: Haiyuan Cao <haiyuan@google.com>
PiperOrigin-RevId: 889963735
PiperOrigin-RevId: 889992570
… default

Co-authored-by: Sasha Sobran <asobran@google.com>
PiperOrigin-RevId: 890025323
…definitions

The list_agents method in AgentLoader no longer attempts to determine the agent language for each directory

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 890078066
Merge #5016

Syncs version bump and CHANGELOG from release v1.28.0 to main.

COPYBARA_INTEGRATE_REVIEW=#5016 from google:release/v1.28.0 4e05efb
PiperOrigin-RevId: 890122693
…r session management

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 890127075
The workflow now accepts a `release_branch` input, checks out the specified release branch, and updates the version in `src/google/adk/version.py`

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 890134954
…ponses

Close: #4609

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 890144644
When an MCP server (or any toolset) is unavailable or raises an
exception during get_tools(), the error previously propagated uncaught
through _convert_tool_union_to_tools() and canonical_tools(), crashing
the entire agent silently with no log output.

This change wraps the toolset.get_tools_with_prefix() call in a
try-except that catches exceptions, logs a warning with the toolset
class name and error details, and returns an empty tool list. This
allows the agent to continue operating with tools from other working
toolsets.

The fix preserves the existing retry behavior — McpToolset's
@retry_on_errors decorator still attempts reconnection before the
error reaches this handler. On subsequent agent invocations,
get_tools() is called again, naturally retrying the connection.

Fixes: #3341

Co-authored-by: Xiang (Sean) Zhou <seanzhougoogle@google.com>
PiperOrigin-RevId: 890512146
The deep_merge_dicts function will now extend lists when merging dictionaries, instead of overwriting them.

Co-authored-by: Vishwa Murugan <vishwamurugan@google.com>
PiperOrigin-RevId: 890531331
… ExpressMode and GCP projects

Otherwise we get errors of the form: `Project/location and API key are mutually exclusive in the client initializer` (https://github.com/googleapis/python-genai/blob/1ccad7b70ae1068cb5f3e866ad7ca4d42aa55e1e/google/genai/_api_client.py#L590-L591).

Co-authored-by: Yeesian Ng <ysian@google.com>
PiperOrigin-RevId: 890588927
PiperOrigin-RevId: 890595289
This PR updates the `toolbox-adk` package version in the `pyproject.toml` and also updates the MCP Toolbox server version to the latest in the docs.

PiperOrigin-RevId: 890633573
…ecution

This change introduces a new EnvironmentToolset within the ADK, providing tools to interact with a BaseEnvironment. The toolset includes Execute, ReadFile, EditFile, WriteFile. System instructions are injected to guide the LLM on workspace usage and file manipulation.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 890672569
…le I/O locally

This change introduces the LocalEnvironment class, which allows agents to execute shell commands and perform file operations using asyncio subprocesses on the local machine. It includes support for a working directory and custom environment variables. A sample agent configuration is also added to demonstrate its usage.

Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 890685517
Co-authored-by: Shangjie Chen <deanchen@google.com>
PiperOrigin-RevId: 890694124
Merge #4842

### Link to Issue or Description of Change
**1. Link to an existing issue**

Closes #4841

**2. Changes**
This change aligns SSE transport behavior with Streamable HTTP transport for MCP tools, enabling users to customize the httpx.AsyncClient for SSE-based MCP connections (e.g., proxy, auth, TLS config).

- Update `SseConnectionParams` model to include httpx_client_factory parameter (matching StreamableHTTPConnectionParams pattern)
- Pass `httpx_client_factory` from `SseConnectionParams` to underlying `sse_client()` call
- Add `model_config` to `SseConnectionParams` to allow arbitrary types for the factory function
- Update docstrings to document the new `httpx_client_factory attribute`
- Add unit test for new senarios

### Testing Plan

**Unit Tests:**

- [x] I have added or updated unit tests for my change.
    - `tests/unittests/tools/mcp_tool/test_mcp_session_manager.py`
- [x] All unit tests pass locally.
    - All test cases have passed the test.

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

1. Set custom httpx_client_factory parameter for SseConnectionParams
```Python
from typing import Any

import httpx
from google.adk.agents.llm_agent import Agent
from google.adk.models import LiteLlm
from google.adk.tools.mcp_tool import SseConnectionParams, McpToolset

# Cutom httpx client factory for MCP SSE transport
def custom_httpx_client_factory(
    headers: dict[str, str] | None = None,
    timeout: httpx.Timeout | None = None,
    auth: httpx.Auth | None = None,
) -> httpx.AsyncClient:
    # Print message for debugging
    print(' === Custom httpx_client_factory running! ===')
    kwargs: dict[str, Any] = {
        "follow_redirects": True,
    }
    if timeout is None:
        kwargs["timeout"] = httpx.Timeout(30, read=300)
    else:
        kwargs["timeout"] = timeout
    if headers is not None:
        kwargs["headers"] = headers
    if auth is not None:
        kwargs["auth"] = auth
    return httpx.AsyncClient(**kwargs)

connection_params = SseConnectionParams(
    url='http://127.0.0.1:9000/sse',
    httpx_client_factory=custom_httpx_client_factory, # Custom httpx client factory
)

tool = McpToolset(connection_params=connection_params)

root_agent = Agent(
    model=LiteLlm(model="ollama_chat/qwen3.5:35b-a3b-q4_K_M"),
    name='root_agent',
    description='A helpful assistant for user questions.',
    instruction='Answer user questions to the best of your knowledge',
    tools=[tool],
)
```

2.  Run the Agent, and display the debug log in console
```
2026-03-15 23:54:14,304 - INFO - agent_loader.py:130 - Found root_agent in my_agent.agent
INFO:     127.0.0.1:55642 - "POST /run_sse HTTP/1.1" 200 OK
 === Custom httpx_client_factory running! ===
2026-03-15 23:54:14,345 - INFO - _client.py:1740 - HTTP Request: GET http://127.0.0.1:9000/sse "HTTP/1.1 200 OK"
2026-03-15 23:54:14,349 - INFO - _client.py:1740 - HTTP Request: POST http://127.0.0.1:9000/messages/?session_id=b5750c6e214048c28110dff11c412ecb "HTTP/1.1 202 Accepted"
```

### 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.

### Additional context

Co-authored-by: Kathy Wu <wukathy@google.com>
COPYBARA_INTEGRATE_REVIEW=#4842 from ushelp:main e3125fb
PiperOrigin-RevId: 890708694
- Add 1P BQ Skills  `bigquery-ai-ml`, add mandatory reference routing and reference file for `AI.*` syntax.
- Include dedicated reference documents for various BigQuery ML features.
- Update unit tests to fully assert skill validations.

Co-authored-by: Haiyuan Cao <haiyuan@google.com>
PiperOrigin-RevId: 890749300
Revert global list extension in deep_merge_dicts and instead explicitly handle list extension only for render_ui_widgets in merge_parallel_function_response_events.

Co-authored-by: Vishwa Murugan <vishwamurugan@google.com>
PiperOrigin-RevId: 891147765
Close: #4671

Co-authored-by: Xuan Yang <xygoogle@google.com>
PiperOrigin-RevId: 891827874
…n intermediate data

PiperOrigin-RevId: 891846041
This reduces latency by avoiding redudant network calls

Co-authored-by: Kathy Wu <wukathy@google.com>
PiperOrigin-RevId: 891931454
Moved `before_model_callback` inside the `call_llm` span.
Wrapped both `after_model_callback` and error callbacks with `trace.use_span()` to bind callbacks to the correct overarching span.
Added regression tests to verify span ID consistency.

Co-authored-by: Haiyuan Cao <haiyuan@google.com>
PiperOrigin-RevId: 891952170
Co-authored-by: Liang Wu <wuliang@google.com>
PiperOrigin-RevId: 891960308
Fixes an issue where the Agent Analytics plugin could log plain-text
OAuth credentials and access tokens to BigQuery. Sensitive keys are
now redacted.

Co-authored-by: Haiyuan Cao <haiyuan@google.com>
PiperOrigin-RevId: 891963630
…into an isolated snapshot sequence before starting loop

_list_sessions_impl intermittently would throw `RuntimeError: dictionary changed size during iteration`

Co-authored-by: Ankur Sharma <ankusharma@google.com>
PiperOrigin-RevId: 892454902
PiperOrigin-RevId: 892466615
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.