fix(llm): 测试连接补发自定义会话头,修 opencode zen 400

testLLM 单发路径既没往 context 挂 session id,也没把 profile 的
session_header_key 透传给 cfg,导致强制要求 x-opencode-session 的端点
(opencode zen)在"对话正常"时"点击测试"却 400 MissingSessionID。

- provider.go: TestConnection 挂一个一次性随机 session id 作头值
- server.go: testLLM 透传 session_header_key,并从已存 profile 兜底
- web: api.ts / llm page 把该字段传到 /llm/test
This commit is contained in:
Autumn-27 committed 2026-09-11 10:45:27 -04:00
1 parent d86dd152c3
commit 399f971f41
4 files changed
+31 -11

No files matched your search

+1
View File
@@ -400,6 +400,7 @@ function ProfileSheet({
toStore(effort),
profileId,
streaming,
sessionHeaderKey.trim(),
);
// 回复内容一并展示:看得见模型确实说了话,才算和会话里跑通是一回事。
if (r.ok)
+2
View File
@@ -784,6 +784,7 @@ export const api = {
reasoning_effort = "",
profile_id?: number,
streaming = true, // 用该配置真实的收发模式来测,别让"流式能通、非流式不通"漏到会话里
session_header_key = "", // 非空=测试请求也带该自定义会话头(值为一次性 session id)
) =>
// reply = 模型实际回复(已截断);一个字都不回的配置后端直接判失败
post<{ ok: boolean; error?: string; latency_ms?: number; model?: string; reply?: string }>("/llm/test", {
@@ -796,6 +797,7 @@ export const api = {
reasoning_effort,
profile_id,
streaming,
session_header_key,
}),
llmProfiles: () => get<{ profiles: LLMProfile[] }>("/llm/profiles").then((r) => arr(r.profiles)),
saveLLMProfile: (p: {