Skip to content

Status and Stop Reasons

Different protocols use different names for “the model stopped producing output”. ProxAI treats these as related protocol concepts, not interchangeable raw fields.

ProtocolTerminal fields or eventsMeaning
OpenAI Responsesstatus, output items, response.completedThe response envelope and typed events describe completion.
OpenAI Chat Completionschoices[].finish_reason, [DONE]Each choice has a finish reason; the stream ends with [DONE].
Anthropic Messagesstop_reason, stop_sequence, message_stopThe final message carries stop metadata; streaming ends with message_stop.
Anthropic Messages stop_reason
end_turnMaps to stop

The assistant naturally finished its turn.

max_tokensMaps to length

Generation stopped because the token budget was reached.

stop_sequenceMaps to stop

A configured stop sequence was generated. stop_sequence may identify the matched sequence.

tool_useMaps to tool_calls

The assistant produced a tool-use request and expects the client/tool loop to continue.

pause_turnMaps to stop or protocol-specific continuation

Provider asks the client to continue later; conversion must be careful not to pretend it is a normal final answer.

refusalMaps to refusal metadata / completed Responses with refusal content

A model refusal is a terminal assistant turn, not a provider/request failure.

OpenAI Chat Completions finish_reason
stopMaps to end_turn / stop_sequence

The model stopped normally or hit an explicit stop condition.

lengthMaps to max_tokens

The model stopped because the token budget was exhausted.

tool_callsMaps to tool_use

The assistant emitted tool calls.

content_filterMaps to refusal / incomplete Responses

The provider stopped output for safety or policy reasons. Treat as policy stop/truncation, not transport failure.

Wire structs mirror official field contracts rather than accepting missing and null interchangeably:

CaseRepresentation or handling
Official required-nullable fieldRequiredNullable<T>: missing is rejected, explicit null and values are accepted.
Official optional fieldOption<T> with explicit serde presence handling.
Known provider omits a required-nullable fieldA narrow provider normalization may insert explicit null before protocol deserialization when a measured fixture documents the deviation.
Streaming state before a terminal eventInternal accumulation state uses its own optional fields; the official wire event remains strict.

A successful final Anthropic message therefore follows the official requiredness of stop fields. Failed or interrupted upstream responses are handled as errors rather than by weakening the protocol carrier or inventing a stop reason.

  • ProxAI observes streaming terminal events; it does not treat arbitrary byte-stream closure as semantic completion.
  • ProxAI does not fabricate provider-specific reason details such as upstream code, param, or matched stop sequences.
  • Cross-protocol mappings should preserve behavior first, exact field spelling second.
  • A model refusal is semantic output, not an upstream/request failure; do not map it to Responses failed.
  • Responses failed is a response lifecycle/error state and should not be fabricated as Anthropic refusal without refusal content.
  • Tool-call terminal states must remain distinct from natural text completion.