Skip to content

The agent that grows with you

fix(image_gen): catch only the JSON error the fallback parse can raise

Mariano Nicolini8d0c59d75c6f
diff --git a/tools/image_generation_tool.py b/tools/image_generation_tool.py
index 5af23ba2118..e59ca9773d7 100644
--- a/tools/image_generation_tool.py
+++ b/tools/image_generation_tool.py
@@ -802,7 +802,7 @@ def _fall_back_to_fal(raw: str, prompt: str, aspect_ratio: str, sources: dict[st
Source images never fall back; FAL would route them to an edit endpoint with different semantics."""
try:
result = json.loads(raw)
- except Exception: # noqa: BLE001
+ except ValueError:
return raw
if not isinstance(result, dict) or result.get("success") or not result.get("fallback_eligible"):
return raw