|
|
@@ -604,6 +604,55 @@ it.live("session.processor effect tests retry recognized structured json errors"
|
|
|
),
|
|
|
)
|
|
|
|
|
|
+it.live("session.processor effect tests retry OpenAI-compatible midstream server errors", () =>
|
|
|
+ provideTmpdirServer(
|
|
|
+ ({ dir, llm }) =>
|
|
|
+ Effect.gen(function* () {
|
|
|
+ const { processors, session, provider } = yield* boot()
|
|
|
+
|
|
|
+ yield* llm.push(
|
|
|
+ raw({ chunks: [{ error: { type: "server_error", code: "server_error", message: "xxx" } }] }),
|
|
|
+ )
|
|
|
+ yield* llm.text("after")
|
|
|
+
|
|
|
+ const chat = yield* session.create({})
|
|
|
+ const parent = yield* user(chat.id, "retry midstream server error")
|
|
|
+ const msg = yield* assistant(chat.id, parent.id, path.resolve(dir))
|
|
|
+ const mdl = yield* provider.getModel(ref.providerID, ref.modelID)
|
|
|
+ const handle = yield* processors.create({
|
|
|
+ assistantMessage: msg,
|
|
|
+ sessionID: chat.id,
|
|
|
+ model: mdl,
|
|
|
+ })
|
|
|
+
|
|
|
+ const value = yield* handle.process({
|
|
|
+ user: {
|
|
|
+ id: parent.id,
|
|
|
+ sessionID: chat.id,
|
|
|
+ role: "user",
|
|
|
+ time: parent.time,
|
|
|
+ agent: parent.agent,
|
|
|
+ model: { providerID: ref.providerID, modelID: ref.modelID },
|
|
|
+ } satisfies SessionV1.User,
|
|
|
+ sessionID: chat.id,
|
|
|
+ model: mdl,
|
|
|
+ agent: agent(),
|
|
|
+ system: [],
|
|
|
+ messages: [{ role: "user", content: "retry midstream server error" }],
|
|
|
+ tools: {},
|
|
|
+ })
|
|
|
+
|
|
|
+ const parts = yield* MessageV2.parts(msg.id)
|
|
|
+
|
|
|
+ expect(value).toBe("continue")
|
|
|
+ expect(yield* llm.calls).toBe(2)
|
|
|
+ expect(parts.some((part) => part.type === "text" && part.text === "after")).toBe(true)
|
|
|
+ expect(handle.message.error).toBeUndefined()
|
|
|
+ }),
|
|
|
+ { config: (url) => providerCfg(url) },
|
|
|
+ ),
|
|
|
+)
|
|
|
+
|
|
|
it.live("session.processor effect tests publish retry status updates", () =>
|
|
|
provideTmpdirServer(
|
|
|
({ dir, llm }) =>
|