fix(agents): a startedAt too large for a float counts as live (Issue #31, review)
json.load reads a huge integer as an int, and math.isfinite raised
OverflowError on it outside any try: conversation_in_use and purge_artifacts
(which must never raise) threw, where 6f4f40a had taken it as live. The
conversion to float now comes first, and an overflow means live.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e156179822
commit
60779ba1f8
2 files changed
+15
-7
No files matched your search
@@ -78,12 +78,17 @@ def _session_file_live(data: dict, pid) -> bool:
|
||||
except OSError:
|
||||
pass
|
||||
# startedAt is epoch ms: a finite positive number. A bool, a string, NaN
|
||||
# (every comparison with it is false) or an infinity is no time at all.
|
||||
# (every comparison with it is false), an infinity or an int too large
|
||||
# for a float is no time at all.
|
||||
started = data.get("startedAt")
|
||||
if isinstance(started, bool) or not isinstance(started, (int, float)) \
|
||||
or not math.isfinite(started) or started <= 0:
|
||||
if isinstance(started, bool) or not isinstance(started, (int, float)):
|
||||
return True
|
||||
try:
|
||||
started = float(started) / 1000.0
|
||||
except OverflowError:
|
||||
return True
|
||||
if not math.isfinite(started) or started <= 0:
|
||||
return True
|
||||
started = started / 1000.0
|
||||
# lstart in UTC: a local time is ambiguous in the hour a DST change repeats.
|
||||
try:
|
||||
out = subprocess.run(["ps", "-p", str(pid), "-o", "lstart="], capture_output=True, text=True,
|
||||
|
||||
Reference in new issue
Block a user