Skip to content

feat(zai): add China Coding Plan provider and fix endpoint priority - #11429

Closed
afanty2021 wants to merge 16 commits into
NousResearch:mainfrom
afanty2021:feat/zai-china-coding-plan
Closed

feat(zai): add China Coding Plan provider and fix endpoint priority#11429
afanty2021 wants to merge 16 commits into
NousResearch:mainfrom
afanty2021:feat/zai-china-coding-plan

Conversation

@afanty2021

Copy link
Copy Markdown

📋 功能概述

为 ZAI (智谱AI) 添加 China Coding Plan 端点支持,并修复端点优先级问题。

🎯 动机

中国用户的 ZAI API key 分为普通端点和 Coding Plan 端点两个独立计费项:

  • 普通端点:按 token 计费,费用较高
  • Coding Plan 端点:专为代码生成优化,费用更低

当前问题:

  1. ❌ 自动检测可能选择错误的端点,导致额外扣费
  2. ❌ 配置文件中的 base_url 设置被自动检测覆盖
  3. ❌ 缺少 China Coding Plan 端点的专门配置

✨ 改进内容

1. 新增 zai-coding-cn Provider

  • 支持 China Coding Plan 端点:https://open.bigmodel.cn/api/coding/paas/v4
  • 独立的 provider ID,可精确选择计费方式
  • 添加模型别名:glm-cn, zai-cn, zhipu-cn

2. 优化端点检测顺序

之前:Global → China → Coding Plan (Global) → Coding Plan (China)
现在:China (Coding Plan) → Global (Coding Plan) → China → Global

优先尝试 Coding Plan 端点,为中国用户提供更经济的选项。

3. 修复 base_url 解析优先级

新优先级:explicit_base_url > 环境变量 > 配置文件 > 自动检测 > 默认端点

配置文件中的 base_url 设置现在会被正确识别,不会被自动检测覆盖。

4. 新增缓存清理工具

  • scripts/clear_zai_cache.py - 清理 auth.json 中的端点缓存

📝 修改文件

文件 修改
.env.example 更新 ZAI 端点文档
hermes_cli/auth.py 新增 provider,调整端点顺序
hermes_cli/main.py 添加 provider 支持
hermes_cli/models.py 添加模型别名
hermes_cli/providers.py 添加 Hermes overlay
hermes_cli/runtime_provider.py 修复 base_url 优先级
scripts/clear_zai_cache.py 新增工具脚本

🧪 测试

已验证:

  • ✅ 端点顺序正确(China Coding Plan 优先)
  • ✅ 配置文件 base_url 优先于自动检测
  • ✅ 模型别名正常工作
  • ✅ 缓存清理脚本功能正常

📚 相关问题

解决中国用户在使用 ZAI Coding Plan API key 时遇到的额外扣费问题。


Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

afanty2021 and others added 16 commits April 8, 2026 22:45
- Created complete AI context documentation system with 9 module docs
- Added 8 architecture decision records (ADRs) with Mermaid diagrams
- Implemented module interaction flowcharts in root CLAUDE.md
- Established ADR feedback mechanism with voting and discussion process
- Added ADR navigation mindmap and changelog
- Achieved 100% module documentation coverage (9/9 modules)

Module docs:
- agent: Core agent logic (prompt builder, context compressor, memory manager)
- hermes_cli: CLI interface (command registry, config system, setup wizard)
- tools: Tool system (registry, execution, scheduling)
- gateway: Message platform gateway (platform adapters, session management)
- environments: RL training environments (agent loop, benchmarks)
- cron: Cron scheduler (job scheduling, persistence)
- acp_adapter: ACP protocol adapter (IDE integration)
- plugins: Plugin system (memory providers, extensibility)
- tests: Test suite (unit, integration, E2E, benchmarks)

Architecture Decision Records:
- ADR-001: Synchronous agent loop
- ADR-002: Centralized tool registry
- ADR-003: Multi-instance configuration isolation
- ADR-004: Prompt cache protection
- ADR-005: Memory provider plugin system
- ADR-006: Command system design
- ADR-007: Session management system
- ADR-008: Skill system architecture

Documentation features:
- 15 Mermaid diagrams (flowcharts, sequence diagrams, state diagrams, mindmaps)
- Breadcrumb navigation in all module docs
- Cross-references between modules and ADRs
- Complete ADR feedback mechanism with voting
- ADR changelog tracking architecture evolution

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…文本批处理、OAuth 令牌同步\n- 新功能:/fast 命令、Codex 快速模式\n- 文档与测试:流式超时文档、文本批处理测试
- 更新根级 CLAUDE.md:添加 Web UI Dashboard 文档,更新技术栈(React 19、Vite、Tailwind CSS v4)
- 完善 gateway 模块文档:添加 Web 服务器、企业微信平台调试日志
- 完善 hermes_cli 模块文档:添加 Web 服务器、模型配置更新
- 添加 glm-4.5-air 模型支持
- 添加 MEMORY/ 目录到 .gitignore
- 合并上游 v0.9.0 版本(195 个文件更改,+6,834/-2,896 行)

上游主要更新:
- Web UI 移动端响应式支持
- 自定义提供商多模型去重和分组
- 配置系统改进和死代码清理
- Slack 权限修复和贡献者审计脚本

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
`_get_named_custom_provider("ollama")` called `resolve_provider("ollama")`
which aliased "ollama" → "custom" and returned without raising AuthError.
This caused the function to skip the custom_providers lookup and return None,
so fallback to local Ollama silently failed with "provider not configured".

Now when resolve_provider maps to "custom", we fall through to the named
custom provider lookup instead of short-circuiting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update AI context documentation with latest upstream changes:
- Add backup/import system and quick snapshot functionality
- Add OAuth provider management for Web Dashboard
- Add Kimi/Moonshot provider support for China users
- Add debug commands (/debug, hermes debug share)
- Add session tips feature (279 tips total)
- Add native model picker modal (/model)
- Add network configuration options (network.force_ipv4)
- Add component-based logging system
- Add new modules: credential_pool, context_engine, backup, auth_commands
- Update core commands and slash commands documentation
- Add v2026.4.13 changelog entry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 新增 zai-coding-cn provider 支持 China Coding Plan 端点
- 调整 ZAI 端点检测顺序,优先使用 Coding Plan 端点
- 修复 base_url 解析优先级:配置文件 > 自动检测 > 环境变量
- 添加模型别名:glm-cn, zai-cn, zhipu-cn
- 新增 clear_zai_cache.py 工具脚本

修复问题:自动检测可能选择错误端点导致额外扣费

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard provider/zai ZAI provider labels Apr 24, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #13500 and #13911 — all three address ZAI China Coding Plan endpoint support. #13500/#13911 split into 4 static providers; this PR adds a single zai-coding-cn provider with endpoint priority fix.

@afanty2021 afanty2021 closed this Jun 1, 2026
@afanty2021
afanty2021 deleted the feat/zai-china-coding-plan branch June 1, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists provider/zai ZAI provider type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants