Skip to content

Commit cb51d27

Browse files
author
Your Name
committed
Only clear invocation cache on success
1 parent b0c4b5b commit cb51d27

6 files changed

Lines changed: 10 additions & 11 deletions

File tree

cecli/tools/command_interactive.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ def _run_interactive():
9393
" large_file_token_threshold)"
9494
)
9595

96+
cls.clear_invocation_cache()
97+
9698
if exit_status == 0:
9799
return (
98100
"Interactive command finished successfully (exit code 0)."

cecli/tools/delete_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def execute(
118118
)
119119

120120
coder.files_edited_by_tools.add(rel_path)
121+
cls.clear_invocation_cache()
122+
121123
# 5. Format and return result
122124
success_message = f"Deleted lines {start_line} to {end_line} in {file_path}"
123125
return format_tool_result(
@@ -130,10 +132,8 @@ def execute(
130132
except ToolError as e:
131133
# Handle errors raised by utility functions (expected errors)
132134
coder.edit_allowed = False
133-
cls.clear_invocation_cache()
134135
return handle_tool_error(coder, tool_name, e, add_traceback=False)
135136
except Exception as e:
136137
# Handle unexpected errors
137138
coder.edit_allowed = False
138-
cls.clear_invocation_cache()
139139
return handle_tool_error(coder, tool_name, e)

cecli/tools/finished.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def execute(cls, coder, **kwargs):
2626
2727
This gives the LLM explicit control over when it can stop looping
2828
"""
29+
cls.clear_invocation_cache()
2930

3031
if coder:
3132
coder.agent_finished = True

cecli/tools/insert_text.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def execute(
123123
)
124124

125125
coder.files_edited_by_tools.add(rel_path)
126+
cls.clear_invocation_cache()
126127

127128
# 5. Format and return result
128129
success_message = f"Inserted content at {start_line} in {file_path}"
@@ -134,14 +135,12 @@ def execute(
134135
)
135136

136137
except ToolError as e:
137-
coder.edit_allowed = False
138-
cls.clear_invocation_cache()
139138
# Handle errors raised by utility functions (expected errors)
139+
coder.edit_allowed = False
140140
return handle_tool_error(coder, tool_name, e, add_traceback=False)
141141

142142
except Exception as e:
143143
coder.edit_allowed = False
144-
cls.clear_invocation_cache()
145144
return handle_tool_error(coder, tool_name, e)
146145

147146
@classmethod

cecli/tools/replace_text.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,8 @@ def execute(
262262
success_message += "\nFailed edits:\n" + "\n".join(all_failed_edits)
263263
change_id_to_return = None # Multiple change IDs, can't return single one
264264

265+
cls.clear_invocation_cache()
266+
265267
return format_tool_result(
266268
coder,
267269
tool_name,
@@ -272,12 +274,10 @@ def execute(
272274
except ToolError as e:
273275
# Handle errors raised by utility functions or explicitly raised here
274276
coder.edit_allowed = False
275-
cls.clear_invocation_cache()
276277
return handle_tool_error(coder, tool_name, e, add_traceback=False)
277278
except Exception as e:
278279
# Handle unexpected errors
279280
coder.edit_allowed = False
280-
cls.clear_invocation_cache()
281281
return handle_tool_error(coder, tool_name, e)
282282

283283
@classmethod

cecli/tools/utils/base_tool.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ def process_response(cls, coder, params):
8888
cls._invocations[tool_name].append((current_params_tuple, params))
8989
if len(cls._invocations[tool_name]) > 3:
9090
cls._invocations[tool_name] = cls._invocations[tool_name][-3:]
91-
else:
92-
# When TRACK_INVOCATIONS is False, clear all invocation history
93-
# This indicates the job is making progress, so reset tracking for all tools
94-
cls.clear_invocation_cache()
91+
9592
try:
9693
return cls.execute(coder, **params)
9794
except Exception as e:

0 commit comments

Comments
 (0)