fix: improve robustness across model providers and search pipeline#1039
Open
VibhorGautam wants to merge 2 commits intoItzCrazyKns:masterfrom
Open
fix: improve robustness across model providers and search pipeline#1039VibhorGautam wants to merge 2 commits intoItzCrazyKns:masterfrom
VibhorGautam wants to merge 2 commits intoItzCrazyKns:masterfrom
Conversation
This addresses several reported issues in one pass: - Remove hardcoded num_ctx (32000) in the Ollama provider. It now uses the contextWindowSize option from GenerateOptions, letting Ollama fall back to whatever the model was loaded with instead of forcing 32K. (fixes ItzCrazyKns#981) - Add null-safety checks on response.message in both OpenAI and Ollama providers. Some endpoints (vLLM, older Ollama builds) can return responses where message or content is missing, causing "Cannot read properties of undefined" crashes. (fixes ItzCrazyKns#836, ItzCrazyKns#789) - Normalize YouTube embed URLs from youtube-nocookie.com to youtube.com in the video search widget. Some SearXNG instances return the privacy-enhanced domain which doesn't resolve on certain networks. (fixes ItzCrazyKns#799) - Handle SearXNG errors gracefully instead of crashing. Added HTTP status check in searchSearxng(), try-catch wrappers in webSearch, academicSearch, socialSearch, and video search actions, and early returns on empty results. The UI no longer hangs indefinitely when SearXNG returns a CAPTCHA or error. (fixes ItzCrazyKns#763) - Add console.error logging for scrape failures, search failures, and SearXNG errors so issues are visible in the terminal. (fixes ItzCrazyKns#997)
Contributor
There was a problem hiding this comment.
4 issues found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/agents/media/video.ts">
<violation number="1" location="src/lib/agents/media/video.ts:62">
P2: Unvalidated upstream result shapes can still cause runtime errors when calling `.replace` on non-string `iframe_src`.</violation>
</file>
<file name="src/lib/searxng.ts">
<violation number="1" location="src/lib/searxng.ts:43">
P2: `res.ok` guard is incomplete: `res.json()` can still throw on 2xx non-JSON/malformed responses, bypassing the intended safe fallback.</violation>
<violation number="2" location="src/lib/searxng.ts:45">
P2: Non-2xx SearXNG responses are swallowed as empty results, masking backend failures and bypassing existing error-handling flows.</violation>
</file>
<file name="src/lib/agents/search/researcher/actions/webSearch.ts">
<violation number="1" location="src/lib/agents/search/researcher/actions/webSearch.ts:121">
P2: Per-query catch swallows search exceptions, causing failed searches to return successful empty/partial results instead of propagating to centralized 500 handling.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Non-2xx responses now throw so the error propagates to callers (which already have try-catch). Also wrapped res.json() in a try-catch to handle cases where a 2xx response has malformed/non-JSON body.
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.
Summary
Addresses 6 open issues with a single set of targeted fixes across the model provider layer and search pipeline. All changes are minimal and focused on preventing crashes and improving error visibility.
Issues fixed
num_ctxhardcoded to 32000, overrides model configcontextWindowSizeoption; Ollama uses its own default when not set?.) on response.message in OpenAI providerChanges by file
contextWindowSizetoGenerateOptionsHow to test
npm install && npm run devnum_ctx: 32000(check Ollama server logs, the model should load with its own default context size)TypeError: Cannot read properties of undefined (reading 'message')during search operations. #836/TypeError: Cannot read properties of undefined (reading 'content') #789: If you have a vLLM or non-standard Ollama endpoint, queries should return a proper error instead of crashingSummary by cubic
Improves robustness across model providers and the search pipeline to prevent crashes and hangs, with clearer error logs. Adds a configurable context window for
ollamaand makes SearXNG error handling strict to avoid silent failures.ollama: replace hardcodednum_ctxwithcontextWindowSize; fall back to the model’s default when unset.ollamaandopenaito handle vLLM/older endpoints.searchSearxng()now throws on non-2xx and non-JSON responses; web/academic/social/video actions catch errors, early-exit on empty results, and log withconsole.errorto avoid UI hangs.youtube-nocookie.comtoyoutube.comso iframes load.Written for commit badde05. Summary will update on new commits.