Fix intermittent empty/truncated Grok search responses#34
Open
dztabel-happy wants to merge 1 commit intoGuDaStudio:mainfrom
Open
Fix intermittent empty/truncated Grok search responses#34dztabel-happy wants to merge 1 commit intoGuDaStudio:mainfrom
dztabel-happy wants to merge 1 commit intoGuDaStudio:mainfrom
Conversation
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
This fixes an intermittent issue where
web_searchcan return an empty or truncatedcontentstring even though the upstream request succeeds andsources_countis non-zero.Reproduction
Using the current
mainimplementation against a real Grok-compatible endpoint, repeated calls toGrokSearchProvider.search(...)intermittently returned incomplete results:"**"or"**Scrape.do** is a"In one 6-run sample before this patch, 2 runs returned an empty string and several others were truncated.
Root Cause
The provider currently depends on streaming chat completions (
stream=True) and concatenates SSE deltas.For this upstream, streaming responses are not consistently delivered as a complete answer, which causes partial or empty content to propagate into
web_search.Fix
stream=False)AcceptandUser-Agentheaders for the upstream API requestdata:linesValidation
uv run --extra dev pytest tests/test_grok_provider.py -qEMPTY_COUNTdropped from2to0web_searchcalls via local stdio server returned non-empty content across repeated runs