Skip to content

The agent that grows with you

review-fix(suppress-audit): run_turn_runner/browser_control_artifacts — restore BASE exception semantics

Teknium4749300508d4
diff --git a/gateway/browser_control_artifacts.py b/gateway/browser_control_artifacts.py
index 732eb06c53e..cbd0c3c49d0 100644
--- a/gateway/browser_control_artifacts.py
+++ b/gateway/browser_control_artifacts.py
@@ -127,12 +127,14 @@ class ArtifactStore:
# are unreachable orphans past their TTL by definition — sweep them.
self._sweep_orphan_files()
- def _sweep_orphan_files(self) -> None:
- """Delete on-disk files with no live index entry; only minted-id-shaped and ``*.tmp`` names are touched."""
+ def _sweep_orphan_files(self) -> int:
+ """Delete on-disk files with no live index entry; only minted-id-shaped and ``*.tmp`` names are
+ touched. Returns the number removed."""
+ removed = 0
try:
candidates = list(self._root.iterdir())
except OSError:
- return
+ return 0
with self._lock:
live = set(self._entries)
for path in candidates:
@@ -140,6 +142,8 @@ class ArtifactStore:
if path.is_file() and orphan:
with contextlib.suppress(OSError):
path.unlink(missing_ok=True)
+ removed += 1
+ return removed
@property
def root(self) -> Path:
diff --git a/gateway/run_turn_runner.py b/gateway/run_turn_runner.py
index 6735b495579..587cc527f37 100644
--- a/gateway/run_turn_runner.py
+++ b/gateway/run_turn_runner.py
@@ -876,11 +876,13 @@ class TurnRunner:
ctx = self._ctx
if self._runner._session_db is None or not ctx.session_id:
return None
- row = None
+ count = None
with suppress(Exception):
# run_sync is off-loop (executor); sync DB is fine.
row = self._runner._session_db._db.get_session(ctx.session_id)
- return row.get("message_count", 0) if row else None
+ if row:
+ count = row.get("message_count", 0)
+ return count
def _pop_cached_agent_for_eviction(self):
"""Evict under the lock but DEFER release (release_clients can block on memory-provider /