🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix: allow disabling zhipu tool stream (#16331)
YuTengjinga8d6b0551cb1
diff --git a/packages/model-runtime/src/providers/zhipu/index.test.ts b/packages/model-runtime/src/providers/zhipu/index.test.tsindex 230e958c961..3545581773e 100644--- a/packages/model-runtime/src/providers/zhipu/index.test.ts+++ b/packages/model-runtime/src/providers/zhipu/index.test.ts@@ -439,6 +439,29 @@ describe('LobeZhipuAI - custom features', () => {expect(payload.tool_stream).toBe(expected);});++ it('should allow compatible channels to disable tool_stream without disabling Zhipu payload handling', () => {+ const payload = params.chatCompletion.handlePayload(+ {+ max_tokens: 4096,+ messages: [+ { content: 'Hello', reasoning: { content: 'cached thought' }, role: 'user' },+ ],+ model: 'glm-5.2',+ preserveThinking: true,+ stream: true,+ temperature: 0.5,+ thinking: { type: 'enabled' },+ },+ { disableToolStream: true },+ );++ expect(payload.tool_stream).toBeUndefined();+ expect(payload.thinking).toEqual({ clear_thinking: false, type: 'enabled' });+ expect(payload.messages).toEqual([+ { content: 'Hello', reasoning_content: 'cached thought', role: 'user' },+ ]);+ });});describe('GLM-5.2 optional params', () => {diff --git a/packages/model-runtime/src/providers/zhipu/index.ts b/packages/model-runtime/src/providers/zhipu/index.tsindex f13080f46a8..0e455f67a93 100644--- a/packages/model-runtime/src/providers/zhipu/index.ts+++ b/packages/model-runtime/src/providers/zhipu/index.ts@@ -19,10 +19,15 @@ export interface ZhipuModelCard {modelName: string;}+interface ZhipuRuntimeOptions {+ [key: string]: unknown;+ disableToolStream?: boolean;+}+export const params = {baseURL: 'https://open.bigmodel.cn/api/paas/v4',chatCompletion: {- handlePayload: (payload) => {+ handlePayload: (payload, options: ZhipuRuntimeOptions = {}) => {const {enabledSearch,max_tokens,@@ -106,6 +111,10 @@ export const params = {},);+ // Example: Fireworks serves GLM-5.2 but rejects the Z.ai-only `tool_stream` field.+ const shouldEnableToolStream =+ !options.disableToolStream && stream && isToolStreamSupportedGLMModel(model);+return {...rest,...resolvedParams,@@ -113,7 +122,7 @@ export const params = {model,stream,thinking: resolvedThinking,- tool_stream: stream && isToolStreamSupportedGLMModel(model) ? true : undefined,+ tool_stream: shouldEnableToolStream ? true : undefined,tools: zhipuTools,} as any;},@@ -210,6 +219,6 @@ export const params = {return processModelList(standardModelList, MODEL_LIST_CONFIGS.zhipu, 'zhipu');},provider: ModelProvider.ZhiPu,-} satisfies OpenAICompatibleFactoryOptions;+} satisfies OpenAICompatibleFactoryOptions<ZhipuRuntimeOptions>;-export const LobeZhipuAI = createOpenAICompatibleRuntime(params);+export const LobeZhipuAI = createOpenAICompatibleRuntime<ZhipuRuntimeOptions>(params);