mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
PluginInvokeError while using Gemini and search tool in Agent node. #640
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Egoistsoul on GitHub (Sep 12, 2025).
Self Checks
Dify version
1.8.1
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
I use Gemini 2.5 Pro along with search tools like Tavily and Jina within the Agent node in a loop, but it occasionally triggers the error below and halts execution. Sometimes it works fine but sometimes not, and all variables and settings are not changed.
Run failed: Failed to transform agent message: req_id: 66d87d9167 PluginInvokeError: {"args":{},"error_type":"KeyError","message":"'search'"}You can check this yml for details build:
B-学习内容生成-test.yml
✔️ Expected Behavior
Gemini can run properly in the loop.
❌ Actual Behavior
@dosubot[bot] commented on GitHub (Sep 12, 2025):
The intermittent
PluginInvokeError: KeyError 'search'happens because the agent workflow expects the tool/plugin output to always include a'search'key, but sometimes the response from Gemini or the search tools (like Tavily/Jina) doesn't contain it. This is a known issue in the agent node's tool invocation logic—there isn't a robust check for the key before accessing it, so if the tool result is missing or malformed, the error bubbles up and halts execution. Defensive coding (using.get('search')or explicit checks) would prevent this, but it's not currently implemented in the relevant code paths source.Immediate workarounds: try adding retry logic for Gemini nodes, ensure your tool/plugin configuration (especially
toolConfig) is correct, and consider testing with a model like GPT-4 that has more stable tool-calling support. If you need reliable execution in loops, you may want to add a fallback or default value for the'search'key in your workflow logic, or update your agent/plugin code to check for key existence before access source.If you want to avoid this error entirely, suggest maintainers add defensive checks for missing keys in agent node code, especially for multi-tool workflows. For more context and troubleshooting, see similar issues with Gemini and agent nodes here and here.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@Egoistsoul commented on GitHub (Sep 12, 2025):
The agent node currently lacks a retry function; I request its inclusion in the next version. Additionally, is there any update on implementing defensive checks?
@Egoistsoul commented on GitHub (Sep 12, 2025):
Update, I changed the tool from Tavily to Exa search, and got this error:
Run failed: Failed to transform agent message: req_id: 8218d7a549 PluginInvokeError: {"args":{},"error_type":"KeyError","message":"'exa_synthesis'"}@dosubot[bot] commented on GitHub (Sep 12, 2025):
The error with
'exa_synthesis'is caused by the agent node expecting a key in the plugin/tool output that isn't present—just like the previous'search'KeyError. This happens because the agent workflow directly accesses keys matching the tool name without checking if they exist, and there are no defensive checks in place to handle missing keys in plugin outputs. This is a known systemic issue in Dify's agent node logic for all plugins, especially custom or non-standard ones, and not specific to Exa search or any official plugin design reference.Immediate workarounds: update your workflow or plugin code to check for key existence before access (e.g., use
.get('exa_synthesis')or provide a fallback/default value), verify your plugin/tool configuration, and consider adding retry logic if the error is intermittent. If you control the plugin output, ensure it always returns the expected key, even if the value is empty. There are ongoing requests for maintainers to add defensive key checks and retry mechanisms in future versions, but no recent updates or merged fixes address this yet reference.If you need more robust handling, you may want to preprocess plugin outputs to match the expected schema before passing them to the agent node. This will prevent execution from halting due to missing keys.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

@Egoistsoul commented on GitHub (Sep 12, 2025):
What is the earliest date this systemic issue was identified?
@dosubot[bot] commented on GitHub (Sep 28, 2025):
Hi, @Egoistsoul. I'm Dosu, and I'm helping the dify-official-plugins team manage their backlog and am marking this issue as stale.
Issue Summary
Next Steps
Thank you for your understanding and contribution!
@Egoistsoul commented on GitHub (Nov 3, 2025):
This issue still exist in Dify 1.9.2 and Gemini Plugin 0.5.6
@dosubot[bot] commented on GitHub (Nov 3, 2025):
@crazywoola The user reports that the intermittent KeyError issues with Dify 1.9.2 and Gemini Plugin 0.5.6 still persist and requests assistance with retry functionality and defensive checks in the plugins. Could you please help address this ongoing problem?