cache clearing, code exec heading trim

frdel committed Mar 19, 2026 at 20:50 UTC a82312f524fd61f432ca7b92a71853b181f49845
5 files changed +36 -12
helpers/api.py
+5 -3
@@ -288,14 +288,16 @@ def register_api_route(app: Flask, lock: ThreadLockType) -> None:
288 def register_watchdogs():
289 from helpers import watchdog
290
291 - def on_api_change(items:list[watchdog.WatchItem]):
291 + def on_api_change(items: list[watchdog.WatchItem]):
292 PrintStyle.debug("API endpoint watchdog triggered:", items)
293 cache.clear(CACHE_AREA)
294 -
294
295 watchdog.add_watchdog(
296 "api_handlers",
298 - roots=[files.get_abs_path("api")],
297 + roots=[
298 + files.get_abs_path(files.API_DIR),
299 + files.get_abs_path(files.USER_DIR, files.API_DIR),
300 + ],
301 patterns=["*.py"],
302 handler=on_api_change,
303 )
helpers/extension.py
+27 -6
@@ -29,6 +29,7 @@ class _Unset:
29 _UNSET = _Unset()
30 _EXTENSIONS_LOG_COUNTS: dict[str, int] = {}
31
32 +
33 # debug - extensions call counter
34 def _log_extension_call(name: str):
35 try:
@@ -298,20 +299,40 @@ def _get_extensions(folder: str):
299 cache.add(_EXTENSIONS_CACHE_AREA, folder, classes)
300 return classes
301
302 +
303 def register_extensions_watchdogs():
302 - from helpers import watchdog
304 + from helpers import watchdog, projects
305
306 def extensions_changed(items: list[watchdog.WatchItem]):
307 cache.clear(_EXTENSIONS_CACHE_AREA)
308 cache.clear(_CLASSES_CACHE_AREA)
309 PrintStyle.debug("Extensions watchdog triggered:", items)
310
311 + # extensions and usr/extensions
312 watchdog.add_watchdog(
310 - id="extensions",
313 + id="extensions_base",
314 roots=[
315 files.get_abs_path(files.EXTENSIONS_DIR),
313 - files.get_abs_path(files.USER_DIR, files.EXTENSIONS_DIR)
314 - ],
315 - handler=extensions_changed
316 + files.get_abs_path(files.USER_DIR, files.EXTENSIONS_DIR),
317 + ],
318 + handler=extensions_changed,
319 + )
320 +
321 + # usr/projects/**/extensions
322 + watchdog.add_watchdog(
323 + id="extensions_projects",
324 + roots=[projects.PROJECTS_PARENT_DIR],
325 + patterns=[f"*/{projects.PROJECT_META_DIR}/**/{files.EXTENSIONS_DIR}/**/*"],
326 + handler=extensions_changed,
327 )
317 - # TODO - watch extensions under projects/agents
\ No newline at end of file
328 +
329 + # agents and usr/agents
330 + watchdog.add_watchdog(
331 + id="extensions_agents",
332 + roots=[
333 + files.get_abs_path(files.AGENTS_DIR),
334 + files.get_abs_path(files.USER_DIR, files.AGENTS_DIR),
335 + ],
336 + patterns=[f"*/{files.EXTENSIONS_DIR}/**/*"],
337 + handler=extensions_changed,
338 + )
\ No newline at end of file
helpers/files.py
+1
@@ -19,6 +19,7 @@ PROJECTS_DIR = "projects"
19 EXTENSIONS_DIR = "extensions"
20 USER_DIR = "usr"
21 TEMP_DIR = "tmp"
22 +API_DIR = "api"
23 _base_dir = os.path.dirname(os.path.abspath(os.path.join(__file__, "../")))
24
25 class VariablesPlugin(ABC):
helpers/plugins.py
+1 -1
@@ -621,7 +621,7 @@ def save_plugin_config(
621 # or do standard load
622 if new_settings is not None and file_path:
623 files.write_file(file_path, json.dumps(new_settings))
624 - after_plugin_change([plugin_name])
624 + # after_plugin_change([plugin_name]) # don't trigger when only config changes
625
626
627 def find_plugin_asset(
plugins/_code_execution/tools/code_execution_tool.py
+2 -2
@@ -83,7 +83,7 @@ class CodeExecution(Tool):
83 text = f"{self.name} - {self.args['runtime'] if 'runtime' in self.args else 'unknown'}"
84 session = self.args.get("session", None)
85 session_text = f"[{session}] " if session or session == 0 else ""
86 - return f"icon://terminal {session_text}{text}"
86 + return f"icon://terminal {session_text}{truncate_text_string(text, 200)}"
87
88 async def after_execution(self, response, **kwargs):
89 self.agent.hist_add_tool_result(self.name, response.message, **(response.additional or {}))
@@ -266,7 +266,7 @@ class CodeExecution(Tool):
266 last_lines.reverse()
267 for idx, line in enumerate(last_lines):
268 line = line.strip()
269 - line = line if len(line) <= 500 else line[:250] + line[-250:]
269 + line = line if len(line) <= 500 else line[:250] + line[-250:] # only check start and end on long lines
270 for pat in prompt_patterns:
271 if pat.search(line):
272 PrintStyle.info(