Skip to content

Python: fix: DevUI list[Message] input for declarative ToolAgent entry (#6533) - #6534

Merged
Evan Mattson (moonbox3) merged 3 commits into
microsoft:mainfrom
anneheartrecord:fix/6533-devui-list-message-entry
Jul 8, 2026
Merged

Python: fix: DevUI list[Message] input for declarative ToolAgent entry (#6533)#6534
Evan Mattson (moonbox3) merged 3 commits into
microsoft:mainfrom
anneheartrecord:fix/6533-devui-list-message-entry

Conversation

@anneheartrecord

Copy link
Copy Markdown
Contributor

When a declarative ToolAgent is created, its entry JoinExecutor declares input_types = [dict | str | list[Message] | ...]. DevUI called select_primary_input_type which returned bare Message instead of list[Message], passing a single Message to an executor that expects a list -- causing 'cannot handle message of type Message'.

Root cause: select_primary_input_type iterated over message_types without searching inside the union for list[Message].

Changes:

  • _is_list_message_type: detect list[Message] via get_origin/get_args
  • _find_chat_message_type: recursively searches union members, prefers list[Message] over bare Message
  • select_primary_input_type: use _find_chat_message_type so list[Message] is returned correctly
  • generate_input_schema: return {type: string} for list[Message] so DevUI shows a text box
  • _looks_like_message_dict: distinguish serialised Message payloads from structured workflow inputs
  • parse_input_for_type: handle list[Message] target -- wrap strings/Messages, convert lists of dicts item-by-item, pass structured workflow inputs through unchanged

12 regression tests added; 57 total pass.

Closes #6533

)

When a declarative ToolAgent is created with default settings the
entry JoinExecutor declares `input_types = [dict | str | list[Message]
| ActionTrigger | ...]`.  DevUI called `select_primary_input_type`
which returned bare `Message` instead of `list[Message]`, then passed
a single Message to the executor that expects a list — causing a
"cannot handle message of type Message" runtime error.

Changes:
- Add `_is_list_message_type` helper (GenericAlias cannot be used with
  isinstance; get_origin/get_args required).
- Add `_find_chat_message_type` that recursively searches union members
  and returns `list[Message]` in preference to bare `Message`.
- `select_primary_input_type`: first-pass uses `_find_chat_message_type`
  so the declarative entry type is correctly returned as `list[Message]`.
- `generate_input_schema`: returns `{"type":"string"}` for `list[Message]`
  so DevUI renders a plain text box.
- Add `_looks_like_message_dict` heuristic (role present, type=="message",
  or exactly {"input":...}) to distinguish serialised Message payloads
  from structured workflow inputs without false positives.
- `parse_input_for_type`: handle `list[Message]` target — wrap plain
  strings/Message objects, convert lists of dicts item-by-item, pass
  structured workflow inputs through unchanged.
- Add 12 regression tests (57 total pass).
Copilot AI review requested due to automatic review settings June 16, 2026 06:13
@moonbox3 Evan Mattson (moonbox3) added the python Usage: [Issues, PRs], Target: Python label Jun 16, 2026
@github-actions github-actions Bot changed the title fix: DevUI list[Message] input for declarative ToolAgent entry (#6533) Python: fix: DevUI list[Message] input for declarative ToolAgent entry (#6533) Jun 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR improves DevUI handling of declarative entry executors whose input union includes list[Message], ensuring the UI presents a simple text box while runtime input parsing wraps user text into the expected list[Message] shape.

Changes:

  • Add recursive detection of list[Message] vs Message in select_primary_input_type.
  • Render list[Message] input schemas as a plain JSON {"type":"string"} and parse raw inputs into list[Message].
  • Add regression tests covering schema generation and parse_input_for_type behavior for list[Message].

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
python/packages/devui/agent_framework_devui/_utils.py Adds list[Message] detection, schema rendering as string, and input parsing logic to wrap/convert into list[Message].
python/packages/devui/tests/devui/test_server.py Adds regression tests for select_primary_input_type and parse_input_for_type with list[Message].
python/packages/devui/tests/devui/test_schema_generation.py Adds regression test ensuring list[Message] generates a simple string schema.
Comments suppressed due to low confidence (2)

python/packages/devui/agent_framework_devui/_utils.py:476

  • generate_input_schema and parse_input_for_type accept and are now called with list[Message], which is a types.GenericAlias (not a type) in modern Python. Keeping the parameter annotations as type is misleading for callers and type checkers, and isinstance(input_data, target_type) will raise TypeError for other generic aliases (e.g., list[str]) if they ever get passed in. Updating these signatures to accept Any (or type[Any] | object) and guarding isinstance (only call it when target_type is a real type) would make this API safer and more accurate.
def generate_input_schema(input_type: type) -> dict[str, Any]:

python/packages/devui/agent_framework_devui/_utils.py:536

  • generate_input_schema and parse_input_for_type accept and are now called with list[Message], which is a types.GenericAlias (not a type) in modern Python. Keeping the parameter annotations as type is misleading for callers and type checkers, and isinstance(input_data, target_type) will raise TypeError for other generic aliases (e.g., list[str]) if they ever get passed in. Updating these signatures to accept Any (or type[Any] | object) and guarding isinstance (only call it when target_type is a real type) would make this API safer and more accurate.
def parse_input_for_type(input_data: Any, target_type: type) -> Any:

Comment thread python/packages/devui/agent_framework_devui/_utils.py
Comment thread python/packages/devui/agent_framework_devui/_utils.py Outdated
Comment thread python/packages/devui/agent_framework_devui/_utils.py
Comment thread python/packages/devui/agent_framework_devui/_utils.py
@anneheartrecord

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@anneheartrecord

Copy link
Copy Markdown
Contributor Author

Victor Dibia (@victordibia) This fixes DevUI for declarative ToolAgent entries whose input union includes list[Message] (#6533): it detects that case, renders a plain text input, and wraps the raw text back into list[Message] at runtime, with regression tests. Could you take a look when you have a moment?

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL44490534687% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
8815 33 💤 0 ❌ 0 🔥 1m 58s ⏱️

@eavanvalkenburg

Copy link
Copy Markdown
Member

Charles (@anneheartrecord) there are some checks failing, could you have a look?

@anneheartrecord

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) Fixed — the Package Checks failure was pyright flagging unknown types in the new list[Message] branch of parse_input_for_type (untyped list/dict narrowing). Pushed b211fd8 which adds explicit annotations/casts; uv run pyright on the package is clean locally and all 174 devui tests still pass.

@moonbox3
Evan Mattson (moonbox3) added this pull request to the merge queue Jul 8, 2026
Merged via the queue into microsoft:main with commit c47f20d Jul 8, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

4 participants