Spaces:
Sleeping
Sleeping
Commit Β·
e014c8f
1
Parent(s): 77db99b
Refactor max_steps calculation and disable centralized step reward logic for microservice incidents
Browse files- benchmark_runner.py +3 -1
- environment.py +7 -42
benchmark_runner.py
CHANGED
|
@@ -327,7 +327,9 @@ def run_episode(
|
|
| 327 |
{"role": "user", "content": f"ALERT: {alert}\n\n{message}"},
|
| 328 |
]
|
| 329 |
|
| 330 |
-
|
|
|
|
|
|
|
| 331 |
|
| 332 |
for step in range(1, max_steps + 1):
|
| 333 |
action, raw_response = get_llm_action(
|
|
|
|
| 327 |
{"role": "user", "content": f"ALERT: {alert}\n\n{message}"},
|
| 328 |
]
|
| 329 |
|
| 330 |
+
# Get task metadata to find correct max_steps (varies by task difficulty)
|
| 331 |
+
task_meta = TASKS.get(task_id, {})
|
| 332 |
+
max_steps = task_meta.get("max_steps", 15)
|
| 333 |
|
| 334 |
for step in range(1, max_steps + 1):
|
| 335 |
action, raw_response = get_llm_action(
|
environment.py
CHANGED
|
@@ -865,48 +865,13 @@ class IncidentResponseEnv:
|
|
| 865 |
)
|
| 866 |
message = f"INCORRECT. The fault was in {', '.join(fault_services)}, not {action.target}.\n[END]"
|
| 867 |
|
| 868 |
-
# --- Centralized step reward (Phase 4):
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
"check_health": "check_runner_status",
|
| 876 |
-
"run_db_query": "read_consumer_logs",
|
| 877 |
-
"restart_service": "restart_consumer_group",
|
| 878 |
-
"rollback_deployment": "rollback_workflow",
|
| 879 |
-
"declare_rca": "declare_rca",
|
| 880 |
-
}
|
| 881 |
-
reward_action = action_map_reward.get(action.action_type, action.action_type)
|
| 882 |
-
try:
|
| 883 |
-
# normalize history entries to reward-action names for redundancy detection
|
| 884 |
-
actions_conv = [action_map_reward.get(k.split(':', 1)[0], k.split(':', 1)[0]) for k in self._actions_taken]
|
| 885 |
-
computed = compute_step_reward(reward_action, task, self._step_count, actions_conv, self._evidence, observation=message)
|
| 886 |
-
if isinstance(computed, float):
|
| 887 |
-
reward_value = round(computed, 4)
|
| 888 |
-
reward_reason = f"reward.py computed ({reward_action})"
|
| 889 |
-
except Exception:
|
| 890 |
-
# if reward lib fails, leave inline reward_value as fallback
|
| 891 |
-
pass
|
| 892 |
-
|
| 893 |
-
# Mirror evidence flags from EvidenceTracker into the env's evidence set
|
| 894 |
-
try:
|
| 895 |
-
ev = self._evidence
|
| 896 |
-
if ev is not None:
|
| 897 |
-
if ev.logs_read:
|
| 898 |
-
if action.action_type == "read_logs" and action.target == fault_svc:
|
| 899 |
-
self._relevant_evidence_found.add("logs_fault_svc")
|
| 900 |
-
elif action.action_type == "read_logs" and action.target == "api-gateway":
|
| 901 |
-
self._relevant_evidence_found.add("logs_gateway")
|
| 902 |
-
if ev.per_partition_lag_checked or ev.partition_inspected or ev.broker_logs_read:
|
| 903 |
-
self._relevant_evidence_found.add("metrics_fault_svc")
|
| 904 |
-
if ev.runner_status_checked or ev.action_integrity_checked or ev.audit_log_read:
|
| 905 |
-
self._relevant_evidence_found.add("health_fault_svc")
|
| 906 |
-
except Exception:
|
| 907 |
-
pass
|
| 908 |
-
except Exception:
|
| 909 |
-
pass
|
| 910 |
|
| 911 |
# ββ cascade mechanic ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 912 |
cascade_step = task.get("cascade_step")
|
|
|
|
| 865 |
)
|
| 866 |
message = f"INCORRECT. The fault was in {', '.join(fault_services)}, not {action.target}.\n[END]"
|
| 867 |
|
| 868 |
+
# --- Centralized step reward (Phase 4): DISABLED
|
| 869 |
+
# Reason: reward.py is designed for CI/CD and Kafka domains,
|
| 870 |
+
# but this environment uses microservice incident faults (cpu_spike, disk_full, etc.)
|
| 871 |
+
# that don't match CI/CD fault types. The centralized rewards were returning 0.0,
|
| 872 |
+
# silently overwriting the carefully-tuned inline rewards above.
|
| 873 |
+
# Phase 4 integration is postponed until reward.py has microservice reward functions.
|
| 874 |
+
# For now, we rely on the domain-correct inline reward logic above.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 875 |
|
| 876 |
# ββ cascade mechanic ββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 877 |
cascade_step = task.get("cascade_step")
|