Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 30, 2026

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:

  1. PR fix: prevent tool_call_end events for unstarted tool calls #11093 Fix - Tool Call Sync: Fixed NativeToolCallParser.processFinishReason() to only emit tool_call_end events for tool calls that have actually started (i.e., where tool_call_start was emitted). This prevents finalizeStreamingToolCall from receiving IDs that were never registered, which was causing tool results to be silently dropped and triggering infinite retry loops.

  2. 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.

  3. mergeToolResultText Optimization: For detected GLM models, the providers now use convertToZAiFormat with mergeToolResultText: true to prevent conversation flow disruption and reasoning_content loss.

  4. Disable parallel_tool_calls: GLM models have parallel_tool_calls disabled as they may not support it properly.

  5. GLM-4.7 Thinking Parameters: For GLM-4.7+ models, the providers send the thinking: { type: "enabled" | "disabled" } parameter based on user settings.

  6. Diagnostic Logging: Console logging shows GLM detection results including version, variant, and applied optimizations.

Test Procedure

  • Added 5 new test cases in NativeToolCallParser.spec.ts covering the processFinishReason fix
  • Added 34 test cases in glm-model-detection.spec.ts covering GLM detection

Run tests:

cd src && npx vitest run core/assistant-message/__tests__/NativeToolCallParser.spec.ts
cd src && npx vitest run api/providers/utils/__tests__/glm-model-detection.spec.ts

All 51 tests pass.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

N/A - Backend fix, no UI changes.

Documentation Updates

  • No documentation updates are required.

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.

  • Behavior:
    • Fix processFinishReason() in NativeToolCallParser to emit tool_call_end only for started tool calls, preventing unregistered IDs from causing issues.
    • Add glm-model-detection.ts to detect GLM models (GLM-4.5, GLM-4.6, GLM-4.7) and handle various ID formats.
    • Optimize mergeToolResultText for GLM models to prevent conversation flow disruption.
    • Disable parallel_tool_calls for GLM models.
    • Add thinking parameter for GLM-4.7 models based on user settings.
  • Tests:
    • Add 5 test cases in NativeToolCallParser.spec.ts for processFinishReason fix.
    • Add 34 test cases in glm-model-detection.spec.ts for GLM detection.
  • Misc:
    • Log GLM detection results including version and variant.

This description was created by Ellipsis for 9e96578. You can customize this summary. It will automatically update as commits are pushed.

…1071

This PR combines:
1. PR #11093 fix: NativeToolCallParser processFinishReason hasStarted check
2. GLM model detection utility for LM Studio and OpenAI-compatible providers
3. mergeToolResultText optimization for GLM models
4. Disable parallel_tool_calls for GLM models
5. GLM-4.7 thinking parameter support
6. Diagnostic logging for GLM detection

Closes #11071
@roomote
Copy link
Contributor Author

roomote bot commented Jan 30, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The PR correctly addresses the reported issue by:

  1. Fixing NativeToolCallParser.processFinishReason() to only emit tool_call_end events for tool calls that have started (preventing infinite retry loops)
  2. Adding comprehensive GLM model detection for LM Studio and OpenAI-compatible endpoints
  3. Applying GLM-specific optimizations (mergeToolResultText, disabled parallel_tool_calls, thinking parameters for GLM-4.7)

The latest commit (9e96578) adds GLM detection to OpenAiHandler (the "OpenAI Compatible" provider), following the same patterns already established in BaseOpenAiCompatibleProvider. The implementation is consistent between streaming and non-streaming paths.

The changes are well-tested with 39 new test cases.

Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@mark-ucalgary
Copy link

@roomote tested with OpenAI-compatible endpoint and GLM-4.5-UD-Q8_K_XL-00001-of-00008.gguf as the model. I didnt see any logging about model detection in the console.

This commit adds GLM model detection and related optimizations to the
OpenAI Compatible provider (OpenAiHandler), which handles the "OpenAI
Compatible" option in the UI when users set a custom base URL.

Changes:
- Import GLM detection utilities and Z.ai format converter
- Add glmConfig property to track GLM model configuration
- Detect GLM model on construction when model ID is available
- Re-detect GLM model in createMessage if model ID changes
- For GLM models:
  - Use convertToZAiFormat with mergeToolResultText to prevent
    conversation flow disruption
  - Disable parallel_tool_calls as GLM models may not support it
  - Add thinking parameter for GLM-4.7 models
- Add console logging for detection results and applied optimizations

This addresses the feedback in issue #11071 where the user clarified
they are using the "OpenAI Compatible" provider, not the "OpenAI"
provider. The previous changes in this PR only affected the
base-openai-compatible-provider.ts (used by Z.ai, Groq, etc.) and
lm-studio.ts, but not openai.ts which handles OpenAI Compatible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] GLM4.5 via LMStudio as well as via an OpenAI-compatible endpoint stuck repeating file reads

2 participants