Skip to content

fix(oaistream): end a content_filter turn as a refusal - #4825

Merged
dgageot merged 1 commit into
docker:mainfrom
jaeminbird:fix/oaistream-content-filter
Nov 9, 2026
Merged

dgageot merged 1 commit into
docker:mainfrom
jaeminbird:fix/oaistream-content-filter

Conversation

@jaeminbird

Copy link
Copy Markdown
Contributor

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 inferred stop. The Responses API path already maps content_filter to refusal.

The adapter now maps it to refusal and holds it for the usage chunk like stop/length. The runtime then voids the tool calls and still records usage.

  • Real openai.Client → LocalRuntime test: refusal, 0 tool runs, one request, usage kept. On main the tool loops, or the turn reports content_filter.
  • 3 new adapter cases fail without the change.
  • go test ./pkg/model/provider/... ./pkg/runtime/ (Windows) and -race on oaistream, openai and runtime (Linux) pass, except failures main has too. golangci-lint is clean.

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.
@jaeminbird
jaeminbird requested a review from a team as a code owner November 9, 2026 04:47
Copilot AI balanced review requested due to automatic review settings November 9, 2026 04:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@aheritier aheritier added area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/testing Test infrastructure, CI/CD, test runners, evaluation kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Nov 9, 2026
@dgageot
dgageot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into docker:main with commit dbbd4b2 Nov 9, 2026
17 checks passed
@jaeminbird
jaeminbird deleted the fix/oaistream-content-filter branch November 10, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/testing Test infrastructure, CI/CD, test runners, evaluation kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants