Pixir.Provider.OutputTruncation (pixir v0.1.12)

Copy Markdown View Source

Provider-neutral evidence about whether a successful model response ended because the Provider truncated its output.

The value is deliberately independent from operational finish_reason: a response can contain executable, finalized tool calls and still be positively truncated. Raw Provider terminal tokens are retained only when they are bounded, valid UTF-8, and contain the conservative identity alphabet used by this contract.

Missing and malformed historical evidence normalizes to an explicit :unknown value. It is never inferred from token counts, text length, transport closure, or a requested output cap.

Summary

Functions

Normalize the nested object in canonical provider_usage data.

Normalize the evidence carried by one successful Provider result.

Normalize a struct or atom/string-keyed neutral evidence map.

Build explicit Provider evidence that output was not truncated.

Return the bounded raw Provider terminal token, if retained.

Return the neutral reason enum, if any.

Return the neutral status enum.

Return a bounded redacted summary that never includes the raw Provider token.

Project the opaque value into a string-keyed canonical Event map.

Project the opaque value into an atom-keyed Provider result map.

Build explicit positive truncation evidence.

True only for explicit, valid positive truncation evidence.

Build explicit uncertainty evidence.

Types

t()

@opaque t()

Functions

from_event_data(data)

@spec from_event_data(term()) :: t()

Normalize the nested object in canonical provider_usage data.

from_result(result, provider_module)

@spec from_result(term(), module()) :: t()

Normalize the evidence carried by one successful Provider result.

normalize(evidence)

@spec normalize(term()) :: t()

Normalize a struct or atom/string-keyed neutral evidence map.

not_truncated(provider_reason)

@spec not_truncated(term()) :: t()

Build explicit Provider evidence that output was not truncated.

provider_reason(evidence)

@spec provider_reason(t() | term()) :: String.t() | nil

Return the bounded raw Provider terminal token, if retained.

reason(evidence)

@spec reason(t() | term()) :: atom() | nil

Return the neutral reason enum, if any.

status(evidence)

@spec status(t() | term()) :: atom()

Return the neutral status enum.

summary(evidence)

@spec summary(t() | term()) :: String.t()

Return a bounded redacted summary that never includes the raw Provider token.

to_event_data(evidence)

@spec to_event_data(t() | term()) :: map()

Project the opaque value into a string-keyed canonical Event map.

to_result_map(evidence)

@spec to_result_map(t() | term()) :: map()

Project the opaque value into an atom-keyed Provider result map.

truncated(reason, provider_reason)

@spec truncated(term(), term()) :: t()

Build explicit positive truncation evidence.

truncated?(evidence)

@spec truncated?(t() | term()) :: boolean()

True only for explicit, valid positive truncation evidence.

unknown(reason, provider_reason \\ nil)

@spec unknown(term(), term()) :: t()

Build explicit uncertainty evidence.