fix(opencode): retry raw network finish errors (#43813)

Co-authored-by: Aiden <rekram1-node@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2026-08-21 02:17:35 -05:00
committed by GitHub
parent 1e4c153aed
commit e0b9e68a68
3 changed files with 125 additions and 0 deletions
@@ -651,6 +651,63 @@ it.live("session.processor effect tests retry OpenAI-compatible midstream server
),
)
it.live("session.processor effect tests retry network_error finish reasons", () =>
provideTmpdirServer(
({ dir, llm }) =>
Effect.gen(function* () {
const { processors, session, provider } = yield* boot()
yield* llm.push(
raw({
chunks: [
{
id: "chatcmpl-network-error",
object: "chat.completion.chunk",
choices: [{ index: 0, delta: { role: "assistant", content: "" }, finish_reason: "network_error" }],
},
],
}),
)
yield* llm.text("after retry")
const chat = yield* session.create({})
const parent = yield* user(chat.id, "retry network 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 network 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 retry")).toBe(true)
expect(handle.message.error).toBeUndefined()
}),
{ config: (url) => providerCfg(url) },
),
)
it.live("session.processor effect tests publish retry status updates", () =>
provideTmpdirServer(
({ dir, llm }) =>