sandbox: fix supervisor (double probe, real spawn), retry+log in run_code, route tool requests to native :48005 (shim drops streamed tool_calls), e2e proof
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env python3
|
||||
# patch_sbx_v4.py — tool-запросы шлём на нативный new-api :48005
|
||||
# (шим :48000 в стриме вырезает delta.tool_calls: finish=stop вместо tool_calls).
|
||||
import time, shutil
|
||||
|
||||
SRC = "/opt/grok-bot/iishko/legacy.py"
|
||||
|
||||
A1_OLD = '''GW_BASE = CFG.get("newapi_url", "http://127.0.0.1:48000").rstrip("/") + "/v1"
|
||||
GW_KEY = CFG.get("main_key") or ""'''
|
||||
A1_NEW = '''GW_BASE = CFG.get("newapi_url", "http://127.0.0.1:48000").rstrip("/") + "/v1"
|
||||
GW_KEY = CFG.get("main_key") or ""
|
||||
# [SBX-TOOLS 1114] шим :48000 в стриме теряет delta.tool_calls (finish=stop),
|
||||
# нативный new-api :48005 отдаёт tool_calls. Запросы с tools идут напрямую.
|
||||
GW_BASE_TOOLS = (CFG.get("newapi_tools_url") or GW_BASE.replace(":48000", ":48005")).rstrip("/")'''
|
||||
|
||||
A2_OLD = ''' async with s.post(GW_BASE + "/chat/completions", json=payload,'''
|
||||
A2_NEW = ''' async with s.post((GW_BASE_TOOLS if payload.get("tools") else GW_BASE) + "/chat/completions", json=payload,'''
|
||||
|
||||
src = open(SRC, encoding="utf-8").read()
|
||||
if "SBX-TOOLS 1114" in src:
|
||||
print("ALREADY PATCHED v4")
|
||||
else:
|
||||
assert src.count(A1_OLD) == 1, "A1 count=%d" % src.count(A1_OLD)
|
||||
assert src.count(A2_OLD) == 1, "A2 count=%d" % src.count(A2_OLD)
|
||||
bak = SRC + ".bak-sbx4-" + time.strftime("%Y%m%dT%H%M%S")
|
||||
shutil.copy2(SRC, bak)
|
||||
src = src.replace(A1_OLD, A1_NEW).replace(A2_OLD, A2_NEW)
|
||||
open(SRC, "w", encoding="utf-8").write(src)
|
||||
print("PATCHED OK, backup:", bak)
|
||||
|
||||
import py_compile
|
||||
py_compile.compile(SRC, doraise=True)
|
||||
print("compile OK")
|
||||
Reference in New Issue
Block a user