From 7c905c4bf352f0f24cb9c51104db6ad065c0be33 Mon Sep 17 00:00:00 2001 From: OG T Date: Sun, 29 Mar 2026 00:03:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(ai):=20=E4=BF=AE=E5=BE=A9=20generate=5Finci?= =?UTF-8?q?dent=5Fproposal=20tuple=20unpacking=20=E9=8C=AF=E8=AA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - _call_with_cache 返回 6 值 (含 ai_tokens/ai_cost) - generate_incident_proposal 解包只取 4 值導致 ValueError - 修復: 完整解包 6 值並傳遞 ai_tokens/ai_cost 到 proposal_dict 2026-03-29 ogt: Token/Cost 追蹤補遺 Co-Authored-By: Claude Opus 4.5 --- apps/api/src/services/openclaw.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/api/src/services/openclaw.py b/apps/api/src/services/openclaw.py index d3ef3afa2..7b33be2e7 100644 --- a/apps/api/src/services/openclaw.py +++ b/apps/api/src/services/openclaw.py @@ -1261,7 +1261,8 @@ Focus on: "severity": severity, } - raw_response, provider, success, from_cache = await self._call_with_cache( + # 2026-03-29 ogt: 修復 tuple unpacking (Token/Cost 追蹤) + raw_response, provider, success, from_cache, ai_tokens, ai_cost = await self._call_with_cache( proposal_prompt, alert_context, signoz_metrics, @@ -1290,6 +1291,7 @@ Focus on: ) # 轉換為 proposal dict (optimization_suggestions 是 list[dict]) + # 2026-03-29 ogt: 加入 ai_tokens/ai_cost 追蹤 proposal_dict = { "action": result.action_title, "description": result.description, @@ -1311,6 +1313,8 @@ Focus on: "signoz_correlation": result.signoz_correlation, "from_cache": from_cache, "provider": provider, + "ai_tokens": ai_tokens, + "ai_cost": ai_cost, } return proposal_dict, provider, True