Skip to content

Anthropic SSE stream parser fails with providers that omit space after data: prefix #7928

@NiltonVolpato

Description

@NiltonVolpato

Summary

Goose's Anthropic SSE stream parser requires data: (with a trailing space) before JSON payloads, but the SSE specification treats the space as optional. Providers that send data:{"type":...} instead of data: {"type":...} are silently ignored, resulting in "Stream yielded no message" and an empty session.

Affected providers

  • Kimi Code (api.kimi.com/coding) — Anthropic-compatible endpoint sends data: without space. This is the provider that exposed the issue.
  • Potentially any third-party Anthropic-compatible provider.

Steps to reproduce

  1. Configure a custom Anthropic-compatible provider pointing to Kimi's API:
    {
      "name": "kimi",
      "engine": "anthropic",
      "base_url": "https://api.kimi.com/coding",
      "models": [{"name": "kimi-for-coding", "context_limit": 262144}],
      "supports_streaming": true,
      "requires_auth": true
    }
  2. Run goose run --text "Hello" --no-session
  3. Goose connects, receives a valid 200 response with SSE events, but displays no output.

Root cause

In crates/goose/src/providers/formats/anthropic.rs line 575:

if line.trim().is_empty() || !line.starts_with("data: ") {
    continue;
}

This skips all lines that start with data: but not data: . The same issue exists in the OpenAI, OpenAI Responses, and Snowflake format parsers.

Expected behavior

Both data: {...} and data:{...} should be parsed, per the SSE spec.

Debug log

WARN: "🔍 Anthropic no final usage to yield"
WARN: "Failed to generate session description: Execution error: Stream yielded no message"

Environment

  • Goose 1.27.2
  • macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions