From 916b419af3645521716bfe244b360104aba41dfc Mon Sep 17 00:00:00 2001 From: Pepijn Date: Tue, 28 Apr 2026 22:33:54 +0200 Subject: [PATCH] fix(annotate): don't crash pipeline on persistent JSON parse failure Some prompts/models occasionally return pure prose with no JSON object even on retry. Returning None (and logging a preview) lets the pipeline skip that one VLM call cleanly instead of aborting the whole episode. The modules already check for None / non-dict results and degrade gracefully (no row emitted from that call). Co-Authored-By: Claude Opus 4.7 (1M context) --- .../annotations/steerable_pipeline/vlm_client.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lerobot/annotations/steerable_pipeline/vlm_client.py b/src/lerobot/annotations/steerable_pipeline/vlm_client.py index 14955d9f6..a06631c2f 100644 --- a/src/lerobot/annotations/steerable_pipeline/vlm_client.py +++ b/src/lerobot/annotations/steerable_pipeline/vlm_client.py @@ -164,7 +164,17 @@ class _GenericTextClient: }, ] retry_text = self.generate_text([retry], max_tok, temp)[0] - out.append(_strip_to_json(retry_text)) + try: + out.append(_strip_to_json(retry_text)) + except (ValueError, json.JSONDecodeError): + # After retry: log preview and return None instead of crashing + # the whole pipeline. Modules treat None as "skip". + preview = retry_text.strip().replace("\n", " ")[:200] + print( + f"[vlm] WARNING: failed to parse JSON after retry; preview: {preview!r}", + flush=True, + ) + out.append(None) return out