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

Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 29, 2026

This PR attempts to address Issue #11071 where GLM4.5 models via LM Studio or OpenAI-compatible endpoints get stuck repeating file reads.

Problem

The user reported that model names like:

  • mlx-community/GLM-4.5-4bit
  • GLM-4.5-UD-Q8_K_XL-00001-of-00008.gguf
  • glm-4.5

were not being detected as GLM models, causing the optimizations for GLM models to not be applied.

Solution

Created a flexible isGlmModel() utility function that uses a simple regex pattern (/glm/i) to detect GLM anywhere in the model ID, case-insensitively. This handles:

  • Standard Z.ai format: glm-4.5, glm-4.6, glm-4.7
  • MLX format: mlx-community/GLM-4.5-4bit
  • GGUF format: GLM-4.5-UD-Q8_K_XL-00001-of-00008.gguf
  • HuggingFace format: THUDM/glm-4-9b-chat
  • ChatGLM variants: chatglm-6b, chatglm2-6b

Changes

  1. New utility (src/api/providers/utils/glm-model-detection.ts):

    • isGlmModel(modelId) - Detects if a model ID represents a GLM model
    • getGlmModelOptions(modelId) - Returns recommended options for GLM models
  2. LmStudioHandler - Now detects GLM models and applies:

    • mergeToolResultText: true - Prevents conversation flow disruption
    • parallel_tool_calls: false - Disabled as GLM may not support it
  3. BaseOpenAiCompatibleProvider - Same GLM detection and optimizations

  4. Tests - 41 tests covering various GLM model name formats

Feedback and guidance are welcome!


Important

Introduces GLM model detection utility and updates handlers to apply GLM-specific options, with tests for various model formats.

  • Utility Function (glm-model-detection.ts):
    • isGlmModel(modelId): Detects GLM models using regex /glm/i.
    • getGlmModelOptions(modelId): Returns options for GLM models, disabling parallel_tool_calls and enabling mergeToolResultText.
  • Handlers:
    • LmStudioHandler and BaseOpenAiCompatibleProvider now use getGlmModelOptions() to apply GLM-specific options.
  • Tests (glm-model-detection.spec.ts):
    • 41 tests added for various GLM model name formats to ensure correct detection and option application.

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

…mpatible endpoints

Addresses Issue #11071 where GLM4.5 models via LM Studio get stuck
repeating file reads due to undetected model names.

Changes:
- Add isGlmModel() utility that uses a flexible regex pattern to detect
  GLM models anywhere in the model ID (case-insensitive)
- Handle model name formats like:
  - mlx-community/GLM-4.5-4bit
  - GLM-4.5-UD-Q8_K_XL-00001-of-00008.gguf
  - glm-4.5 (standard format)
  - chatglm variants
- Update LmStudioHandler to apply GLM-specific optimizations when detected
- Update BaseOpenAiCompatibleProvider similarly
- Add comprehensive tests for GLM model detection

When GLM model is detected:
- mergeToolResultText: true (prevents conversation flow disruption)
- parallel_tool_calls: false (GLM may not support this parameter)
@roomote
Copy link
Contributor Author

roomote bot commented Jan 29, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation is clean and follows established patterns in the codebase. The GLM detection uses the existing mergeToolResultText option (already used by DeepSeek and Z.ai) and all 41 tests pass.

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

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.

1 participant