Skip to content

fix: handle current Perplexity SSE responses - #2

Merged
ardzz merged 1 commit into
masterfrom
fix/mcp-sse-response-timeout
Aug 10, 2026
Merged

fix: handle current Perplexity SSE responses#2
ardzz merged 1 commit into
masterfrom
fix/mcp-sse-response-timeout

Conversation

@ardzz

@ardzz ardzz commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Description

Fix MCP calls that completed upstream but returned an empty answer to OpenCode.

Root cause

Perplexity's current SSE response shape emits the answer in a plain ask_text.markdown_block and may finish without the legacy outer FINAL event. The client only handled legacy FINAL and limited diff-block fallbacks, so valid answers could be discarded as No response received..

What changed

  • recognize current ask_text, ask_text_markdown, and numbered markdown answer blocks
  • treat direct markdown_block.answer as authoritative while preserving legacy diff and FINAL parsing
  • collect and URL-deduplicate current web_results citations, including incremental patches
  • stop on valid terminal signals and always close the stream generator and HTTP response
  • add bounded MCP timeouts with explicit partial/error responses:
    • search: thinking model, mode="search", 45 seconds
    • research: thinking model, mode="copilot", 180 seconds
    • accepted override range: 5–600 seconds
  • remove the ambiguous No response received. fallback
  • add regression coverage for current/legacy schemas, conflicting snapshots, numbered sections, citations, timeout behavior, resource cleanup, and FastMCP schema defaults

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Other (please describe):

Testing

  • I have tested these changes locally
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Validation performed:

  • 572 passed in the non-live test suite
  • Pyright: 0 errors and 0 warnings
  • Ruff fatal/import checks: passed
  • git diff --check: passed
  • OpenCode-style MCP stdio smoke (initialize → tools/list → tools/call): succeeded with a non-empty response in 8.36 seconds
  • independent code review: approved with no remaining Critical, Important, or Minor findings

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

No documentation or dependent-package changes are required. The feature worktree is intentionally preserved for PR feedback. The unrelated local uv.lock modification on master was not staged, committed, or pushed.

@ardzz
ardzz marked this pull request as ready for review August 10, 2026 17:14
Copilot AI lite review requested due to automatic review settings August 10, 2026 17:14
@ardzz
ardzz merged commit c765dca into master Aug 10, 2026
8 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants