Skip to content

fix(py/plugins/openai): finish_reason, finish_message, and refusals never set #6230

Description

@hilariie

Neither chat path sets finish_reason or finish_message, so every response reports None no matter how the model stopped. _generate reads the finish reason only to write a debug log and then discards it, while _generate_stream never reads it at all.

Refusals are worse than absent: nothing in the plugin reads refusal, so a refusal-only message (no content, no tool calls) raises ValueError: Unable to determine content part instead of returning a blocked response.

Go maps the reason with a provider-aware switch that also covers xAI's end_turn and model_context_window_exceeded and DeepSeek's insufficient_system_resource, and sets the finish message from refusal and from the error object a gateway attaches to a failing choice. JS maps the reason but does not read refusal either (tracked for JS in #6165).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions