#4318·camel

[BUG] StructuredOutputHandler._fix_common_issues raises AttributeError when recovery_strategy is not a string

Author: Shxiao101Created Sep 6, 2026Updated Sep 6, 2026

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:

python
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:

  1. schema(**extracted_data) raises ValidationError (expected).
  2. _fix_common_issues then raises AttributeError: 'list' object has no attribute 'lower' inside the except ValidationError handler.
  3. parse_structured_response only catches ValidationError, so the AttributeError propagates into the Workforce task-analysis flow and fails the whole run instead of falling back to fallback_values.

An unfixable string value already behaves correctly (left as-is → ValidationErrorfallback_values → default instance); only the non-string case crashes.

Reproduction

python
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.