Team_Daemons / tasks /base_task.py
Rudransh-1508
fix: enforce strict (0,1) task scores and stronger fallback policy
1cad6c8
Raw
History Blame Contribute Delete
934 Bytes
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import List
class BaseTask(ABC):
task_id: str
difficulty: str
config_path: str
step_limit: int
_MIN_SCORE: float = 0.001
_MAX_SCORE: float = 0.999
@abstractmethod
def get_system_prompt(self) -> str:
raise NotImplementedError
@abstractmethod
def grade(
self,
declared_service: str | None,
declared_fault: str | None,
steps_used: int,
rewards: List[float],
) -> float:
raise NotImplementedError
@staticmethod
def _score_correct(correct: bool, steps_used: int, step_limit: int) -> float:
if not correct:
return BaseTask._MIN_SCORE
efficiency = max(0.0, (step_limit - steps_used) / step_limit)
score = 0.5 + 0.5 * efficiency
return float(min(BaseTask._MAX_SCORE, max(BaseTask._MIN_SCORE, score)))