fix(browser): guard LLM response content against None in snapshot and vision (#3642)

Salvage of PR #3532 (binhnt92). Guards browser_tool.py against None content from reasoning-only models (DeepSeek-R1, QwQ). Follow-up to #3449.

Co-Authored-By: binhnt92 <binhnt92@users.noreply.github.com>
This commit is contained in:
Teknium
2026-03-28 17:25:04 -07:00
committed by GitHub
parent dc74998718
commit 973deb4f76
2 changed files with 112 additions and 3 deletions

View File

@@ -993,7 +993,7 @@ def _extract_relevant_content(
if model:
call_kwargs["model"] = model
response = call_llm(**call_kwargs)
return response.choices[0].message.content
return (response.choices[0].message.content or "").strip() or _truncate_snapshot(snapshot_text)
except Exception:
return _truncate_snapshot(snapshot_text)
@@ -1623,10 +1623,10 @@ def browser_vision(question: str, annotate: bool = False, task_id: Optional[str]
call_kwargs["model"] = vision_model
response = call_llm(**call_kwargs)
analysis = response.choices[0].message.content
analysis = (response.choices[0].message.content or "").strip()
response_data = {
"success": True,
"analysis": analysis,
"analysis": analysis or "Vision analysis returned no content.",
"screenshot_path": str(screenshot_path),
}
# Include annotation data if annotated screenshot was taken