Skip to content

Add GLM 5.2 direct and OpenRouter support#589

Merged
brynary merged 5 commits into
mainfrom
codex/glm-5-2-support
Jul 22, 2026
Merged

Add GLM 5.2 direct and OpenRouter support#589
brynary merged 5 commits into
mainfrom
codex/glm-5-2-support

Conversation

@brynary

@brynary brynary commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • add GLM 5.2 to the direct Z.AI catalog and make it the Z.AI default
  • add z-ai/glm-5.2 to the opt-in OpenRouter catalog
  • expose route-appropriate reasoning controls, context limits, caching, and pricing
  • decode both reasoning_content and the OpenRouter-normalized reasoning field in the generic OpenAI-compatible codec
  • add catalog coverage and a live GLM 5.2 reasoning/tool round-trip regression test

Verification

  • live OpenRouter E2E: forced multiply tool call, reasoning capture, tool-result replay to 437, and authoritative cost reporting
  • cargo 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 warnings
  • cargo +nightly-2026-04-14 fmt --check --all
  • no pending snapshots

Copilot AI review requested due to automatic review settings July 22, 2026 21:19

Copilot AI 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.

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.2 to the direct Z.ai catalog (set as Z.ai default + new aliases) and add z-ai/glm-5.2 to the opt-in OpenRouter catalog with limits, reasoning controls, caching, and pricing.
  • Extend the OpenAI-compatible decoder to accept OpenRouter’s normalized reasoning field in both streaming and non-streaming responses (in addition to reasoning_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.

Copilot AI review requested due to automatic review settings July 22, 2026 21:26

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

# Conflicts:
#	lib/crates/fabro-llm/tests/integration.rs
#	lib/crates/fabro-model/src/catalog.rs
Copilot AI review requested due to automatic review settings July 22, 2026 22:37

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread lib/crates/fabro-llm/tests/it/wire/openai_compatible.rs Outdated
Comment thread lib/crates/fabro-llm/src/codec/openai_compatible/wire.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>
Copilot AI review requested due to automatic review settings July 22, 2026 23:14

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 22, 2026 23:29

Copilot AI 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.

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() prefers reasoning_content even when it is an empty string, which can suppress OpenRouter reasoning deltas 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())
}
}
@brynary
brynary merged commit d629816 into main Jul 22, 2026
14 checks passed
@brynary
brynary deleted the codex/glm-5-2-support branch July 22, 2026 23:47
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