From de02764895c06b0e46ed2dfb8a20b1042f247166 Mon Sep 17 00:00:00 2001 From: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com> Date: Fri, 17 Jul 2026 11:27:59 -0700 Subject: [PATCH] fix(exceptions): include diagnosis step in details Diagnosis execution errors stored the failed step only as an attribute, leaving logs and rendered error details without the relevant context. Add it to the details mapping and cover the behavior with a regression test. --- openagent_eval/exceptions/diagnosis.py | 6 +++++- tests/unit/test_exceptions.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) 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."""