Skip to content

fix(sse): pass real response payload into plugin onResponse hooks - #8806

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
Prudhvivuda:fix/8711-plugin-onresponse-body
Jul 28, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.49from
Prudhvivuda:fix/8711-plugin-onresponse-body

Conversation

@Prudhvivuda

@Prudhvivuda Prudhvivuda commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • runPluginOnResponseHook always forwarded a hard-coded { status: 200 } stub, so plugins never saw response bodies.
  • Non-streaming success paths now pass { status: 200, data: translatedResponse }.
  • Streaming success paths pass { status: 200, streamed: true } without materializing/double-reading the SSE body.

Closes #8711

Test plan

  • node --import tsx/esm --test tests/unit/chatcore-plugin-onresponse.test.ts tests/unit/8395-plugin-hooks-fire.test.ts
  • node --import tsx/esm --test tests/unit/plugins-hooks.test.ts
  • Enable request-logger with includeBody on a non-streaming chat completion and confirm logged response.data
  • Confirm streaming completions still succeed and plugins observe streamed: true

Plugins always received a hard-coded {status:200} stub, so hooks like
request-logger never saw response bodies. Forward translated JSON for
non-streaming completions and a streamed flag for SSE without reading
the body twice.

Closes cheaper-inference#8711
@diegosouzapw
diegosouzapw merged commit 2538565 into cheaper-inference:release/v3.8.49 Jul 28, 2026
5 checks passed
diegosouzapw added a commit that referenced this pull request Jul 28, 2026
…0 test

file-size: apiKeys.ts 1518 -> 1529 (#8805, treating cx/* and codex/* as
equivalent provider prefixes in API-key model permissions) and chatCore.ts
5006 -> 5020 (#8806, passing the real response payload into plugin onResponse
hooks instead of a hardcoded {status:200}). Both extend existing call sites
rather than adding a branch.

stryker: account-fallback-cf1010-no-retry-8775.test.ts covers
accountFallback.ts but was missing from tap.testFiles, which would redden
Fast Quality Gates on every subsequent PR.
@diegosouzapw diegosouzapw mentioned this pull request Jul 28, 2026
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…eaper-inference#8806)

Plugins always received a hard-coded {status:200} stub, so hooks like
request-logger never saw response bodies. Forward translated JSON for
non-streaming completions and a streamed flag for SSE without reading
the body twice.

Closes cheaper-inference#8711
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
…0 test

file-size: apiKeys.ts 1518 -> 1529 (cheaper-inference#8805, treating cx/* and codex/* as
equivalent provider prefixes in API-key model permissions) and chatCore.ts
5006 -> 5020 (cheaper-inference#8806, passing the real response payload into plugin onResponse
hooks instead of a hardcoded {status:200}). Both extend existing call sites
rather than adding a branch.

stryker: account-fallback-cf1010-no-retry-8775.test.ts covers
accountFallback.ts but was missing from tap.testFiles, which would redden
Fast Quality Gates on every subsequent PR.
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…eaper-inference#8806)

Plugins always received a hard-coded {status:200} stub, so hooks like
request-logger never saw response bodies. Forward translated JSON for
non-streaming completions and a streamed flag for SSE without reading
the body twice.

Closes cheaper-inference#8711
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…0 test

file-size: apiKeys.ts 1518 -> 1529 (cheaper-inference#8805, treating cx/* and codex/* as
equivalent provider prefixes in API-key model permissions) and chatCore.ts
5006 -> 5020 (cheaper-inference#8806, passing the real response payload into plugin onResponse
hooks instead of a hardcoded {status:200}). Both extend existing call sites
rather than adding a branch.

stryker: account-fallback-cf1010-no-retry-8775.test.ts covers
accountFallback.ts but was missing from tap.testFiles, which would redden
Fast Quality Gates on every subsequent PR.
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.

fix(backend): Plugin system never sends response

2 participants