[BUG] StructuredOutputHandler._fix_common_issues raises AttributeError when recovery_strategy is not a string
Version
0.2.91a7 (master @ d198715)
Description
In _fix_common_issues (camel/societies/workforce/structured_output_handler.py), the TaskAnalysisResult branch calls .lower() on recovery_strategy unconditionally:
strategy = fixed_data['recovery_strategy'].lower()Weak models sometimes emit a non-string value for this field (e.g. "recovery_strategy": ["retry"] or 3). When that happens:
schema(**extracted_data)raisesValidationError(expected)._fix_common_issuesthen raisesAttributeError: 'list' object has no attribute 'lower'inside theexcept ValidationErrorhandler.parse_structured_responseonly catchesValidationError, so theAttributeErrorpropagates into the Workforce task-analysis flow and fails the whole run instead of falling back tofallback_values.
An unfixable string value already behaves correctly (left as-is → ValidationError → fallback_values → default instance); only the non-string case crashes.
Reproduction
from camel.societies.workforce.structured_output_handler import StructuredOutputHandler
from camel.societies.workforce.utils import TaskAnalysisResult
StructuredOutputHandler.parse_structured_response(
'{"reasoning": "task failed", "recovery_strategy": ["retry"]}',
TaskAnalysisResult,
fallback_values={"reasoning": "Defaulting to retry", "recovery_strategy": "retry"},
)
# AttributeError: 'list' object has no attribute 'lower'Expected behavior
The best-effort fix path should never raise. Non-string values should be left as-is so validation fails into the caller's fallback_values (failure analysis defaults to RecoveryStrategy.RETRY), matching how unfixable string values already behave.
I have a small fix plus regression tests ready and will open a PR referencing this issue.
Source: camel-ai/camel