Skip to content

Fix Z.AI coding-plan model remap for GLM-5#223

Merged
jamiepine merged 6 commits intospacedriveapp:mainfrom
vsumner:fix/glm5-model-remap
Feb 26, 2026
Merged

Fix Z.AI coding-plan model remap for GLM-5#223
jamiepine merged 6 commits intospacedriveapp:mainfrom
vsumner:fix/glm5-model-remap

Conversation

@vsumner
Copy link
Contributor

@vsumner vsumner commented Feb 25, 2026

Summary

  • fix Z.AI coding-plan model remapping so chat completions use plain model IDs (glm-5)
  • keep optional zai/ prefix compatibility by stripping it before API calls
  • add regression coverage for coding-plan remap behavior

Why

zai-coding-plan/glm-5 requests were being remapped to zai/glm-5, which the coding-plan endpoint rejects with Unknown Model. This produced typing/stop-typing with no final response.

Verification

  • cargo test -q coding_plan_model_name_uses_plain_glm_id
  • cargo clippy --all-targets -q

Related context: follow-up extracted from #216.

Note

The fix extracts the model remapping logic into a standalone function and corrects the Z.AI Coding Plan behavior to send plain model IDs (e.g., "glm-5") instead of the provider-prefixed format ("zai/glm-5"). The implementation strips any optional "zai/" prefix before sending to the API. Test coverage verifies both bare and prefixed model names are handled correctly, and that other providers are unaffected.

Written by Tembo for commit eea072a.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b209d7 and b7cda98.

📒 Files selected for processing (1)
  • src/llm/model.rs

Walkthrough

Extracted model-name remapping into a new free function remap_model_name_for_api(provider: &str, model_name: &str) -> String; updated SpacebotModel::remap_model_name_for_api(&self) to delegate to it; added cfg(test) unit tests for the Z.AI coding-plan special-case and a non-special-case.

Changes

Cohort / File(s) Summary
Model remapping implementation & API
src/llm/model.rs
Added a new free function remap_model_name_for_api(provider: &str, model_name: &str) -> String that applies the "zai-coding-plan" special-case (strips zai/ prefix to return a plain glm-5 id) and otherwise returns the original model name; updated SpacebotModel::remap_model_name_for_api(&self) to call the new function and removed the in-method special-case branch.
Tests
src/llm/model.rs (cfg(test) section)
Added unit tests verifying behavior for the coding-plan special-case and a non-coding-plan case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: fixing Z.AI coding-plan model remapping for GLM-5, which matches the core objective of the PR.
Description check ✅ Passed The description is highly detailed and directly related to the changeset, explaining the problem, solution, and verification steps for the model remapping fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +1584 to +1587
assert_eq!(
remap_model_name_for_api("openai", "gpt-4o-mini"),
"gpt-4o-mini"
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor test hardening: could add a non-zai-coding-plan case where the model does have a zai/ prefix, to make sure we don’t accidentally strip prefixes for other providers later.

Suggested change
assert_eq!(
remap_model_name_for_api("openai", "gpt-4o-mini"),
"gpt-4o-mini"
);
assert_eq!(
remap_model_name_for_api("openai", "gpt-4o-mini"),
"gpt-4o-mini"
);
assert_eq!(
remap_model_name_for_api("openai", "zai/glm-5"),
"zai/glm-5"
);

@jamiepine jamiepine merged commit 3514626 into spacedriveapp:main Feb 26, 2026
2 of 4 checks passed
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