Skip to content

fix(openai): show OpenAI refusals and end the turn as refusal - #4932

Open
jaeminbird wants to merge 1 commit into
docker:mainfrom
jaeminbird:fix/openai-refusal-text
Open

jaeminbird wants to merge 1 commit into
docker:mainfrom
jaeminbird:fix/openai-refusal-text

Conversation

@jaeminbird

Copy link
Copy Markdown
Contributor

OpenAI sends a model refusal in its own field, not as text: delta.refusal on Chat Completions, and response.refusal.delta plus a refusal content part on Responses. Neither adapter read it, so the user got an empty answer that ended as stop ("no final answer" from run --exec). It shows up most with strict structured_output schemas.

Both adapters now emit the refusal text as the answer (the Responses snapshot is deduplicated against the deltas) and end the turn as refusal, as content_filter already does since #4825.

Tested with a real openai.Client through LocalRuntime on both APIs, plus adapter cases; all fail on main. golangci-lint is clean.

OpenAI delivers a refusal in delta.refusal (Chat Completions) or
response.refusal.delta events and a refusal content part (Responses), not
as text. Both adapters dropped it, so the user got an empty answer that
ended as stop. Emit the refusal text as the answer and report the finish
reason as refusal.
@jaeminbird
jaeminbird requested a review from a team as a code owner November 14, 2026 02:52
Copilot AI balanced review requested due to automatic review settings November 14, 2026 02:52

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/openai For features/issues/fixes related to the usage of OpenAI models area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Nov 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers/openai For features/issues/fixes related to the usage of OpenAI models area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection 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.

3 participants