Add InputData.type_metadata Field Feature
Overview
This feature adds an optional type_metadata string field to InputData that flows through to UIBlockConfiguration as data_type_metadata. The primary use case is passing tool call arguments used to load data, enabling the frontend to refresh data using the same parameters.
Core Type Changes
1. Update [libs/next_gen_ui_agent/types.py](libs/next_gen_ui_agent/types.py)
InputData TypedDict (line ~268):
- Add new optional field:
type_metadata: NotRequired[str | None] - Description: "Optional type specific metadata, passed to the renderer. For example Tool call arguments used to load these data can be passed this way."
UIBlockConfiguration Pydantic model (line ~399):
- Add new optional field:
data_type_metadata: Optional[str] - Description: "Optional type specific metadata from InputData, passed to the renderer. For example Tool call arguments used to load the data can be used by frontend to refresh data."
- Place after
data_typefield for logical grouping
Agent Core Logic
2. Update [libs/next_gen_ui_agent/agent.py](libs/next_gen_ui_agent/agent.py)
In construct_UIBlockConfiguration method (line ~206):
- Extract
type_metadatafrominput_datausinginput_data.get("type_metadata") - Pass it to
UIBlockConfigurationconstructor asdata_type_metadataparameter - Location: Around line 240 where
UIBlockConfigurationis created
Agent Core Tests
3. Update [libs/next_gen_ui_agent/agent_test.py](libs/next_gen_ui_agent/agent_test.py)
Add new test in TestConstructUIBlockConfiguration class (after line ~887):
- Test name:
test_construct_UIBlockConfiguration_with_type_metadata - Create
InputDatawithtype_metadata='{"arg1": "value1"}' - Create
UIComponentMetadatawith standard fields - Call
agent.construct_UIBlockConfiguration() - Assert
configuration.data_type_metadata == '{"arg1": "value1"}'
Update existing test (line ~620):
test_construct_UIBlockConfiguration_all_info: Addtype_metadatato input and assert it's preserved- Add assertion:
assert configuration.data_type_metadata == <expected_value>
Documentation
4. Update [docs/guide/input_data/index.md](docs/guide/input_data/index.md)
In "InputData object fields" section (after line ~22):
- Add new bullet point after
typefield description - Content:
* type_metadata- optional string with type specific metadata passed to the renderer. Example: JSON-serialized tool call arguments used to load the data, enabling frontend to refresh data with same parameters.
MCP Protocol Integration
5. Update [libs/next_gen_ui_mcp/agent.py](libs/next_gen_ui_mcp/agent.py)
In generate_ui_component tool (line ~270):
- Add new parameter after
data_type(around line ~302):- Name:
data_type_metadata - Type:
Annotated[str | None, Field(...)] - Default:
None - Description via
_get_argument_description(): "Arguments of tool call used for 'data' argument. COPY of tool arguments. Do not change anything! NEVER generate this."
- Name:
- Pass
type_metadata=data_type_metadatawhen creatingInputDataobject (line ~329)
In generate_ui_multiple_components tool (line ~372):
- Update
structured_dataargument description to mention the newtype_metadatafield - The field should already work since
InputDataTypedDict is used directly
6. Update [libs/next_gen_ui_mcp/README.md](libs/next_gen_ui_mcp/README.md)
In generate_ui_component section (line ~330):
- Add new parameter documentation after
data_type(around line ~341):data_type_metadata(str, optional): Arguments of tool call used for 'data' argument
In generate_ui_multiple_components section (line ~231):
- Update
structured_datadescription (line ~243) to mention: "Each object has to haveid,data,type, and optionallytype_metadatafield."
MCP Tests
7. Update [libs/next_gen_ui_mcp/agent_test.py](libs/next_gen_ui_mcp/agent_test.py)
Add test in TestGenerateUIComponent class:
- Test name:
test_data_type_metadata_passed_through - Call
generate_ui_componentwithdata_type_metadata='{"tool": "search", "query": "test"}' - Assert
output.blocks[0].configuration.data_type_metadata == '{"tool": "search", "query": "test"}'
Update existing test (around line ~273):
test_data_configuration: Adddata_type_metadatato tool call and verify in assertion
Add test in TestGenerateUIMultipleComponents class:
- Test name:
test_structured_data_with_type_metadata - Create
input_datawithtype_metadatafield - Call tool and verify it's preserved in output configuration
A2A Protocol Integration
8. Update [libs/next_gen_ui_a2a/agent_executor.py](libs/next_gen_ui_a2a/agent_executor.py)
In _data_selection method (line ~18):
- Extract
type_metadatafrom metadata the same waytypeis extracted - Around line ~40-42: Add check for
metadata.get("type_metadata")and store intype_metadatavariable - Pass
type_metadata=type_metadatawhen creatingInputData(line ~44-49) - For DataPart metadata (line ~54-55): Extract
type_metadatasimilarly - Pass to
InputDatacreation at line ~57-59
9. Update [libs/next_gen_ui_a2a/README.md](libs/next_gen_ui_a2a/README.md)
In "Input" section (line ~176):
- Update description (around line ~180) to mention
type_metadatametadata item can be provided alongsidedataandtype
A2A Tests
10. Update [libs/next_gen_ui_a2a/agent_executor_test.py](libs/next_gen_ui_a2a/agent_executor_test.py)
Add new test:
- Test name:
test_agent_executor_with_type_metadata - Create message with TextPart containing metadata with
data,type, andtype_metadata - Execute and verify
ui_block.configuration.data_type_metadatamatches input
Update existing test (line ~55):
test_agent_executor_one_part_input_with_metadata: Addtype_metadatato metadata and assert it appears in output
Implementation Notes
- The field is optional everywhere, so backward compatibility is maintained
- No database migrations needed (all in-memory data structures)
- The value is passed through unchanged - no transformation or validation
- Example usage:
{"tool": "search_movies", "args": {"title": "Toy Story"}} - Frontend can deserialize this JSON to make refresh calls with same parameters