From afc6dbc18b76561d39966816f291186977d9a414 Mon Sep 17 00:00:00 2001 From: Roman | RyzenAdvanced Date: Wed, 27 May 2026 18:29:54 +0400 Subject: [PATCH] =?UTF-8?q?v10.13.8:=20remove=20broken=20read-vs-write=20t?= =?UTF-8?q?racker=20=E2=80=94=20budget=20cap=20is=20sufficient=20safety=20?= =?UTF-8?q?net?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translate-proxy.py | 53 ---------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/translate-proxy.py b/translate-proxy.py index f1436de..8b81dd9 100755 --- a/translate-proxy.py +++ b/translate-proxy.py @@ -5962,8 +5962,6 @@ class Handler(http.server.BaseHTTPRequestHandler): _mp = _model_profile(model) _mp_max_calls = _mp["max_tool_calls"] _mp_warn_calls = _mp["warn_tool_calls"] - _mp_max_reads = _mp["max_reads_no_write"] - _mp_warn_reads = _mp["warn_reads_no_write"] if cumulative_calls > _mp_max_calls: print(f"[{getattr(self, '_session_id', '?')}] [antigravity-budget] HARD CAP: {cumulative_calls}/{_mp_max_calls} calls (model={model}), injecting force-write directive", file=sys.stderr) @@ -5979,32 +5977,6 @@ class Handler(http.server.BaseHTTPRequestHandler): f"{_mp_max_calls - cumulative_calls} remaining before forced stop. " f"STOP READING FILES AND APPLY YOUR EDITS NOW."}]}) - # CHANGE 2: Read-vs-write loop detection (snapshot, no accumulation) - _READ_CMDS = ("cat ", "head ", "tail ", "less ", "more ", "grep ", "find ", "ls ", "sed -n", "wc ", "file ", "stat ", "du ", "pwd", "which ", "type ", "python3 -c \"\nwith open(", "python3 -c \"\nimport re; open(", ".read(", "read_file", "view_file", "search_file", "list_dir") - _WRITE_CMDS = ("write(", ".write", " > ", " >> ", "sed -i", "patch ", "mv ", "cp ", "install ", "mkdir ", "rm ", "chmod ", "chown ", "truncate", "insert_text", "replace_text", "write_file", "create_file") - n_reads = 0 - n_writes = 0 - for item in input_data: - if isinstance(item, dict) and item.get("type") == "function_call": - args_str = item.get("arguments", "{}") - if not isinstance(args_str, str): - args_str = json.dumps(args_str) - args_lower = args_str.lower() - is_read = any(k in args_lower for k in _READ_CMDS) - is_write = any(k in args_lower for k in _WRITE_CMDS) - if is_write: - n_writes += 1 - elif is_read: - n_reads += 1 - if n_reads >= _mp_max_reads and n_writes == 0: - ag_state["force_finalize"] = True - print(f"[antigravity-loop] READ-WRITE IMBALANCE: {n_reads} reads, {n_writes} writes in context (model={model}, limit={_mp_max_reads})", file=sys.stderr) - elif n_reads >= _mp_warn_reads and n_writes == 0 and not ag_state.get("force_finalize"): - contents.append({"role": "user", "parts": [{"text": - f"WARNING: You have made {n_reads} tool calls and ZERO writes. " - f"You MUST apply your edit NOW using exec_command with a python write. " - f"Do NOT read any more files. WRITE YOUR CHANGES IMMEDIATELY."}]}) - null_tool_names = {"get_goal", "get_remaining_tokens", "get_completion_budget", "status"} consecutive_null = 0 for item in reversed(input_data): @@ -6808,8 +6780,6 @@ class Handler(http.server.BaseHTTPRequestHandler): _mp_oa = _model_profile(model) _mp_max = _mp_oa["max_tool_calls"] _mp_warn = _mp_oa["warn_tool_calls"] - _mp_maxr = _mp_oa["max_reads_no_write"] - _mp_warnr = _mp_oa["warn_reads_no_write"] if cumulative_calls > _mp_max: print(f"[antigravity-budget] HARD CAP: {cumulative_calls}/{_mp_max} calls (model={model}), injecting force-write", file=sys.stderr) @@ -6823,29 +6793,6 @@ class Handler(http.server.BaseHTTPRequestHandler): f"{_mp_max - cumulative_calls} remaining. " f"STOP READING AND WRITE NOW."}]}) - n_reads_oa = 0 - n_writes_oa = 0 - for item in input_data: - if isinstance(item, dict) and item.get("type") == "function_call": - args_str = item.get("arguments", "{}") - if not isinstance(args_str, str): - args_str = json.dumps(args_str) - args_lower = args_str.lower() - is_read = any(k in args_lower for k in _READ_CMDS) - is_write = any(k in args_lower for k in _WRITE_CMDS) - if is_write: - n_writes_oa += 1 - elif is_read: - n_reads_oa += 1 - if n_reads_oa >= _mp_maxr and n_writes_oa == 0: - ag_state["force_finalize"] = True - print(f"[antigravity-loop] READ-WRITE IMBALANCE: {n_reads_oa} reads, {n_writes_oa} writes in context (model={model}, limit={_mp_maxr})", file=sys.stderr) - elif n_reads_oa >= _mp_warnr and n_writes_oa == 0 and not ag_state.get("force_finalize"): - contents.append({"role": "user", "parts": [{"text": - f"WARNING: You have made {n_reads_oa} tool calls and ZERO writes. " - f"You MUST apply your edit NOW using exec_command with a python write. " - f"Do NOT read any more files. WRITE YOUR CHANGES IMMEDIATELY."}]}) - null_tool_names = {"get_goal", "get_remaining_tokens", "get_completion_budget", "status"} consecutive_null = 0 for item in reversed(input_data):