fix(relay): fix llm_routing read path bug and add User-Agent header for Coding Plan
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
1. connectionStore.ts: storedAccount.account.llm_routing → storedAccount.llm_routing
- saveSaaSSession stores SaaSAccountInfo directly, not { account: SaaSAccountInfo }
- This bug caused admin llm_routing config to never take effect
2. relay/service.rs: add User-Agent: claude-code/1.0 header
- Kimi Coding Plan requires recognized coding agent User-Agent
- Default reqwest UA is rejected with 403
3. Docs: add llm_routing routing mode explanation and troubleshooting entries
This commit is contained in:
@@ -2040,7 +2040,51 @@ Next.js App Router SSR
|
||||
|
||||
---
|
||||
|
||||
## 14. 相关文档
|
||||
## 14. SaaS Relay 模式未生效 — llm_routing 读取路径 Bug (2026-03-31)
|
||||
|
||||
**症状**: Admin 后台配置 `llm_routing=relay`,但桌面端仍走本地 Kernel 模式(需要本地 API Key),不经过 SaaS Key Pool 中转。
|
||||
|
||||
**根本原因**: `desktop/src/store/connectionStore.ts` 第 362 行的 `llm_routing` 读取路径多了一层嵌套:
|
||||
|
||||
```typescript
|
||||
// ❌ 错误:storedAccount 是 SaaSAccountInfo 对象本身,不是 { account: SaaSAccountInfo }
|
||||
const adminRouting = storedAccount?.account?.llm_routing;
|
||||
|
||||
// ✅ 正确:直接读取 SaaSAccountInfo.llm_routing
|
||||
const adminRouting = storedAccount?.llm_routing;
|
||||
```
|
||||
|
||||
`saveSaaSSession` 将 `session.account`(即 `SaaSAccountInfo`)直接 `JSON.stringify` 存入 localStorage 的 `zclaw-saas-account` 键。但 connectionStore 误以为存储结构是 `{ account: { llm_routing: ... } }`,实际是 `{ llm_routing: ... }`。
|
||||
|
||||
**修复**: 修改 `desktop/src/store/connectionStore.ts` 第 362 行。
|
||||
|
||||
**影响**: 此 bug 导致 `llm_routing` 管理端配置从未生效,所有桌面端都忽略 admin 路由优先级,走默认连接模式。
|
||||
|
||||
**验证**: 登录后检查 SaaS 后端 relay tasks 表是否有新记录。如果没有新 relay task 创建,说明走了本地模式。
|
||||
|
||||
---
|
||||
|
||||
## 15. SaaS Relay 403 — Coding Plan 不识别 User-Agent (2026-03-31)
|
||||
|
||||
**症状**: SaaS relay 模式调用 Kimi Coding Plan 时返回 403:
|
||||
|
||||
```json
|
||||
{"error":{"message":"Kimi For Coding is currently only available for Coding Agents such as Kimi CLI, Claude Code, Roo Code, Kilo Code, etc.","type":"access_terminated_error"}}
|
||||
```
|
||||
|
||||
**根本原因**: SaaS relay 的 `execute_relay()` 使用默认 reqwest User-Agent(`reqwest/0.12.x`),Kimi Coding Plan 检查 User-Agent 白名单。
|
||||
|
||||
**修复**: `crates/zclaw-saas/src/relay/service.rs` 的 HTTP 请求构建中添加:
|
||||
|
||||
```rust
|
||||
.header("User-Agent", "claude-code/1.0")
|
||||
```
|
||||
|
||||
**注意**: 此修复与 9.7 节类似,但 9.7 修复的是桌面端直连时的 User-Agent,此处修复的是 SaaS 后端作为代理转发时的 User-Agent。两者都需要。
|
||||
|
||||
---
|
||||
|
||||
## 16. 相关文档
|
||||
|
||||
- [ZCLAW 配置指南](./zclaw-configuration.md) - 配置文件位置、格式和最佳实践
|
||||
- [Agent 和 LLM 提供商配置](./agent-provider-config.md) - Agent 管理和 Provider 配置
|
||||
@@ -2052,6 +2096,7 @@ Next.js App Router SSR
|
||||
|
||||
| 日期 | 变更 |
|
||||
|------|------|
|
||||
| 2026-03-31 | 添加第 14/15 节:llm_routing 读取路径 Bug + SaaS Relay 403 User-Agent 缺失 — relay 模式从未生效的根因分析 |
|
||||
| 2026-03-30 | 添加第 13 节:Admin 前端 ERR_ABORTED / 后端卡死 — Next.js SSR/hydration + SWR 根本冲突导致连接池耗尽,admin-v2 (Ant Design Pro 纯 SPA) 替代方案 |
|
||||
| 2026-03-28 | 添加 12.1-12.4 节:SaaS 后端问题 — Admin 登录无请求、SQLite→PostgreSQL 遗留语法、角色权限不足、usage 路由不匹配 |
|
||||
| 2026-03-27 | 添加 9.10/9.11 节:多轮工具调用 tool_call_id + reasoning_content 缺失 — OpenAiMessage 字段补全、[Assistant,ToolUse*] 合并、reasoning 分离追踪 |
|
||||
|
||||
Reference in New Issue
Block a user