Skip to content

fix: accumulate WebSocketResponsesRequest as responses streaming (#3001)#3020

Closed
thiscantbeserious wants to merge 1 commit intomaximhq:mainfrom
thiscantbeserious:fix/3001-accumulator-ws-responses
Closed

fix: accumulate WebSocketResponsesRequest as responses streaming (#3001)#3020
thiscantbeserious wants to merge 1 commit intomaximhq:mainfrom
thiscantbeserious:fix/3001-accumulator-ws-responses

Conversation

@thiscantbeserious
Copy link
Copy Markdown

Summary

Token counts and output data were silently lost for every native-WS Responses request because the accumulator rejected those chunks with an error that callers discarded without logging.

Root cause: ProcessStreamingResponse in framework/streaming/accumulator.go set isResponsesStreaming based only on ResponsesStreamRequest. A WebSocketResponsesRequest chunk fell through to the final error return (request type missing/invalid for accumulator). The same gap existed in plugins/logging/utils.go convertToProcessedStreamResponse, where the request-type switch fell through to the default StreamTypeChat branch for WS requests.

WebSocketResponsesRequest carries an identical BifrostResponsesStreamResponse chunk shape to ResponsesStreamRequest, so the existing processResponsesStreamingResponse path handles it correctly with no further changes needed.

Changes

  • framework/streaming/accumulator.go: add || requestType == schemas.WebSocketResponsesRequest to the isResponsesStreaming guard in ProcessStreamingResponse.
  • plugins/logging/utils.go: extend the ResponsesStreamRequest case in the convertToProcessedStreamResponse switch to also match WebSocketResponsesRequest.
  • framework/streaming/accumulator_test.go: two new regression tests covering the WS path through ProcessStreamingResponse.

Type of change

  • Bug fix

Affected areas

  • Framework (streaming accumulator)
  • Logging plugin (stream-type classification)

How to test

go test ./framework/streaming/... -run TestWebSocket -v
go test ./framework/streaming/... -cover
go build ./framework/...

Both new tests (TestWebSocketResponsesRequestAccumulatedAsResponsesStreaming and TestWebSocketResponsesRequestVsResponsesStreamRequestParity) must pass. The second test exercises the exact pre-fix code path that returned the silent error.

Breaking changes

No.

Related

This fix was discovered while working on PR #2775 (openai-oauth-passthrough). The PR branch contains the original version of this fix, which has been extracted here as a focused upstream contribution.

Closes #3001

…imhq#3001)

ProcessStreamingResponse in framework/streaming/accumulator.go
classified only ResponsesStreamRequest as responses streaming. Any
WebSocketResponsesRequest chunk fell through to the default error
return, silently dropping token usage and output accumulation for every
native-WS Responses request.

The same omission existed in plugins/logging/utils.go
convertToProcessedStreamResponse, where the request-type switch
assigned StreamTypeResponses only for ResponsesStreamRequest, leaving
WebSocketResponsesRequest to fall through to the default StreamTypeChat
branch and produce incorrect stream-type metadata in log entries.

Both locations now treat WebSocketResponsesRequest identically to
ResponsesStreamRequest. WebSocketResponsesRequest carries the same
BifrostResponsesStreamResponse chunk shape, so no downstream handler
changes are required.

Two regression tests are added to framework/streaming/accumulator_test.go:
- TestWebSocketResponsesRequestAccumulatedAsResponsesStreaming verifies
  that a full WS chunk sequence produces a non-nil ProcessedStreamResponse
  with token usage populated.
- TestWebSocketResponsesRequestVsResponsesStreamRequestParity runs both
  request types through ProcessStreamingResponse and asserts neither
  returns an error.

Closes maximhq#3001
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b7a3a5de-6ed9-48f3-a7ed-8ccfca09d795

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

thiscantbeserious added a commit to thiscantbeserious/bifrost that referenced this pull request Apr 24, 2026
The WebSocketResponsesRequest classification in ProcessStreamingResponse
was extracted to maximhq/bifrost PR maximhq#3020 (fixes issue maximhq#3001).

Removing the duplicate from this feature branch to avoid a merge conflict
and keep the feature branch focused on OAuth passthrough concerns.

Extraction commit: 606f47b
@thiscantbeserious
Copy link
Copy Markdown
Author

Superseded by #3018 (merged 2026-04-24), which bundles the fix for this issue and several other native WS reliability bugs. Closing this draft as redundant.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Accumulator drops all WS Responses chunks, token usage and output never captured for native-WS requests

1 participant