Repository navigation
fix(core): parse web search SSE events - #55611
sdivyanshu90 wants to merge 1 commit into
Conversation
|
Hi @kitlangton, could you please review this PR whenever you have some time. Thanks! |
|
The following comment was made by an LLM, it may be inaccurate: |
There was a problem hiding this comment.
The approach looks right: it reuses Effect's SSE parser, which packages/core/src/aisdk.ts already uses, instead of matching the data: prefix by hand. That covers both cases in #55609: data: with no space, and JSON split across several data: lines. The plain-JSON path is unchanged. I could not run the tests or the #55609 reproduction in time (the dependency install had not finished), so this is a code read only.
Public API is unchanged. WebSearchMcp.parseResponse keeps its signature. Its error type may now include an SSE parser error, but it is only used inside the built-in web search providers.
One case is worth checking (inline): does the parser dispatch the last event when the body ends without a blank line? The old line-by-line loop handled that.
| const parser = makeParser((event) => { | ||
| if (event._tag === "Event") events.push(event.data) | ||
| }) | ||
| const error = parser.feed(body) |
There was a problem hiding this comment.
SSE parsers usually dispatch an event only when they reach the blank line that ends it. If an MCP server's response body ends straight after the last data: line (no trailing \n\n), the event may never be dispatched. events would then be empty and this would return undefined, which is a regression: the old split("\n") loop decoded that line. Could you confirm how makeParser behaves here? If it drops the event, feed a final "\n\n" (or call the parser's finish/reset step, if it has one) after body, and add a test for a body with no trailing newline.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Issue for this PR
Closes #55609
Type of change
What does this PR do?
Use Effect's existing SSE parser for MCP web-search responses. Valid
data:{...}fields now return results, and multiple data fields are joined before JSON decoding. Plain JSON responses keep their existing path.How did you verify your code works?
From
packages/core, using Bun 1.4.3:bun run test test/plugin/websearch-mcp.test.ts test/plugin/websearch.test.ts test/websearch.test.ts test/tool-websearch.test.ts: 63 passed. Five parser cases and the Exa integration regression fail before the fix.bun typecheck: passed.git diff --check: passed.Repository-wide verification is limited by the filtered dependency installation: the shared baseline's
bun run checkpassed lint with existing warnings, then stopped at the GUI package's missing@tsconfig/node22dependency.Screenshots / recordings
Not applicable; no rendered UI changes.
Checklist