fix(L3): self_repair 迁移 llm_client(OCG直连无session) 废弃常驻'self-repair' session(指令冻结+上下文累积)

This commit is contained in:
hmo
2026-07-21 01:39:54 +08:00
parent 95d07f6a11
commit ae0c7d1ca3
+8 -11
View File
@@ -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_clientOCG 直连,无 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)