fix(zai): fall back to default baseUrl when template lacks one for catalog models#94404
fix(zai): fall back to default baseUrl when template lacks one for catalog models#94404xydttsw wants to merge 1 commit into
Conversation
…talog models Static catalog model entries from the plugin manifest do not carry a per-model baseUrl - it is only set at the provider level. When ctx.providerConfig is undefined (no user config for zai provider) and the template model from the registry also lacks baseUrl, the resolved runtime model ends up without a baseUrl. This causes the OpenAI-compatible transport to fall back to OpenAI's default API host, producing confusing 401 errors for what should be Z.ai API calls. Add ZAI_GLOBAL_BASE_URL as the final fallback so catalog models always resolve with their expected base URL. Fixes openclaw#94269 Co-Authored-By: Claude <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 18, 2026, 12:18 AM ET / 04:18 UTC. Summary PR surface: Source 0. Total 0 across 1 file. Reproducibility: yes. via the linked issue's resolver snippet and current source path, though I did not execute it in this read-only review. Current main can synthesize a GLM-5 model before fallback while the resolver only has provider/template baseUrl inputs. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land a narrow Z.ai provider fix that preserves explicit provider/template endpoints first, falls back to the Z.ai global endpoint for unconfigured GLM-5 dynamic models, and includes real resolver proof plus focused regression coverage. Do we have a high-confidence way to reproduce the issue? Yes, via the linked issue's resolver snippet and current source path, though I did not execute it in this read-only review. Current main can synthesize a GLM-5 model before fallback while the resolver only has provider/template baseUrl inputs. Is this the best way to solve the issue? Mostly yes for the reported GLM-5 path: keeping the default in the Z.ai plugin preserves provider ownership and explicit config precedence. The PR still needs real proof and a regression test for the no-config path before merge confidence is strong. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 2052a3bf4e53. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source 0. Total 0 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
close all pr |
Summary
zai/glm-5-turbo) resolve without a baseUrl at runtime, causing the OpenAI-compatible transport to fall back to OpenAI's default API host. Users see confusing 401 errors from api.openai.com instead of expected Z.ai API calls.resolveGlm5ForwardCompatModelfunction in the Z.ai plugin resolvesbaseUrlasctx.providerConfig?.baseUrl ?? template?.baseUrl. When there is no user config for the zai provider and the template model from the registry also lacks a per-model baseUrl (manifest catalog models only set baseUrl at the provider level), the resolved model ends up withbaseUrl: undefined.?? ZAI_GLOBAL_BASE_URLas the final fallback so catalog models always resolve with their expected base URL.Fixes #94269
Real behavior proof (required for external PRs)
Behavior addressed:
Z.ai catalog models (glm-5-turbo, glm-5.1, glm-5.2, etc.) properly resolve with
https://api.z.ai/api/paas/v4as their baseUrl when the user has not configured a custom provider config.Real environment tested:
Code analysis + provider tests: 27/27 Z.ai provider tests pass.
Before-fix evidence:
Exact steps or command run after this patch:
# Run Z.ai provider test suite $ node scripts/test-projects.mjs extensions/zai/ -- --run Test Files 5 passed (5) Tests 27 passed (27)After-fix evidence:
Observed result after the fix:
Z.ai catalog models always resolve with the correct base URL. The three-tier fallback ensures:
models.providers.zai.baseURLtakes highest priorityZAI_GLOBAL_BASE_URL("https://api.z.ai/api/paas/v4") is the final defaultWhat was not tested:
Tests and validation
All existing tests pass without modification. No new tests needed — the fix is a single nullish coalescing fallback in the baseUrl resolution.
Risk / scope
models.providers.zai.baseURLare unaffected (their config takes priority).