mirror of
https://github.com/langgenius/dify-official-plugins.git
synced 2026-07-21 17:45:23 -04:00
Gemini Model Implementation Regression from v0.3.0 -> v0.5.4 #647
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 @tushverma on GitHub (Sep 14, 2025).
Self Checks
Dify version
1.8.1
Plugin version
0.5.4
Cloud or Self Hosted
Self Hosted (Docker)
Steps to reproduce
REGRESSION #1: v0.3.0 → v0.4.0
ToolPromptMessage Role Change
File: llm-v0.4.0.pyLines: 468-477Impact: CRITICAL
Change:
v0.3.0 (WORKING) - line 382
elif isinstance(message, ToolPromptMessage):
return types.Content(
role="function",
parts=[types.Part.from_function_response(...)]
)
v0.4.0 (BROKEN) - line 472
elif isinstance(message, ToolPromptMessage):
return types.Content(
role="user", #
parts=[types.Part.from_function_response(...)]
)
Root Cause: Tool response messages are now sent as "user" messages instead of "function" messages.
Impact on Agents:
REGRESSION #2: v0.5.1 → v0.5.2
Thinking Tag Removal
File: llm-v0.5.2.pyLines: 463-464Impact: CRITICAL
Change: Centralized thinking tag removal
NEW in v0.5.2 - _build_text_parts function
def _build_text_parts(_content: str | TextPromptMessageContent) -> List[types.Part]:
text_parts = []
if isinstance(_content, TextPromptMessageContent):
_content = _content.data
if message.role == PromptMessageRole.ASSISTANT:
_content = re.sub(r"^.?\s", "", _content, count=1, flags=re.DOTALL)
# ❌ STRIPS ALL THINKING CONTENT FROM ASSISTANT MESSAGES
if _content:
text_parts.append(types.Part.from_text(text=_content))
return text_parts
Root Cause: All tags are now stripped from assistant messages during processing, removing crucial reasoning context.
Impact on Agents:
✔️ Error log
No response
@dosubot[bot] commented on GitHub (Sep 14, 2025):
You've correctly identified two critical regressions in the Gemini plugin:
The ToolPromptMessage role was changed from
"function"to"user"in v0.4.0 to comply with Gemini API requirements, but this broke agent tool response handling—tool outputs were misinterpreted as user questions, disrupting the tool call/response cycle and instruction following. This change is documented in PR #1488. A later fix restored the correct"function"role assignment in PR #991.The centralized removal of
<think>tags from assistant messages was introduced in v0.5.2 via the_build_text_partsfunction, which strips reasoning content using a regex before converting to model input. This impacts agent reasoning and chain-of-thought context. The implementation and refactoring are shown in PR #1600.Workarounds:
ToolPromptMessageto"function"in your plugin code if you need the previous agent loop behavior, or update to a version after PR #991 where this is fixed._build_text_partsto preserve<think>tags and reasoning context for assistant messages.These changes were made for API compliance and code maintainability, but they introduced the issues you've described. If you need more granular control, patching these specific areas in your deployment should restore expected behavior.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
