Skip to content

feat(web): add Z.AI and BigModel native search (rescue of #5685) - #5691

Merged
Hmbown merged 3 commits into
mainfrom
codex/v0912-zai-native-search-5685-20260828
Aug 28, 2026
Merged

feat(web): add Z.AI and BigModel native search (rescue of #5685)#5691
Hmbown merged 3 commits into
mainfrom
codex/v0912-zai-native-search-5685-20260828

Conversation

@Hmbown

@Hmbown Hmbown commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Summary

Reconciliation notes: the adapter's provider gate now admits Openai, Anthropic, Xai, Zai, ModelStudio Token Plan, DeepSeek, and DeepSeek-CN together; route capability arms and tests from all three sibling slices coexist; both changelog entries retained and regenerated in sync.

No-Issue: partial delivery tracked by #5681; this slice must not close the umbrella issue.
Supersedes #5685 (which stays credited to h3c-hexin).

h3c-hexin and others added 3 commits August 28, 2026 16:20
Signed-off-by: hexin <372726039@qq.com>
Signed-off-by: hexin <372726039@qq.com>
Signed-off-by: CodeWhale Bot <bot@codewhale.net>

# Conflicts:
#	CHANGELOG.md
#	crates/config/src/route/capabilities.rs
#	crates/config/src/route/tests.rs
#	crates/tui/CHANGELOG.md
#	crates/tui/src/client/provider_native_search.rs
@claude

claude Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Claude finished @Hmbown's task in 2m 59s —— View job


Claude's review of PR #5691

Todo list

Summary

This is a clean, well-scoped rescue of #5685: it wires structured Z.AI/Zhipu web search behind an exact base-URL allowlist (api.z.ai/api/paas/v4search-prime, open.bigmodel.cn/api/paas/v4search_std), keeps the Coding Plan endpoint and any custom-compatible endpoint fail-closed, and reuses the existing citation/URL-validation plumbing rather than reimplementing it. I traced the merge conflict resolution against origin/main and found no dropped test cases, no duplicate match arms, and no leftover conflict markers anywhere in the tree.

Correctness

  • crates/tui/src/client/provider_native_search/zai.rs:9-14build_body normalizes and matches base_url against the two exact official general-API hosts and bail!s otherwise; the Coding Plan and any gateway/custom host correctly fall through to an error rather than silently sending a request.
  • crates/config/src/route/resolver.rs:243-253 — the new ProviderKind::Zai block runs after the existing custom-endpoint capability reset, and documented_zai_web_search_for_route independently re-checks the exact base URL, so a custom/gateway Zai endpoint can't accidentally inherit Supported even though the block is unconditional. Verified this doesn't regress the pre-existing custom-endpoint fail-closed guarantee.
  • provider_native_search.rs:94-101maximum_domain_count() falls through to Some(0) for Zai (same as the existing Deepseek/ModelStudio arms), so a caller-supplied domains filter is rejected explicitly by tools/web/backend.rs:351-358 with an actionable error instead of zai::build_body silently dropping it. This matches existing precedent for the other Responses-style adapters that don't support domain filters — not a new gap introduced by this PR.
  • All three provider dispatch match blocks in provider_native_search.rs (body build, URL, response parse) add the Zai arm consistently; no arm was missed.

Provider/model/route safety (EPIC #2608)

  • No inference is made from a model-string prefix. The web-search fact is gated on ProviderKind::Zai (explicit provider selection) and an exact base-URL match, and the model id is only used to look up the wire-level allowlist in documented_server_side_web_search. This is consistent with the sibling DeepSeek/Qwen slices already in the branch.

Reuse/simplification

  • Good reuse: zai::parse and zai::build_body route through the shared citation_from_url/push_citation helpers (URL scheme/host validation included) instead of duplicating citation normalization.

Tests

  • Coverage looks adequate for the new surface: unit tests in zai.rs cover both official engines and the coding-endpoint rejection; capabilities.rs and route/tests.rs cover the exact-vs-adjacent-endpoint fail-closed behavior at the route-resolution layer; config/src/tests.rs covers the official-endpoint-family classification. No gaps identified.

Minor nit (non-blocking)

  • crates/config/src/route/capabilities.rs:56 — the Zhipu doc-source link contains raw non-ASCII characters inside a bare <...> autolink (<https://docs.bigmodel.cn/api-reference/工具-api/网络搜索>). CommonMark autolinks are technically ASCII-only, so some renderers may show this as literal text rather than a link. Cosmetic only, doesn't affect compilation or behavior — feel free to leave as-is or percent-encode.

No blocking issues found. Nice work keeping the fail-closed boundary exact on both the adapter and route-resolver sides.

@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: 198326110b

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +115 to +118
let normalized = base_url.trim().trim_end_matches('/').to_ascii_lowercase();
if !matches!(
normalized.as_str(),
"https://api.z.ai/api/paas/v4" | "https://open.bigmodel.cn/api/paas/v4"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve path case when matching exact Z.AI routes

When a configured URL uses a differently cased path such as https://api.z.ai/API/paas/v4, this lowercasing marks the route as search-capable even though URL paths are case-sensitive. The adapter similarly accepts the normalized value, but api_url retains the original path and posts to /API/paas/v4/web_search, causing a failed request instead of failing closed during route resolution. This also conflicts with the existing exact-route predicate and test in provider.rs, which deliberately reject the uppercase-path form; normalize only the scheme/host while comparing the path exactly.

Useful? React with 👍 / 👎.

@Hmbown
Hmbown merged commit 128366a into main Aug 28, 2026
28 checks passed
@Hmbown
Hmbown deleted the codex/v0912-zai-native-search-5685-20260828 branch August 28, 2026 16:50
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