From d3e76946b4493c447460e68cac37072bd86a9948 Mon Sep 17 00:00:00 2001 From: Yuxuan Hu Date: Tue, 11 Nov 2025 16:50:52 -0800 Subject: [PATCH] Fix truthiness bug in age_evict function The age_evict function was using truthiness checks (if max_age and ...) which incorrectly evaluates to False when max_age=0 or max_samples=0. This prevents the eviction policy from working correctly when these parameters are set to 0 (which are valid values). Changed to use explicit None checks (if max_age is not None and ...) to properly handle 0 as a valid parameter value. Test Plan: - Verify that age_evict correctly evicts entries when max_age=0 - Verify that age_evict correctly evicts entries when max_samples=0 - Existing tests should continue to pass --- src/forge/actors/replay_buffer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/forge/actors/replay_buffer.py b/src/forge/actors/replay_buffer.py index 37a1558d5..57bbd631d 100644 --- a/src/forge/actors/replay_buffer.py +++ b/src/forge/actors/replay_buffer.py @@ -33,9 +33,9 @@ def age_evict( """Buffer eviction policy, remove old or over-sampled entries""" indices = [] for i, entry in enumerate(buffer): - if max_age and policy_version - entry.data.policy_version > max_age: + if max_age is not None and policy_version - entry.data.policy_version > max_age: continue - if max_samples and entry.sample_count >= max_samples: + if max_samples is not None and entry.sample_count >= max_samples: continue indices.append(i) return indices