mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-27 00:51:59 +00:00
fix(ai): classify missing chat finish reasons as incomplete (#44864)
This commit is contained in:
parent
d0252f7179
commit
895eff09b0
2 changed files with 11 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import { HttpTransport } from "../route/transport/index.js"
|
|||
import { Protocol } from "../route/protocol.js"
|
||||
import {
|
||||
AIError,
|
||||
InvalidProviderOutputReason,
|
||||
LLMEvent,
|
||||
ProviderInternalReason,
|
||||
UnknownProviderReason,
|
||||
|
|
@ -1046,7 +1047,15 @@ const step = (state: ParserState, event: OpenAIChatEvent) =>
|
|||
|
||||
const finishEvents = Effect.fn("OpenAIChat.finishEvents")(function* (state: ParserState) {
|
||||
if (state.finishReason === undefined && state.requireFinishReason)
|
||||
return yield* ProviderShared.eventError(ADAPTER, "OpenAI Chat stream ended without finish_reason")
|
||||
return yield* new AIError({
|
||||
module: ADAPTER,
|
||||
method: "stream",
|
||||
reason: new InvalidProviderOutputReason({
|
||||
classification: "incomplete-stream",
|
||||
message: "OpenAI Chat stream ended without finish_reason",
|
||||
route: ADAPTER,
|
||||
}),
|
||||
})
|
||||
const events: LLMEvent[] = []
|
||||
const toolCallEvents =
|
||||
state.finishReason === undefined && Object.keys(state.tools).length > 0
|
||||
|
|
|
|||
|
|
@ -362,6 +362,7 @@ describe("OpenAI-compatible Chat route", () => {
|
|||
|
||||
expect(error.reason).toMatchObject({
|
||||
_tag: "InvalidProviderOutput",
|
||||
classification: "incomplete-stream",
|
||||
message: "OpenAI Chat stream ended without finish_reason",
|
||||
})
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue