From ae0c7d1ca3344d43c4e476e6875ca29bb93c1d14 Mon Sep 17 00:00:00 2001 From: hmo Date: Tue, 21 Jul 2026 01:39:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(L3):=20self=5Frepair=20=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=20llm=5Fclient(OCG=E7=9B=B4=E8=BF=9E=E6=97=A0session)=20?= =?UTF-8?q?=E5=BA=9F=E5=BC=83=E5=B8=B8=E9=A9=BB'self-repair'=20session?= =?UTF-8?q?=EF=BC=88=E6=8C=87=E4=BB=A4=E5=86=BB=E7=BB=93+=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=E7=B4=AF=E7=A7=AF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/profile-scripts/self_repair.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/deploy/profile-scripts/self_repair.py b/deploy/profile-scripts/self_repair.py index 50299da5..030d8c07 100644 --- a/deploy/profile-scripts/self_repair.py +++ b/deploy/profile-scripts/self_repair.py @@ -175,17 +175,14 @@ def llm_diagnose(failure): 请只输出一个 JSON 动作(不要其他文字)。如果是非交易时段的正常空闲,选 none。""" try: - payload = json.dumps({ - 'model': 'deepseek-v4-flash', - 'messages': [{'role': 'user', 'content': prompt}], - 'max_tokens': 300, 'stream': False, - }).encode() - import urllib.request - req = urllib.request.Request(GATEWAY, data=payload, headers={ - 'Content-Type': 'application/json', 'Authorization': 'Bearer hermes123', - 'X-Hermes-Session-Id': 'self-repair'}) - resp = urllib.request.urlopen(req, timeout=120) - text = json.loads(resp.read())['choices'][0]['message']['content'] + # llm_client:OCG 直连,无 agent 无常驻 session(原 gateway 'self-repair' + # session 指令冻结+上下文无限累积,2026-07-21 废弃) + sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + from llm_client import call_llm + res = call_llm(prompt, max_tokens=300, timeout=120, retries=1, backoff=10) + if not res["ok"]: + raise RuntimeError(res["error"][:120]) + text = res["content"] # 提取 JSON import re m = re.search(r'\{[^{}]*"action"[^{}]*\}', text)