diff --git a/openagent_eval/exceptions/diagnosis.py b/openagent_eval/exceptions/diagnosis.py index 7cfb1a0..d217d7a 100644 --- a/openagent_eval/exceptions/diagnosis.py +++ b/openagent_eval/exceptions/diagnosis.py @@ -37,7 +37,11 @@ def __init__( details: Optional dictionary with additional error context. step: The diagnosis step that failed (e.g., "blame_attribution"). """ - super().__init__(message, details) + error_details = details or {} + if step is not None: + error_details["step"] = step + + super().__init__(message, error_details) self.step = step diff --git a/tests/unit/test_exceptions.py b/tests/unit/test_exceptions.py index 9e0c8bc..cb3747e 100644 --- a/tests/unit/test_exceptions.py +++ b/tests/unit/test_exceptions.py @@ -9,6 +9,7 @@ DatasetError, DatasetNotFoundError, DatasetValidationError, + DiagnosisExecutionError, InvalidDatasetError, MetricError, MetricExecutionError, @@ -130,6 +131,17 @@ def test_timeout_error_preserves_zero_timeout(self) -> None: assert error.details["timeout_seconds"] == 0.0 +class TestDiagnosisError: + """Tests for diagnosis errors.""" + + def test_execution_error_includes_step_in_details(self) -> None: + """Test that the failed step is visible in error details.""" + error = DiagnosisExecutionError("Failed", step="blame_attribution") + + assert error.step == "blame_attribution" + assert error.details["step"] == "blame_attribution" + + class TestProviderError: """Tests for provider errors."""