refactor(ai_client): migrate cleanup + reset_session cache.delete to helper (Phase 11 sites 3+4)

Sites L432 (cleanup) and L450 (reset_session) had:
    try: _gemini_client.caches.delete(name=_gemini_cache.name)
    except Exception: pass

This is bare 'except: pass' = INTERNAL_SILENT_SWALLOW violation (logging is NOT
a drain; 'pass' is the worst form of silent recovery).

Migration: use existing _delete_gemini_cache_result() helper (added Phase 10).
The helper returns Result[None]; on SDK error logs a warning to comms.
The caller ignores the Result (cleanup is best-effort).

Audit: ai_client SS 11 -> 9.
This commit is contained in:
ed
2026-06-20 13:57:27 -04:00
parent 82378339e0
commit fb7014cd63
2 changed files with 36 additions and 10 deletions
+2 -10
View File
@@ -426,11 +426,7 @@ def cleanup() -> None:
"""Performs cleanup operations like deleting server-side Gemini caches."""
global _gemini_client, _gemini_cache, _gemini_cached_file_paths
if _gemini_client and _gemini_cache:
#TODO(Ed): Exception(Review)
try:
_gemini_client.caches.delete(name=_gemini_cache.name)
except Exception:
pass
_delete_gemini_cache_result()
_gemini_cached_file_paths = []
def reset_session() -> None:
@@ -444,11 +440,7 @@ def reset_session() -> None:
global _CACHED_ANTHROPIC_TOOLS, _CACHED_DEEPSEEK_TOOLS
global _gemini_cli_adapter
if _gemini_client and _gemini_cache:
#TODO(Ed): Review(Exception)
try:
_gemini_client.caches.delete(name=_gemini_cache.name)
except Exception:
pass
_delete_gemini_cache_result()
_gemini_client = None
_gemini_chat = None
_gemini_cache = None