fix: return full Perplexity responses and reliable completion status - #8
Open
MrJ55 wants to merge 2 commits into
Open
fix: return full Perplexity responses and reliable completion status#8MrJ55 wants to merge 2 commits into
MrJ55 wants to merge 2 commits into
Conversation
getAgentStatus truncated long answers to their final fragment and could get stuck reporting WORKING after the answer finished streaming. Fixes: - Join ALL [class*="prose"] blocks with containment dedup instead of taking only the last element - long answers are returned in full, without duplicated nested content. - Raise the response cap from 8000 to 30000 chars. - Completion detection: "Ask a follow-up" + prose wins over the working-text heuristic, so answers whose text contains words like "Working"/"Searching"/"Analyzing" no longer leave comet_poll stuck on WORKING. - Harden getAgentStatus against undefined CDP evaluate results (dead tab, navigate race, closed browser) so callers never crash on status.toUpperCase(). Verified end-to-end against live Perplexity threads (search mode) through the MCP gateway: comet_poll returns the complete, deduplicated answer.
This was referenced Aug 7, 2026
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.
Fix response extraction truncation + stuck WORKING status
Problem
getAgentStatuscollected every[class*="prose"]block but returned only the last one, so long Perplexity answers came back as their final fragment (e.g. only the last bullet of a multi-section answer).comet_pollnever flipped tocompletedonce the answer was done.Changes (
src/comet-ai.tsonly)innerTextincludes descendants) → complete, non-duplicated answers.hasAskFollowUp && hasProseContent && !hasActiveStopButton→completedbefore the working-text branch. ("Ask a follow-up" UI only appears when streaming finished.)Cannot read properties of undefined (reading 'toUpperCase').Verification
comet_pollreturns the full deduplicated answer; status flips tocompletedeven when the answer text contains streaming words.status=completedwith the complete response length.Notes
dist/is gitignored; only the TypeScript source is included.