aws.internal._is_malformed_stop

(internal) True for the two `stopReason` values that say the turn's own content is unusable: `malformed_model_output` (the model emitted something the service could not assemble into a message) and `malformed_tool_use` (it emitted a tool call the service could not assemble into a `toolUse` block).

Reference version

Signature

function aws.internal._is_malformed_stop(raw: string) -> bool

(internal) True for the two stopReason values that say the turn's own content is unusable: malformed_model_output (the model emitted something the service could not assemble into a message) and malformed_tool_use (it emitted a tool call the service could not assemble into a toolUse block).

Neither is a stop reason in the ai.content.StopReason sense — there is no answer to stop on — so parse_response throws ai.errors.ParseFailed with the whole response as raw_output instead of returning a turn. That is the honest identity (it IS a failure to produce parseable output), it is RetrySafety.Safe so a Retry policy re-asks, and it keeps the raw bytes for the caller. MaxTokens would falsely blame the token limit and Refused would falsely claim the model declined.

Source:<builtin>/aws/ns_internal/bedrock.bamlbytes 4960749726