fix: combine tool call sync fix with GLM model detection for issue #11071 #11096
+748
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11071
Roo Code Task Context (Optional)
N/A
Description
This PR attempts to address Issue #11071 by combining the fix from PR #11093 with GLM-related improvements (points 1-5 from the discussion), excluding point 6 (path-based repetition detection).
Changes included:
PR fix: prevent tool_call_end events for unstarted tool calls #11093 Fix - Tool Call Sync: Fixed
NativeToolCallParser.processFinishReason()to only emittool_call_endevents for tool calls that have actually started (i.e., wheretool_call_startwas emitted). This preventsfinalizeStreamingToolCallfrom receiving IDs that were never registered, which was causing tool results to be silently dropped and triggering infinite retry loops.GLM Model Detection (
glm-model-detection.ts): New utility that detects GLM models (GLM-4.5, GLM-4.6, GLM-4.7 and their variants) from model IDs, supporting various formats from LM Studio and OpenAI-compatible endpoints.mergeToolResultText Optimization: For detected GLM models, the providers now use
convertToZAiFormatwithmergeToolResultText: trueto prevent conversation flow disruption and reasoning_content loss.Disable parallel_tool_calls: GLM models have
parallel_tool_callsdisabled as they may not support it properly.GLM-4.7 Thinking Parameters: For GLM-4.7+ models, the providers send the
thinking: { type: "enabled" | "disabled" }parameter based on user settings.Diagnostic Logging: Console logging shows GLM detection results including version, variant, and applied optimizations.
Test Procedure
NativeToolCallParser.spec.tscovering the processFinishReason fixglm-model-detection.spec.tscovering GLM detectionRun tests:
All 51 tests pass.
Pre-Submission Checklist
Screenshots / Videos
N/A - Backend fix, no UI changes.
Documentation Updates
Additional Notes
This PR combines solutions from prior PRs (#11093, #11092) as requested by @mark-ucalgary in the issue discussion. Feedback and guidance are welcome!
Important
Fix tool call sync issue and enhance GLM model detection, adding support for GLM-4.5, 4.6, 4.7 models and optimizing message handling.
processFinishReason()inNativeToolCallParserto emittool_call_endonly for started tool calls, preventing unregistered IDs from causing issues.glm-model-detection.tsto detect GLM models (GLM-4.5, GLM-4.6, GLM-4.7) and handle various ID formats.mergeToolResultTextfor GLM models to prevent conversation flow disruption.parallel_tool_callsfor GLM models.thinkingparameter for GLM-4.7 models based on user settings.NativeToolCallParser.spec.tsforprocessFinishReasonfix.glm-model-detection.spec.tsfor GLM detection.This description was created by
for 9e96578. You can customize this summary. It will automatically update as commits are pushed.