Skip to content

fix(agent): preserve multiple-select plugin parameter arrays - #46841

Merged
BeautyyuYanli merged 1 commit into
langgenius:mainfrom
Wang-Zephyr:fix/agent-multiple-select-arrays
Nov 26, 2026
Merged

BeautyyuYanli merged 1 commit into
langgenius:mainfrom
Wang-Zephyr:fix/agent-multiple-select-arrays

Conversation

@Wang-Zephyr

Copy link
Copy Markdown
Contributor

Fixes #46840

Summary

Preserve multiple-select plugin values as JSON arrays when Agent V2 invokes a tool. The API already supplies an array schema, but the Agent DTO drops multiple and the scalar select conversion turns valid lists into strings such as "['apac,east', 'emea']".

Retain that existing declaration field, then route select/dynamic-select parameters marked multiple through the existing array conversion. This covers model arguments, hidden runtime parameters, and defaults. Single selects retain scalar conversion; no frontend, API builder, plugin protocol, dependency, or shared array conversion changes are needed.

This covers Agent V2 dispatch, separate from the Tool-node constant parsing in #45676.

Verification

  • The same six native tool-dispatch scenarios fail on base ff7ee47f9dcdf9020f3a8151eae0aac24ac63a5c's Agent sources and pass with the fix. The actual daemon-facing request carries a list after the fix; the single-select control remains a string.
  • uv run --no-sync python -m pytest -q tests/local/dify_agent/layers/dify_plugin: 56 passed (1.03s pytest time).
  • The issue includes an independent collector using the native Pydantic AI Agent/Toolset with a local FunctionModel and HTTPX MockTransport. No live model-provider or plugin-daemon validation is claimed.
  • Package-wide Ruff lint, changed-file format check, package Pyrefly (0 errors), staged diff check, and the current baseline-aware test-doubles guard pass.
  • Windows / Python 3.13.18. The API builder was traced through its existing DTO conversion and array-schema construction; full API/backend suites and hosted CI were not run locally.

Checklist

  • Associated issue with reproduction and expected behavior.
  • Verified the change and added one parametrized regression group at the native dispatch boundary.
  • Documented the retained metadata field in its DTO docstring.
  • Ran the standalone package's lint and type-check commands described above.

From Codex

@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 20, 2026

@BeautyyuYanli BeautyyuYanli 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.

(This message is automated while I'm responsible for it.)

LGTM. Retaining multiple: bool = False on DifyPluginToolParameter and routing multiple select / dynamic-select parameters through the existing ARRAY coercion branch in _prepare_tool_arguments cleanly preserves JSON arrays across model arguments, hidden runtime_parameters, and defaults without affecting single-select scalar coercion or requiring API-side changes.

Verified locally (dify-agent plugin-layer tests 56 passed, ruff check / ruff format --check, pyrefly check 0 errors) and confirmed all hosted CI checks are green on d03da758906d.

@BeautyyuYanli
BeautyyuYanli added this pull request to the merge queue Nov 26, 2026
Merged via the queue into langgenius:main with commit a5d5e94 Nov 26, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Agent V2 converts multiple-select tool arrays into Python repr strings

2 participants