Repository navigation
Description
Self Checks
- I have read the Contributing Guide and Language Policy.
- This is only a bug report, not a question or feature request.
- I have searched existing open and closed issues.
- I am submitting this report in English.
- All required bug-report fields are filled in below.
Dify version
1.17.1, self-hosted downstream build. The affected Agent serialization and runtime paths are also present in upstream main at 8c41d45dd895e819ede54c034a1ccaaa9a443aaf (2026-10-23).
The failure was observed on the downstream deployment; the upstream comparison is source inspection, not a claim that we executed an unmodified upstream checkout.
Cloud or Self Hosted
Self Hosted (Docker images deployed through Kubernetes/Helm).
Steps to reproduce
This concerns the legacy Agent node in Workflow/Chatflow, not Agent V2 or a standalone Tool node.
Use an Agent strategy exposing an optional variable-selector parameter, for example:
parameters:
- name: context
type: any
required: false
label:
en_US: Context- Create a Workflow with
Start -> Agent -> End. Add a text input to Start and select the strategy above in Agent. - Leave
contextuntouched. It is absent fromagent_parameters, and the node runs normally. - Select the Start text input for
context. The saved graph contains:{"context":{"type":"variable","value":["start","text"]}} - Hover over the selected variable and click Clear.
- Save/run the draft, or publish and invoke the workflow again.
The cleared field looks unset, but the parameter remains in the graph:
{"context":{"type":"variable","value":""}}An empty selector list ([]) produces the same Agent runtime failure. This also applies to optional files parameters declared as any.
Expected Behavior
- Clearing an optional Agent variable parameter restores its unset state, rather than persisting an invalid variable reference. For these strategy parameters, removing the corresponding
agent_parametersentry matches the untouched state. - Existing drafts and published versions containing an empty optional selector (
"",[], ornull) run as if that parameter were unset. - Required parameters still fail clearly when no variable is selected.
- Non-empty invalid/missing references remain errors. A valid reference resolving to an empty value or numeric
0must not be mistaken for an empty selector.
Actual Behavior
The Agent fails before strategy invocation, even though the parameter is optional:
File "/app/api/core/workflow/nodes/agent/agent_node.py", line 124, in _run
parameters = self._runtime_support.build_parameters(...)
File "/app/api/core/workflow/nodes/agent/runtime_support.py", line 60, in build_parameters
raise AgentVariableNotFoundError(str(agent_input.value))
core.workflow.nodes.agent.exceptions.AgentVariableNotFoundError: Variable '' does not exist
Every execution reaching this node fails until the parameter is actually removed or a valid reference is selected. Clearing it in the editor again does not remove the configuration entry.
Affected source paths
At the upstream commit noted above:
Form.tsx:579-606:anyparameters useVarReferencePickerwithout overriding its default variable-kind state.var-reference-picker.tsx:251-254: clearing emits''or[].use-config.ts:onFormChangeretains the cleared entry and marksanyinputs astype: variable.runtime_support.py:55-61: every variable input is resolved; the missing-variable exception does not distinguish optional parameters.agent_node.py: selector extraction also includes cleared references, affecting single-node draft execution before parameter building.
Related Agent tool-parameter path
An Agent's selected tools have a separate manual-parameter path. If a numeric/object/array/date parameter is switched to variable mode, or a file parameter is selected, clearing it can likewise retain an empty reference with auto: 0. For example:
{"count":{"auto":0,"value":{"type":"variable","value":""}}}runtime_support.py:98-105 raises ValueError: Variable selector is missing for a variable-type parameter. without distinguishing whether that tool parameter is optional. Thus the broader Agent issue is not limited to a strategy's any fields.
Local fix verification
We verified a local fix in a disposable Kubernetes instance with independent PostgreSQL/Redis and real installed deterministic Python strategy/tool plugins. No LLM credentials or production workflow data were used.
- Browser actions: select, clear, autosave, refresh, and reopen
contextandfiles; persisted strategy entries were removed. - Browser actions: clear and reselect/clear an optional manual numeric tool parameter; its value became
nullwhileautoremained0. - 16 real Console API cases covered legacy empty forms, required strategy/tool parameters, missing non-empty references, valid references, and numeric
0; outcomes matched the expectations above. - The complete
Start -> Agent -> Endworkflow was launched through the editor twice and returnedworkflow_finishedwithstatus: succeededand visible output.
These observations validate the local fix only; it has not been submitted or merged upstream. The fix normalizes clearing in the Agent-specific frontend owners and handles existing empty optional references in the backend, including single-node selector extraction. Changing the shared picker alone would not repair existing saved workflows, and replacing '' with [] alone would still fail in Agent.
Related reports
- Run failed: Variable '' does not exist #24462 reports the same Agent error after adding and removing
context, but is closed and originally targeted 1.7.2. This report supplies a newer affected version and concrete serialization/runtime paths. - Bug: Dify 1.17.0 stores an invalid selector when an optional tool file input is cleared #41809 and open PR fix: reset cleared optional file tool inputs #41810 address cleared optional file inputs in ordinary Tool nodes. The PR does not modify the Agent strategy form, Agent parameter builder, or Agent manual-tool parameter path described here.
Activity
rome-xi commentedon Oct 23, 2026
I can confirm this on
530d8300c:AgentRuntimeSupport.build_parametersraisesAgentVariableNotFoundErrorfor an empty selector ('',[],None) even when the strategy parameter is optional. Working on a small backend fix with tests, so existing drafts and published versions run as if the parameter were unset.fix(agent): treat cleared optional variable parameters as unset (lang…
fix(agent): treat cleared optional variable parameters as unset (lang…
fix(agent): treat cleared optional variable parameters as unset (lang…
fix(agent): treat cleared optional variable parameters as unset (lang…
fix(agent): treat cleared optional variable parameters as unset (lang…