Skip to content

Commit 79f21ba

Browse files
committed
fix(core): let HTTP hooks coexist with session WebSockets
A registered http.request or http.response hook no longer forces the request onto HTTP. WebSocket requests skip the hooks; the HTTP fallback the channel keeps still runs them.
1 parent c832dc5 commit 79f21ba

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎packages/core/src/session/model-request.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,8 @@ export const layer = Layer.effect(
309309
return HttpClientResponse.fromWeb(sent, after.response)
310310
}).pipe(Effect.mapError((cause) => (cause instanceof Error ? cause : new Error(String(cause)))))
311311
: undefined
312-
// HTTP hooks must observe every request, so they keep the provider on HTTP.
313312
const webSocket =
314-
input.webSocket === "session" &&
315-
!hasHttpHooks &&
316-
model.capabilities.responsesWebsockets === true &&
317-
model.websocket
313+
input.webSocket === "session" && model.capabilities.responsesWebsockets === true && model.websocket
318314

319315
return {
320316
event: shaped,

‎packages/core/test/plugin/provider-openai.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,13 @@ describe("OpenAIPlugin", () => {
273273
expect(prepared.options.webSocket).toBe(executor)
274274
expect(prepared.options.http).toBeUndefined()
275275
expect(disabled.options.webSocket).toBeUndefined()
276+
277+
// HTTP hooks ride along for the HTTP fallback; they do not force the request onto HTTP.
278+
const hooks = yield* PluginHooks.Service
279+
yield* hooks.register("session", "http.request", () => Effect.void)
280+
const hooked = yield* prepare()
281+
expect(hooked.options.webSocket).toBe(executor)
282+
expect(hooked.options.http).toBeDefined()
276283
}),
277284
)
278285
})

0 commit comments

Comments
 (0)