From 6457fe1a9d93edc289d9f52baf920dd7abbf1eb0 Mon Sep 17 00:00:00 2001 From: wocaoniubi123 <208344286+wocaoniubi123@users.noreply.github.com> Date: Thu, 5 Nov 2026 22:45:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=9A=84=E7=A7=AF=E5=88=86=E5=88=97=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E4=B8=BA=E7=A9=BA=EF=BC=88=E8=AE=B0=E8=B4=A6=E6=97=B6?= =?UTF-8?q?=E6=BC=8F=E6=8B=B7=20snapshot.credit=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `RequestTelemetry::snapshot()` 已从上游 usage 解析出 credit(WorkBuddy 的 `usage.credit`、Loomy 的 `points_consumed`),但 `record_entry` 只拷了 token 四件套,漏了 credit,于是 `NewRequestEntry.credit` 恒为 None、落库 NULL,界面显示「上游没有返回积分消耗」。实测原始报文里 `usage.credit=0.58`,同一条请求 token 记对了、credit 是 NULL。修后自建 3.4.2 包验证:库内 credit 落 0.05/0.15/0.44/0.54。 --- desktop-tauri/src-tauri/server/src/server/api/pipeline.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs b/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs index 242305873..a8002f8cb 100644 --- a/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs +++ b/desktop-tauri/src-tauri/server/src/server/api/pipeline.rs @@ -653,6 +653,12 @@ pub fn record_entry(context: &RecordContext, fallback_error: Option) { entry.completion_tokens = snapshot.completion_tokens; entry.total_tokens = snapshot.total_tokens; entry.cache_read_tokens = snapshot.cache_read_tokens; + // 积分消耗:遥测已经从上游 `usage` 里解析出来了(WorkBuddy 的 `credit`、 + // Loomy 的 `points_consumed`,见 `core::upstream::usage::CREDIT_KEYS`), + // 但这里不拷就等于「解析到了没落库」—— 界面会一直显示「上游没有返回积分 + // 消耗」,而报文里明明有(实测 WorkBuddy `usage.credit=0.58` 同时刻 token + // 记对了、credit 是 NULL)。别删这一行。 + entry.credit = snapshot.credit; // Token 限制器的增量记账(先取快照再 record:entry 的字段已被 move)。 // 请求收尾立刻把本次消耗加进当前窗口,选路的 Token 跳过判定不必等下一轮 // 10 秒刷新。account_id 为空 = 没走到任何账号(转发前就失败的路径),