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 content_filter or refusal metadata

Provider refused the request. Preserve refusal semantics where the target protocol can represent them.

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 / filtered status

The provider stopped output for safety or policy reasons.

Wire structs often use nullable/missing-compatible shapes even when provider documentation says a field is required. This is deliberate:

CaseWhy ProxAI accepts it
SDK schemas mark required-nullable fieldsSome SDK-generated types allow the field to be omitted while still treating null as valid.
Upstream compatibility layers omit null fieldsOpenAI-compatible or Anthropic-compatible proxies may drop fields whose value is null.
Streaming accumulation is partial before terminal eventBefore the terminal event, stop information may not be known yet.
Error or interrupted responses are not normal final messagesA failed upstream response should be handled as an error, not forced into a fake stop reason.

From a logical non-streaming success path, a final Anthropic message should include stop information. The parser still accepts missing/null values so ProxAI can produce a clear translation or upstream error instead of crashing on an overly strict model.

  • 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.
  • Tool-call terminal states must remain distinct from natural text completion.