You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V2 web search ignores valid SSE data fields without a space #55609
V2's MCP web-search parser ignores valid SSE data: fields when the optional space after the colon is absent. Exa's provider then returns an empty result list even though the response contains search results. JSON split across multiple data: fields instead fails JSON decoding.
WebSearchMcp.parseResponse() checks for the literal prefix data: and decodes each line independently. The SSE specification permits either spacing and joins consecutive data fields within an event. Reusing the existing Effect SSE parser would handle both cases.
Observed: undefined. Expected: { content: [{ text: "search result" }] }. Adding a space after data: makes the same payload succeed. The built-in Exa provider path also reproduces the empty search results with this framing.
Screenshot and/or share link
Not applicable; deterministic parser and provider reproduction.
Thanks for the clear report. I can confirm this on 2.0.29, and it still happens on the latest dev (37df62f).
The script below calls WebSearchMcp.parseResponse with three response bodies:
data: {...} (with a space) returns the parsed result.
data:{...} (no space) returns undefined, because the parser only accepts lines that start with the exact text data: .
JSON split across two data: lines in one event fails with SchemaError(Expected a valid JSON string), because each line is decoded separately instead of the lines being joined.
As you suggested, the Effect SSE parser from effect/encoding/Sse looks like a good fit. It's already used in packages/core/src/aisdk.ts.
Reproduction script (sse-parse.ts)
// Copy into packages/core of an opencode checkout (so @opencode/core resolves) and run: bun ./sse-parse.tsimport{Effect,Schema}from"effect"import{WebSearchMcp}from"@opencode/core/plugin/websearch/mcp"constoutput=Schema.Struct({content: Schema.Array(Schema.Struct({text: Schema.String}))})constcases: Record<string,string>={"data: (with space)": 'event: message\ndata: {"result":{"content":[{"text":"search result"}]}}\n\n',"data: (no space)": 'event: message\ndata:{"result":{"content":[{"text":"search result"}]}}\n\n',"multi-line data": 'event: message\ndata: {"result":{"content":\ndata: [{"text":"search result"}]}}\n\n',}for(const[name,body]ofObject.entries(cases)){constr=awaitEffect.runPromise(Effect.result(WebSearchMcp.parseResponse(body,output)))console.log(name,"=>",JSON.stringify(r._tag==="Success" ? r.success : {failure: String(r.failure).slice(0,120)}))}
I’ll take this on by reusing the Effect SSE parser already used in aisdk.ts, so each complete event is decoded after its data fields are joined. I’ll check the existing web-search tests for both data: without a space and multiline data, while preserving the JSON response path.
Activity
opencode-agent commentedon Oct 15, 2026
Thanks for the clear report. I can confirm this on 2.0.29, and it still happens on the latest
dev(37df62f).The script below calls
WebSearchMcp.parseResponsewith three response bodies:data: {...}(with a space) returns the parsed result.data:{...}(no space) returnsundefined, because the parser only accepts lines that start with the exact textdata:.data:lines in one event fails withSchemaError(Expected a valid JSON string), because each line is decoded separately instead of the lines being joined.As you suggested, the Effect SSE parser from
effect/encoding/Sselooks like a good fit. It's already used inpackages/core/src/aisdk.ts.Reproduction script (sse-parse.ts)
Run it:
bun sse-parse.tsDante-dan commentedon Oct 15, 2026
I’ll take this on by reusing the Effect SSE parser already used in aisdk.ts, so each complete event is decoded after its data fields are joined. I’ll check the existing web-search tests for both
data:without a space and multiline data, while preserving the JSON response path.