Skip to content

V2 web search ignores valid SSE data fields without a space #55609

Open

Description

@sdivyanshu90

Description

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.

Plugins

Built-in Exa web search

OpenCode version

V2, current dev (@opencode/core 2.0.29)

Steps to reproduce

From packages/core, run with Bun:

import { Effect, Schema } from "effect"
import { WebSearchMcp } from "@opencode/core/plugin/websearch/mcp"

const output = Schema.Struct({ content: Schema.Array(Schema.Struct({ text: Schema.String })) })
const body = 'event: message\ndata:{"result":{"content":[{"text":"search result"}]}}\n\n'
console.log(await Effect.runPromise(WebSearchMcp.parseResponse(body, output)))

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.

Operating System

Linux

Terminal

Bash

Activity

  1. opencode-agent commented on Oct 15, 2026

    @opencode-agent
    Contributor

    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.ts
    import { Effect, Schema } from "effect"
    import { WebSearchMcp } from "@opencode/core/plugin/websearch/mcp"
    
    const output = Schema.Struct({ content: Schema.Array(Schema.Struct({ text: Schema.String })) })
    const cases: 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] of Object.entries(cases)) {
      const r = await Effect.runPromise(Effect.result(WebSearchMcp.parseResponse(body, output)))
      console.log(name, "=>", JSON.stringify(r._tag === "Success" ? r.success : { failure: String(r.failure).slice(0, 120) }))
    }

    Run it: bun sse-parse.ts

  2. Dante-dan commented on Oct 15, 2026

    @Dante-dan
    Contributor

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions