mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-26 23:28:43 +00:00
fix(ai): map Z.AI's model_context_window_exceeded finish to length (#66646)
This commit is contained in:
parent
ac2263f34c
commit
3a2e427d0d
2 changed files with 12 additions and 0 deletions
|
|
@ -950,6 +950,8 @@ const mapFinishReason = Effect.fnUntraced(function* (event: OpenAIChatEvent, rea
|
|||
case "end":
|
||||
return "stop" as const
|
||||
case "length":
|
||||
// Z.AI stops with this when the prompt plus the generated output fill the context window.
|
||||
case "model_context_window_exceeded":
|
||||
return "length" as const
|
||||
case "content_filter":
|
||||
// Z.AI ends a response its safety review blocked with "sensitive".
|
||||
|
|
|
|||
|
|
@ -647,6 +647,16 @@ describe("OpenAI-compatible Chat route", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("maps Z.AI's model_context_window_exceeded finish to a length finish", () =>
|
||||
Effect.gen(function* () {
|
||||
const response = yield* LLMClient.generate(request).pipe(
|
||||
Effect.provide(fixedResponse(sseEvents(deltaChunk({}, "model_context_window_exceeded")))),
|
||||
)
|
||||
|
||||
expect(response.finishReason).toEqual({ normalized: "length", raw: "model_context_window_exceeded" })
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("preserves content-filter finishes in the common reason algebra", () =>
|
||||
Effect.gen(function* () {
|
||||
const filtered = yield* LLMClient.generate(request).pipe(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue