Skip to content

fix(customchat): accept hyphenated finish reasons and fail unknown ones as upstream errors - #157

Merged
deLiseLINO merged 1 commit into
mainfrom
fix/chat-unknown-finish-reason
Nov 26, 2026
Merged

deLiseLINO merged 1 commit into
mainfrom
fix/chat-unknown-finish-reason

Conversation

@deLiseLINO

Copy link
Copy Markdown
Owner

Why

An upstream that ends a filtered answer with finish_reason: "content-filter" (hyphen) got a 503 server_overloaded from prism. The chat provider did not know the hyphenated spelling, failed the turn with an unknown reason, and routing turned every unknown server-class failure into an overload. Clients retry an overload, so the turn never ended.

Scope

  • internal/providers/customchat: finish reasons are compared after lower-casing and replacing - with _, so content-filter and CONTENT_FILTER end the turn as a content-filter stop.
  • A finish reason with no canonical status now fails with upstream_transport (502) instead of server_overloaded (503). The message is unchanged.

Verification

  • go test ./internal/providers/customchat/ ./internal/routing/ ./internal/server/: ok.
  • New TestFinishReasonSpellings covers a hyphenated, an upper-case and an unknown reason, streamed and buffered.

Model: claude-opus-5-5

@deLiseLINO
deLiseLINO merged commit 5b420dc into main Nov 26, 2026
3 checks passed
@deLiseLINO
deLiseLINO deleted the fix/chat-unknown-finish-reason branch November 26, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant