Repository navigation
fix(oaistream): end a content_filter turn as a refusal - #4825
Merged
Merged
Conversation
Chat Completions passed content_filter through unchanged. The runtime doesn't treat it as terminal, so a filtered turn ran the tool calls streamed before it (looping until the identical-calls guard) and a text turn ended as an inferred stop. Map it to refusal, as the Responses API path does, and hold it for the usage chunk like stop and length.
dgageot
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Chat Completions (Azure OpenAI, OpenAI moderation, compatible gateways),
finish_reason: "content_filter"passed through the adapter unchanged. The runtime doesn't treat it as terminal, so a filtered turn kept going. Tool calls streamed before the filter ran anyway (in a scripted run, until the 5-identical-calls guard), and a text turn ended as an inferredstop. The Responses API path already mapscontent_filtertorefusal.The adapter now maps it to
refusaland holds it for the usage chunk likestop/length. The runtime then voids the tool calls and still records usage.openai.Client→LocalRuntimetest:refusal, 0 tool runs, one request, usage kept. On main the tool loops, or the turn reportscontent_filter.go test ./pkg/model/provider/... ./pkg/runtime/(Windows) and-raceon oaistream, openai and runtime (Linux) pass, except failures main has too. golangci-lint is clean.