fix(browser): guard LLM response content against None in snapshot and vision#3532
Closed
binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(browser): guard LLM response content against None in snapshot and vision#3532binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
binhnt92 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
… vision _extract_relevant_content and browser_vision both access response.choices[0].message.content without a None check. Reasoning-only models (DeepSeek-R1, QwQ via OpenRouter) return content=None, producing null snapshots and null vision analysis. Apply the same (content or "").strip() guard used across the rest of the codebase since NousResearch#3449. For _extract_relevant_content, fall back to the truncated snapshot. For browser_vision, fall back to a descriptive message.
teknium1
added a commit
that referenced
this pull request
Mar 29, 2026
… 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 <[email protected]>
Contributor
|
Merged via PR #3642. Cherry-picked onto current main with authorship preserved. All browser tests passing. Thanks for catching the remaining unguarded sites! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_extract_relevant_contentandbrowser_visioninbrowser_tool.pyboth accessresponse.choices[0].message.contentwithout checking for None. Reasoning-only models (DeepSeek-R1, QwQ via OpenRouter) returncontent=None, which causes_extract_relevant_contentto returnNone(making the snapshot null) andbrowser_visionto return{"success": true, "analysis": null}.These two sites were missed when #3449 applied the
(content or "").strip()guard across the other tool files.Changes Made
tools/browser_tool.py_extract_relevant_content: guard + fall back to truncated snapshottools/browser_tool.pybrowser_vision: guard + fall back to descriptive messageHow to Test
7 tests covering: None content fallback, normal content passthrough, empty string fallback, and source-line verification.
Checklist