Skip to content

Commit 530ff06

Browse files
vishwa180copybara-github
authored andcommitted
feat: Add UiWidget to EventActions for supporting new experimental UI Widgets feature
Co-authored-by: Vishwa Murugan <vishwamurugan@google.com> PiperOrigin-RevId: 881099147
1 parent d6f31be commit 530ff06

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

src/google/adk/events/event_actions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from ..auth.auth_tool import AuthConfig
2727
from ..tools.tool_confirmation import ToolConfirmation
28+
from .ui_widget import UiWidget
2829

2930

3031
class EventCompaction(BaseModel):
@@ -108,3 +109,6 @@ class EventActions(BaseModel):
108109

109110
rewind_before_invocation_id: Optional[str] = None
110111
"""The invocation id to rewind to. This is only set for rewind event."""
112+
113+
render_ui_widgets: Optional[list[UiWidget]] = None
114+
"""List of UI widgets to be rendered by the UI."""

src/google/adk/events/ui_widget.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import annotations
16+
17+
from typing import Any
18+
19+
from pydantic import alias_generators
20+
from pydantic import BaseModel
21+
from pydantic import ConfigDict
22+
from pydantic import Field
23+
24+
25+
class UiWidget(BaseModel):
26+
"""Rendering metadata for a UI widget associated with an event.
27+
28+
When present on an Event.actions, the UI renders the widget using the
29+
specified provider's renderer component.
30+
"""
31+
32+
model_config = ConfigDict(
33+
extra='forbid',
34+
alias_generator=alias_generators.to_camel,
35+
populate_by_name=True,
36+
)
37+
38+
id: str
39+
"""The unique identifier of the UI widget."""
40+
41+
provider: str
42+
"""Widget provider identifier. Determines which rendering strategy
43+
the UI uses.
44+
45+
Known values:
46+
- 'mcp': MCP App iframe, rendered with the MCP Apps AppBridge.
47+
"""
48+
49+
payload: dict[str, Any] = Field(default_factory=dict)
50+
"""Provider-specific data required for rendering.
51+
52+
If provider is 'mcp', the payload is a dictionary with the following fields:
53+
{
54+
"resource_uri: "ui://...",
55+
"tool": {...},
56+
"tool_args": {...}
57+
}
58+
Future providers can have their set of payload fields.
59+
"""

0 commit comments

Comments
 (0)