fix(rl): enhance intervention handling in actor and learner

(cherry picked from commit ef8bfffbd7)
This commit is contained in:
Khalil Meftah
2026-04-26 23:09:33 +02:00
parent f3993cbbb1
commit b3164543f4
2 changed files with 6 additions and 3 deletions
+5 -2
View File
@@ -337,7 +337,7 @@ def act_with_policy(
# Check for intervention from transition info
intervention_info = new_transition[TransitionKey.INFO]
is_intervention = intervention_info.get(TeleopEvents.IS_INTERVENTION, False)
is_intervention = bool(intervention_info.get(TeleopEvents.IS_INTERVENTION, False))
if is_intervention:
episode_intervention = True
episode_intervention_steps += 1
@@ -346,7 +346,10 @@ def act_with_policy(
"discrete_penalty": torch.tensor(
[new_transition[TransitionKey.COMPLEMENTARY_DATA].get("discrete_penalty", 0.0)]
),
"is_intervention": is_intervention,
# Forward the intervention flag so the learner can route this transition
# into the offline replay buffer (see `process_transitions` in learner.py).
# Use the plain string key so the payload survives torch.load(weights_only=True).
TeleopEvents.IS_INTERVENTION.value: is_intervention,
}
# Create transition for learner (convert to old format)
list_transition_to_send_to_learner.append(
+1 -1
View File
@@ -937,7 +937,7 @@ def process_transitions(
# Add to offline buffer if it's an intervention
if dataset_repo_id is not None and transition.get("complementary_info", {}).get(
TeleopEvents.IS_INTERVENTION
TeleopEvents.IS_INTERVENTION.value
):
offline_replay_buffer.add(**transition)