junaid0600 commited on
Commit
ef20791
Β·
1 Parent(s): f2d88cb

Clamp all reward scores strictly between 0.001 and 0.999

Browse files
Files changed (2) hide show
  1. env/models.py +1 -1
  2. env/reward.py +5 -5
env/models.py CHANGED
@@ -97,7 +97,7 @@ class Reward(BaseModel):
97
  @field_validator("score")
98
  @classmethod
99
  def clamp_score(cls, v):
100
- return max(-1.0, min(1.0, round(v, 4)))
101
 
102
  model_config = {"json_schema_extra": {
103
  "example": {
 
97
  @field_validator("score")
98
  @classmethod
99
  def clamp_score(cls, v):
100
+ return max(0.001, min(0.999, round(v, 4)))
101
 
102
  model_config = {"json_schema_extra": {
103
  "example": {
env/reward.py CHANGED
@@ -96,11 +96,10 @@ def compute_reward(
96
  # ── Edge case: null action ────────────────────────────────────
97
  if action is None or action.payload is None:
98
  return Reward(
99
- score=-0.1,
100
- breakdown={"invalid_action": -0.1},
101
- feedback="Invalid or null action received. Penalty applied."
102
  )
103
-
104
  action_type_val = action.action_type.value if hasattr(action.action_type, "value") else str(action.action_type)
105
  action_type_enum = action.action_type
106
 
@@ -170,7 +169,8 @@ def compute_reward(
170
  feedback_parts.append("Approaching max steps limit. Penalty applied.")
171
 
172
  # ── Clamp to [-1.0, 1.0] ─────────────────────────────────────
173
- final_score = round(max(-1.0, min(1.0, final_score)), 4)
 
174
  breakdown["total"] = final_score
175
 
176
  feedback = " ".join(feedback_parts) if feedback_parts else "Step processed."
 
96
  # ── Edge case: null action ────────────────────────────────────
97
  if action is None or action.payload is None:
98
  return Reward(
99
+ score=0.001,
100
+ breakdown={"invalid_action": 0.001},
101
+ feedback="Invalid or null action received."
102
  )
 
103
  action_type_val = action.action_type.value if hasattr(action.action_type, "value") else str(action.action_type)
104
  action_type_enum = action.action_type
105
 
 
169
  feedback_parts.append("Approaching max steps limit. Penalty applied.")
170
 
171
  # ── Clamp to [-1.0, 1.0] ─────────────────────────────────────
172
+ # Clamp strictly between 0.001 and 0.999 for validator compliance
173
+ final_score = round(max(0.001, min(0.999, final_score)), 4)
174
  breakdown["total"] = final_score
175
 
176
  feedback = " ".join(feedback_parts) if feedback_parts else "Step processed."