From 2c5d905aeba518c5b620f25d0457033db83ee713 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 29 Jan 2026 17:16:03 +0000 Subject: [PATCH] feat: add diagnostic logging for GLM model detection - Add console logging in getGlmModelOptions() to show when a GLM model is detected - Log model ID being used in LM Studio and OpenAI-compatible providers - Log parallel_tool_calls value being applied - Helps users verify GLM detection is working correctly Addresses issue #11071 where users cannot verify if GLM detection is functioning --- src/api/providers/base-openai-compatible-provider.ts | 3 +++ src/api/providers/lm-studio.ts | 3 +++ src/api/providers/utils/model-detection.ts | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/src/api/providers/base-openai-compatible-provider.ts b/src/api/providers/base-openai-compatible-provider.ts index 49f4e6c791..be98512895 100644 --- a/src/api/providers/base-openai-compatible-provider.ts +++ b/src/api/providers/base-openai-compatible-provider.ts @@ -79,6 +79,7 @@ export abstract class BaseOpenAiCompatibleProvider // Get model-specific options for GLM models (applies Z.ai optimizations) // This allows third-party GLM models via OpenAI-compatible endpoints to benefit // from the same optimizations used by Z.ai + console.log(`[${this.providerName}] Using model ID: "${model}"`) const glmOptions = getGlmModelOptions(model) // Centralized cap: clamp to 20% of the context window (unless provider-specific exceptions apply) @@ -98,6 +99,8 @@ export abstract class BaseOpenAiCompatibleProvider ? (metadata?.parallelToolCalls ?? false) : (metadata?.parallelToolCalls ?? true) + console.log(`[${this.providerName}] parallel_tool_calls set to: ${parallelToolCalls}`) + // Convert messages with GLM-specific handling when applicable // mergeToolResultText prevents GLM models from dropping reasoning_content const convertedMessages = convertToOpenAiMessages(messages, { diff --git a/src/api/providers/lm-studio.ts b/src/api/providers/lm-studio.ts index 8a711634a3..9ff105f429 100644 --- a/src/api/providers/lm-studio.ts +++ b/src/api/providers/lm-studio.ts @@ -45,6 +45,7 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan ): ApiStream { // Get model-specific options for GLM models (applies Z.ai optimizations) const modelId = this.getModel().id + console.log(`[LM Studio] Using model ID: "${modelId}"`) const glmOptions = getGlmModelOptions(modelId) // Convert messages with GLM-specific handling when applicable @@ -96,6 +97,8 @@ export class LmStudioHandler extends BaseProvider implements SingleCompletionHan ? (metadata?.parallelToolCalls ?? false) : (metadata?.parallelToolCalls ?? true) + console.log(`[LM Studio] parallel_tool_calls set to: ${parallelToolCalls}`) + const params: OpenAI.Chat.ChatCompletionCreateParamsStreaming & { draft_model?: string } = { model: modelId, messages: openAiMessages, diff --git a/src/api/providers/utils/model-detection.ts b/src/api/providers/utils/model-detection.ts index 9ac1851ff7..3ba660e896 100644 --- a/src/api/providers/utils/model-detection.ts +++ b/src/api/providers/utils/model-detection.ts @@ -72,6 +72,13 @@ export interface GlmModelOptions { export function getGlmModelOptions(modelId: string): GlmModelOptions { const isGlm = isGlmModel(modelId) + // Log GLM model detection result for diagnostics + if (isGlm) { + console.log(`[GLM Detection] ✓ GLM model detected: "${modelId}"`) + console.log(`[GLM Detection] - mergeToolResultText: true`) + console.log(`[GLM Detection] - disableParallelToolCalls: true`) + } + return { mergeToolResultText: isGlm, disableParallelToolCalls: isGlm,