Bug: Agent node tool call fails with 'str' object has no attribute 'get' when the referenced string variable contains ". #16179

Closed
opened 2026-02-21 19:24:57 -05:00 by yindo · 1 comment
Owner

Originally created by @zhixing-2024 on GitHub (Aug 15, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

Version 1.7.2

Cloud or Self Hosted

Cloud

Steps to reproduce

While using the Agent node in a Dify workflow, I've encountered an issue. When I call a tool whose string-type input parameter is assigned by referencing a variable from an upstream node, the Agent node fails immediately if the variable's value contains a double quote (").
The error message is: Run failed: 'str' object has no attribute 'get'.
However, a key point of comparison is that if I do not use a variable and instead directly enter the same string (containing double quotes) into the tool's input field, the tool is called successfully, and the Agent node runs without error.
This indicates that the problem lies within the Agent node's handling and parsing of variables containing special characters, rather than an issue with the tool itself ( I've tested several tools, and they are all like this. )

  1. Select a Tool:

    • Create a simple custom tool that accepts a single string input, for example, input_text.
    • Alternatively, use any existing tool that accepts a string input.
  2. Create a Workflow:

    • Create a new workflow.
    • Add a "Start" node and define a string-type input variable in it, e.g., query.
  3. Configure the Agent Node:

    • Add an "Agent" node after the "Start" node.
    • In the "Tools" section of the Agent node, add the tool prepared in step 1.
    • For the tool's input_text parameter, reference the variable by entering {{#start.query}}.

✔️ Expected Behavior

When the query variable contains double quotes, the Agent node should correctly pass the string Please summarize the "dify" project to the tool's input_text parameter, execute the tool successfully, and the workflow should complete without any errors.

Actual Behavior

the Agent node fails and throws the following error: Run failed: 'str' object has no attribute 'get'.
I suspect that when the Agent node retrieves the value of {{#start.query}} from the upstream node, the presence of double quotes causes an error during internal JSON parsing or parameter construction. This likely results in the string not being properly escaped or wrapped, causing downstream logic to misinterpret it as a malformed dictionary or a raw string, ultimately leading to a type error.

Originally created by @zhixing-2024 on GitHub (Aug 15, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version Version 1.7.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce While using the Agent node in a Dify workflow, I've encountered an issue. When I call a tool whose string-type input parameter is assigned by referencing a variable from an upstream node, the Agent node fails immediately if the variable's value contains a double quote (`"`). The error message is: `Run failed: 'str' object has no attribute 'get'`. However, a key point of comparison is that if I **do not use a variable** and instead **directly** enter the same string (containing double quotes) into the tool's input field, the tool is called successfully, and the Agent node runs without error. This indicates that the problem lies within the Agent node's handling and parsing of variables containing special characters, rather than an issue with the tool itself ( I've tested several tools, and they are all like this. ) 1. **Select a Tool**: * Create a simple custom tool that accepts a single string input, for example, `input_text`. * Alternatively, use any existing tool that accepts a string input. 2. **Create a Workflow**: * Create a new workflow. * Add a "Start" node and define a string-type input variable in it, e.g., `query`. 3. **Configure the Agent Node**: * Add an "Agent" node after the "Start" node. * In the "Tools" section of the Agent node, add the tool prepared in step 1. * For the tool's `input_text` parameter, reference the variable by entering `{{#start.query}}`. ### ✔️ Expected Behavior When the `query` variable contains double quotes, the Agent node should correctly pass the string `Please summarize the "dify" project` to the tool's `input_text` parameter, execute the tool successfully, and the workflow should complete without any errors. ### ❌ Actual Behavior the Agent node fails and throws the following error: Run failed: `'str' object has no attribute 'get'`. I suspect that when the Agent node retrieves the value of `{{#start.query}}` from the upstream node, the presence of double quotes causes an error during internal JSON parsing or parameter construction. This likely results in the string not being properly escaped or wrapped, causing downstream logic to misinterpret it as a malformed dictionary or a raw string, ultimately leading to a type error.
yindo added the 🐞 bug label 2026-02-21 19:24:57 -05:00
yindo closed this issue 2026-02-21 19:24:57 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 15, 2025):

Hi @zhixing-2024! I'm Dosu and I’m helping the dify team.

This error is caused by how the Agent node handles variable substitution and JSON serialization. When you reference a variable containing special characters (like double quotes), the Agent node serializes parameters as JSON, then performs template substitution, and finally tries to parse them back. If the value is a string but the code expects a dictionary (e.g., using .get()), you get the 'str' object has no attribute 'get' error. This is a known issue and has been discussed in previous threads and issues (example, example).

Workarounds include:

  • Enabling LLM auto-fill for the parameter, which ensures the correct type is passed and can avoid the error in some cases (details).
  • Double-checking that your Agent node input is set to "variable" and not "constant" or "mixed" (details).
  • If you must pass JSON strings, use double-serialization (json.dumps(json.dumps(obj))) and decode twice at the receiving end (details).

The root cause is in the _generate_agent_parameters method of the AgentNode class, where parameter handling can introduce double-escaping or type mismatches (details). There is no config flag to fix this; a code-level adjustment is needed. If you want to track progress or contribute, keep an eye on related issues and PRs for updates.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Aug 15, 2025): <!-- Greeting --> Hi @zhixing-2024! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> This error is caused by how the Agent node handles variable substitution and JSON serialization. When you reference a variable containing special characters (like double quotes), the Agent node serializes parameters as JSON, then performs template substitution, and finally tries to parse them back. If the value is a string but the code expects a dictionary (e.g., using `.get()`), you get the `'str' object has no attribute 'get'` error. This is a known issue and has been discussed in previous threads and issues ([example](https://github.com/langgenius/dify/issues/21958), [example](https://github.com/langgenius/dify/issues/20661)). Workarounds include: - Enabling LLM auto-fill for the parameter, which ensures the correct type is passed and can avoid the error in some cases ([details](https://github.com/langgenius/dify/issues/21958)). - Double-checking that your Agent node input is set to "variable" and not "constant" or "mixed" ([details](https://github.com/langgenius/dify/issues/21157#issuecomment-2982918889)). - If you must pass JSON strings, use double-serialization (`json.dumps(json.dumps(obj))`) and decode twice at the receiving end ([details](https://github.com/langgenius/dify/issues/22478)). The root cause is in the `_generate_agent_parameters` method of the AgentNode class, where parameter handling can introduce double-escaping or type mismatches ([details](https://github.com/langgenius/dify/issues/20661)). There is no config flag to fix this; a code-level adjustment is needed. If you want to track progress or contribute, keep an eye on related issues and PRs for updates. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/076a2854-e7ae-4bdf-9701-f8c2e709ae6c?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/23973)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#16179