sandbox: self-healing tunnel (tunnel_loop), forced tool description, fallback to tool output; e2e via live bot returns 2**64
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
# patch_sbx_v5.py — жёсткое описание run_code: обязaтельный вызов для кода/вычислений.
|
||||
import time, shutil
|
||||
|
||||
SRC = "/opt/grok-bot/iishko/legacy.py"
|
||||
OLD = '"description": "Execute Python code in an isolated sandbox (Python 3.11, no network access, no secrets, fresh disposable VM). Use it for exact math, data processing, parsing, algorithms, computed results. Input: a full runnable python script. Returns stdout/stderr and exit code.",'
|
||||
NEW = '"description": "Execute Python code in an isolated sandbox (Python 3.11, no network, no secrets, fresh disposable VM). ALWAYS call this tool whenever the user asks to run, execute, count, compute or calculate something in code, or when exact numeric results are needed. Never answer such requests from memory and never pretend the code ran - call the tool and quote its real stdout. Input: a full runnable python script. Returns stdout/stderr and exit code.",'
|
||||
|
||||
src = open(SRC, encoding="utf-8").read()
|
||||
if "ALWAYS call this tool whenever" in src:
|
||||
print("ALREADY PATCHED v5")
|
||||
else:
|
||||
assert src.count(OLD) == 1, "anchor count=%d" % src.count(OLD)
|
||||
bak = SRC + ".bak-sbx5-" + time.strftime("%Y%m%dT%H%M%S")
|
||||
shutil.copy2(SRC, bak)
|
||||
open(SRC, "w", encoding="utf-8").write(src.replace(OLD, NEW))
|
||||
print("PATCHED OK, backup:", bak)
|
||||
|
||||
import py_compile
|
||||
py_compile.compile(SRC, doraise=True)
|
||||
print("compile OK")
|
||||
Reference in New Issue
Block a user