Skip to content

✨ feat: add GLM-5 model support to LobeHub provider#13189

Merged
tjx666 merged 6 commits into
canaryfrom
feat/glm-5-support
Mar 23, 2026
Merged

✨ feat: add GLM-5 model support to LobeHub provider#13189
tjx666 merged 6 commits into
canaryfrom
feat/glm-5-support

Conversation

@tjx666

@tjx666 tjx666 commented Mar 22, 2026

Copy link
Copy Markdown
Member

πŸ’» Change Type

  • ✨ feat
  • πŸ› fix

πŸ”— Related Issue

Fixes LOBE-5086

πŸ”€ Description of Change

Add GLM-5 model support to the LobeHub hosted provider, along with two streaming bug fixes discovered during testing:

Model card & runtime

  • Add GLM-5 model card (lobehub/chat/zhipu.ts) with USD fixed pricing ($1/M input, $3.2/M output)
  • Register zhipu as a new ApiType in RouterRuntime with LobeZhipuAI mapping
  • Pass payload through handleStream so pricing flows to withUsageCost for correct billing

Bug fixes

  • MessageToolCallSchema: use .catch() on all fields to prevent ZodError when providers (e.g., GLM-5) send null in early streaming tool_call chunks
  • StreamingHandler.handleFinish: call endReasoningIfNeeded() to ensure the reasoning spinner completes even when the stop chunk doesn't reach handleChunk (tool call scenarios)

πŸ§ͺ How to Test

  • Tested locally
  • Added/updated tests
    • StreamingHandler.test.ts: 2 new test cases for handleFinish reasoning guard

Test prompts used with GLM-5:

  • Simple conversation: "hello"
  • Tool calling: "write a snake game" (triggers artifacts)
  • Search: "what's the weather in Beijing today"

@vercel

vercel Bot commented Mar 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Mar 23, 2026 9:37am

Request Review

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot

Copy link
Copy Markdown
Member

@sxjeru @arvinxx - This PR adds GLM-5 model support to the LobeHub provider and includes streaming bug fixes. Please coordinate on review.

@codecov

codecov Bot commented Mar 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 26.08696% with 17 lines in your changes missing coverage. Please review.
βœ… Project coverage is 74.21%. Comparing base (9eca3d2) to head (84ee107).
⚠️ Report is 2 commits behind head on canary.

Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #13189       +/-   ##
===========================================
- Coverage   84.35%   74.21%   -10.15%     
===========================================
  Files         375     1535     +1160     
  Lines       24447   126184   +101737     
  Branches     4740    13913     +9173     
===========================================
+ Hits        20623    93643    +73020     
- Misses       3731    32430    +28699     
- Partials       93      111       +18     
Flag Coverage Ξ”
app 67.16% <ΓΈ> (?)
database 97.89% <ΓΈ> (?)
packages/agent-runtime 89.60% <ΓΈ> (?)
packages/context-engine 83.53% <ΓΈ> (ΓΈ)
packages/conversation-flow 92.36% <ΓΈ> (?)
packages/file-loaders 87.02% <ΓΈ> (ΓΈ)
packages/memory-user-memory 66.68% <ΓΈ> (?)
packages/model-bank 99.84% <ΓΈ> (?)
packages/model-runtime 84.79% <26.08%> (+<0.01%) ⬆️
packages/prompts 74.60% <ΓΈ> (ΓΈ)
packages/python-interpreter 92.90% <ΓΈ> (ΓΈ)
packages/ssrf-safe-fetch 0.00% <ΓΈ> (?)
packages/utils 90.09% <ΓΈ> (ΓΈ)
packages/web-crawler 88.82% <ΓΈ> (ΓΈ)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Ξ”
Store 66.04% <ΓΈ> (βˆ…)
Services 49.86% <ΓΈ> (βˆ…)
Server 68.74% <ΓΈ> (βˆ…)
Libs 42.20% <ΓΈ> (βˆ…)
Utils 91.41% <ΓΈ> (-2.07%) ⬇️
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3ea55e504f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +45 to +48
arguments: z.string().catch(''),
name: z.string().catch(''),
}),
id: z.string(),
id: z.string().catch(''),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Don't swallow missing tool ids/names in streamed tool calls

For the GLM-5 case mentioned in the comment, these fallbacks do not let later chunks β€œfill in the correct values”. OpenAIStream still assigns a synthetic id to the first partial chunk, and parseToolCalls() (packages/model-runtime/src/helpers/parseToolCalls.ts) only concatenates function.arguments; it never backfills function.name/id, and if a later chunk finally includes the real id it is treated as a second tool call. In practice, onToolsCalling consumers will see an empty or duplicated tool during streaming for Zhipu/GLM-5 instead of a single progressively completed call.

Useful? React with πŸ‘Β / πŸ‘Ž.

if (reader) {
let done = false;
while (!done) {
const { value, done: isDone } = await reader.read();
tjx666 added 6 commits March 23, 2026 17:29
- Add GLM-5 model card with USD fixed pricing
- Register zhipu as a new ApiType in RouterRuntime
- Pass payload through handleStream for correct billing
Some providers (e.g., Zhipu GLM-5) send null for function.name/id in
early streaming tool_call chunks. Use .catch() to prevent ZodError from
breaking the SSE stream.
When a model calls tools, the stop chunk may not reach handleChunk,
leaving the reasoning spinner stuck. Call endReasoningIfNeeded() at
the start of handleFinish to ensure reasoning always completes.
…ary reasoning guard

- Add test verifying payload is passed to custom handleStream
- Revert endReasoningIfNeeded guard in handleFinish (reasoning is
  already ended by handleToolCallsChunk and handleTextChunk)
The .catch('') on MessageToolCallSchema was only needed for aihubmix
proxy which sends null values; the official zai API sends correct data.
Remove the global schema relaxation and its associated tests.
With tool_stream enabled, some proxies (e.g., aihubmix) send empty
placeholder tool_call chunks without id/function.name before the real
data arrives. Filter them out to prevent ZodError in parseToolCalls.
@tjx666 tjx666 force-pushed the feat/glm-5-support branch from fd15036 to 84ee107 Compare March 23, 2026 09:29
@tjx666 tjx666 merged commit fadaeef into canary Mar 23, 2026
34 checks passed
@tjx666 tjx666 deleted the feat/glm-5-support branch March 23, 2026 09:46
@lobehubbot

Copy link
Copy Markdown
Member

❀️ Great PR @tjx666 ❀️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

hardy-one pushed a commit to hardy-one/lobehub that referenced this pull request Mar 23, 2026
ONLY-yours added a commit that referenced this pull request Mar 27, 2026
# πŸš€ release: 20260326

This release includes **91 commits**. Key updates are below.


- **Agent can now execute background tasks** β€” Agents can perform
long-running operations without blocking your conversation.
[#13289](#13289)
- **Better error messages** β€” Redesigned error UI across chat and image
generation with clearer explanations and recovery options.
[#13302](#13302)
- **Smoother topic switching** β€” No more full page reloads when
switching topics while an agent is responding.
[#13309](#13309)
- **Faster image uploads** β€” Large images are now automatically
compressed to 1920px before upload, reducing wait times.
[#13224](#13224)
- **Improved knowledge base** β€” Documents are now properly parsed before
chunking, improving retrieval accuracy.
[#13221](#13221)

### Bot Platform

- **WeChat Bot support** β€” You can now connect LobeChat to WeChat, in
addition to Discord.
[#13191](#13191)
- **Richer bot responses** β€” Bots now support custom markdown rendering
and context injection.
[#13294](#13294)
- **New bot commands** β€” Added `/new` to start fresh conversations and
`/stop` to halt generation.
[#13194](#13194)
- **Discord stability fixes** β€” Fixed thread creation issues and Redis
connection drops.
[#13228](#13228)
[#13205](#13205)

### Models & Providers

- **GLM-5** is now available in the LobeHub model list.
[#13189](#13189)
- **Coding Plan providers** β€” Added support for code planning assistant
providers. [#13203](#13203)
- **Tencent Hunyuan 3.0 ImageGen** β€” New image generation model from
Tencent. [#13166](#13166)
- **Gemini content handling** β€” Better handling when Gemini blocks
content due to safety filters.
[#13270](#13270)
- **Claude token limits fixed** β€” Corrected max window tokens for
Anthropic Claude models.
[#13206](#13206)

### Skills & Tools

- **Auto credential injection** β€” Skills can now automatically request
and use required credentials.
[#13124](#13124)
- **Smarter tool permissions** β€” Built-in tools skip confirmation for
safe paths like `/tmp`.
[#13232](#13232)
- **Model switcher improvements** β€” Quick access to provider settings
and visual highlight for default model.
[#13220](#13220)

### Memory

- **Bulk delete memories** β€” You can now delete all memory entries at
once. [#13161](#13161)
- **Per-agent memory control** β€” Memory injection now respects
individual agent settings.
[#13265](#13265)

### Desktop App

- **Gateway connection** β€” Desktop app can now connect to LobeHub
Gateway for enhanced features.
[#13234](#13234)
- **Connection status indicator** β€” See gateway connection status in the
titlebar. [#13260](#13260)
- **Settings persistence** β€” Gateway toggle state now persists across
app restarts. [#13300](#13300)

### CLI

- **API key authentication** β€” CLI now supports API key auth for
programmatic access.
[#13190](#13190)
- **Shell completion** β€” Tab completion for bash/zsh/fish shells.
[#13164](#13164)
- **Man pages** β€” Built-in manual pages for CLI commands.
[#13200](#13200)

### Security

- **XSS protection** β€” Sanitized search result image titles to prevent
script injection.
[#13303](#13303)
- **Workflow hardening** β€” Fixed potential shell injection in release
automation. [#13319](#13319)
- **Dependency update** β€” Updated nodemailer to address security
advisory. [#13326](#13326)

### Bug Fixes

- Fixed skill page not redirecting correctly after import.
[#13255](#13255)
[#13261](#13261)
- Fixed token counting in group chats.
[#13247](#13247)
- Fixed editor not resetting when switching to empty pages.
[#13229](#13229)
- Fixed manual tool toggle not working.
[#13218](#13218)
- Fixed Search1API response parsing.
[#13207](#13207)
[#13208](#13208)
- Fixed mobile topic menus rendering issues.
[#12477](#12477)
- Fixed history count calculation for accurate context.
[#13051](#13051)
- Added missing Turkish translations.
[#13196](#13196)

### Credits

Huge thanks to these contributors:

@bakiburakogun @hardy-one @Zhouguanyang @sxjeru @hezhijie0327 @arvinxx
@cy948 @CanisMinor @Innei @lijian @lobehubbot @neko @rdmclin2
@rivertwilight @tjx666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants