mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
Missing stream_options parameter causes self-calculated usage instead of using model's native usage data in streaming mode #819
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 @LycheeTown on GitHub (Nov 20, 2025).
Self Checks
Dify version
1.9.2
Plugin version
0.0.25
Cloud or Self Hosted
Self Hosted (Docker), Self Hosted (Source)
Steps to reproduce
Steps to reproduce
openai_api_compatible 0.0.25ordeepseek 0.0.7pluginExpected behavior
Plugins should include the
stream_options={"include_usage": True}parameter when making streaming calls to leverage the model's native usage reporting, rather than self-calculating these metrics.Additional context
This affects both
openai_api_compatibleanddeepseekplugins when operating in streaming mode. Adding this parameter would improve accuracy and consistency with how OpenAI and other compatible APIs report usage data during streaming responses.✔️ Error log
No specific error logs, but the behavior leads to potentially inaccurate usage calculation as the plugins aren't leveraging the model's built-in usage reporting capabilities when in streaming mode.
@dosubot[bot] commented on GitHub (Nov 20, 2025):
You're correct—both the
openai_api_compatibleanddeepseekplugins currently do not setstream_options={"include_usage": True}in their streaming calls, which causes them to self-calculate usage metrics instead of using the model's native usage data. The base OpenAI-compatible plugin does set this parameter in streaming mode, but the specific plugins do not pass it along in their_invokemethods, leading to the issue you described (source, source).To resolve this, you can modify the
_invokemethod in both plugins to add:before calling the superclass. This will ensure accurate usage reporting during streaming responses, matching the behavior of the base plugin.
No recent pull requests address this for these plugins, so a direct code change is currently the best workaround.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
