Skip to content

Inference parser: Select the OnResponse reader from the response, not the request's stream flag #1706

Closed

Description

@huang195

Problem

InferenceParser.OnResponse uses the request's stream flag to select the response reader. The terminal-frame arm of OnResponseFrame uses the response: settle.IsEventStream(pctx) || inference.CarriesSSEFraming(body). The two arms disagree when a gateway sends JSON to a streaming request, or SSE to a non-streaming request. In that case, OnResponse uses the wrong reader. It loses the completion and the usage, and only a gateway cost header can price the response.

Impact today

None on a live path. Pipeline.RunResponse skips a plugin that implements StreamingResponder, so no listener calls this OnResponse. Only a direct caller (a test, or a future caller) reaches it.

Fix decision

In OnResponse, select the reader with the same rule as the terminal-frame arm of OnResponseFrame. Add a test for each of the two mismatched cases.

The base code had the same behaviour. CodeRabbit found it on #1703. That PR is a pure move, so the fix is not in it.

Assisted-By: Claude (Anthropic AI) [email protected]

Activity

  1. self-assigned this
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 8, 2026
    ca8d8fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions