Skip to content

fix(bridge): do not surface numbered SSE metadata as assistant text #738

Description

@drewstone

Problem

@tangle-network/agent-runtime@0.128.0 treats valid numbered Server-Sent Events metadata from CLI Bridge as model text.

CLI Bridge emits an id-only comment frame for internal session metadata:

id: 1
: bridge-metadata

A real runAgentTaskStream call through createOpenAICompatibleBackend returned final text beginning with:

id: 1
: bridge-metadata

before the actual model response. The same run emitted three text_delta events although the model produced one response token string.

Root cause

streamResponseEvents drains any first line that does not begin with data: before waiting for the blank-line SSE event boundary. It therefore sends id: 1 through parseStreamChunk; the non-JSON fallback converts protocol metadata into text_delta.

Expected

  • Ignore comment-only and id-only frames as assistant output.
  • Parse id: plus data: as one SSE event.
  • Preserve numbered CLI Bridge replay frames without leaking metadata.
  • Remain correct when CRLF or event lines are split across transport chunks.

Completion criteria

  • Add regressions for id plus comment, id plus JSON data, comment-only heartbeat, split CRLF, and split frame boundaries.
  • Prove final assistant text contains only model content.
  • Either fix the published OpenAI-compatible path or prove the canonical profile execution replacement in refactor(runtime): enforce canonical model execution boundary #736 handles the exact CLI Bridge bytes before releasing it.

Live reproduction

Observed 2026-08-04 with Runtime 0.128.0, CLI Bridge on localhost, Pi 0.83.0, and pi/tangle-router/glm-5.2. The request completed successfully in 15.176 seconds, which rules out an error-body fallback.

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