Add GLM 5.2 direct and OpenRouter support#589
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds GLM 5.2 across Fabro’s model catalog and OpenAI-compatible wire handling, including OpenRouter routing and regression coverage, so GLM 5.2 can be selected (and defaulted for Z.ai) with correct reasoning/tool behavior and authoritative cost reporting.
Changes:
- Add
glm-5.2to the direct Z.ai catalog (set as Z.ai default + new aliases) and addz-ai/glm-5.2to the opt-in OpenRouter catalog with limits, reasoning controls, caching, and pricing. - Extend the OpenAI-compatible decoder to accept OpenRouter’s normalized
reasoningfield in both streaming and non-streaming responses (in addition toreasoning_content). - Add/extend catalog assertions and add a live OpenRouter E2E regression test for GLM 5.2 reasoning + tool-call round trip + authoritative cost.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/crates/fabro-model/src/catalog/providers/zai.toml | Introduces glm-5.2 as the default Z.ai model with limits/features/controls/costs and adjusts GLM 4.7 aliases accordingly. |
| lib/crates/fabro-model/src/catalog/providers/openrouter.toml | Adds z-ai/glm-5.2 OpenRouter model entry with limits, reasoning controls, caching, and pricing. |
| lib/crates/fabro-model/src/catalog.rs | Adds catalog tests/snapshots validating GLM 5.2 presence, defaults/aliases, and OpenRouter opt-in behavior. |
| lib/crates/fabro-llm/tests/it/wire/openai_compatible.rs | Updates streaming transcript coverage to exercise OpenRouter-style reasoning deltas. |
| lib/crates/fabro-llm/tests/integration.rs | Adds a live OpenRouter E2E test for GLM 5.2 reasoning + required tool-call + tool-result replay + authoritative costs. |
| lib/crates/fabro-llm/src/codec/openai_compatible/wire.rs | Extends wire structs to deserialize reasoning, adds helpers, and unit tests for both spellings. |
| lib/crates/fabro-llm/src/codec/openai_compatible/stream.rs | Uses the unified reasoning accessor when accumulating streamed reasoning deltas. |
| lib/crates/fabro-llm/src/codec/openai_compatible/response.rs | Uses the unified reasoning accessor when decoding non-streamed responses into Thinking parts. |
| lib/crates/fabro-llm/src/adapter_registry.rs | Updates the built-in route equivalence table to include glm-5.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # lib/crates/fabro-llm/tests/integration.rs # lib/crates/fabro-model/src/catalog.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Bryan Helmkamp <19+brynary@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
lib/crates/fabro-llm/src/codec/openai_compatible/wire.rs:201
reasoning()prefersreasoning_contenteven when it is an empty string, which can suppress OpenRouterreasoningdeltas if both keys are present. Filter out empty strings so the fallback works correctly.
pub(super) fn reasoning(&self) -> Option<&str> {
self.reasoning_content
.as_deref()
.or(self.reasoning.as_deref())
}
Comment on lines
+84
to
+89
| pub(super) fn reasoning(&self) -> Option<&str> { | ||
| self.reasoning_content | ||
| .as_deref() | ||
| .or(self.reasoning.as_deref()) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
z-ai/glm-5.2to the opt-in OpenRouter catalogreasoning_contentand the OpenRouter-normalizedreasoningfield in the generic OpenAI-compatible codecVerification
437, and authoritative cost reportingcargo nextest run --locked -p fabro-model -p fabro-llm --no-fail-fast --status-level fail(755 passed)cargo +nightly-2026-04-14 clippy --locked -p fabro-model -p fabro-llm --all-targets -- -D warningscargo +nightly-2026-04-14 fmt --check --all