empty_content_diagnosis.h

src/inference/empty_content_diagnosis.h

@file empty_content_diagnosis.h @brief gh#137: explain an empty turn without misattributing its cause.

Owners: @tvanfossen

diagnose_empty_content

EmptyContentCause entropic::diagnose_empty_content(bool content_empty, bool produced_tokens, const std::string &finish_reason, bool has_tool_calls)

Classify an empty-content turn from what the decode reported.

src/inference/empty_content_diagnosis.h:68

Show on the map →

Called by SCENARIO, warn_if_content_vanished

Calls none

Source · 16 lines
inline EmptyContentCause diagnose_empty_content(bool content_empty,
                                                bool produced_tokens,
                                                const std::string& finish_reason,
                                                bool has_tool_calls) {
    EmptyContentCause cause = EmptyContentCause::unknown;
    if (!content_empty || !produced_tokens) {
        cause = EmptyContentCause::not_empty;
    } else if (has_tool_calls) {
        cause = EmptyContentCause::tool_call_only;
    } else if (finish_reason == "length") {
        cause = EmptyContentCause::budget_truncated;
    } else if (finish_reason == "stop") {
        cause = EmptyContentCause::model_stopped;
    }
    return cause;
}
Activity · 13 steps
lines 72–72EmptyContentCause cause = EmptyContentCause::unknown;lines 73–73◇ if (!content_empty || !produced_tokens)lines 74–74cause = EmptyContentCause::not_empty;lines 75–75elselines 75–75◇ if (has_tool_calls)lines 76–76cause = EmptyContentCause::tool_call_only;lines 77–77elselines 77–77◇ if (finish_reason == "length")lines 78–78cause = EmptyContentCause::budget_truncated;lines 79–79elselines 79–79◇ if (finish_reason == "stop")lines 80–80cause = EmptyContentCause::model_stopped;lines 82–82return cause;

Requirements

REQ-INFER-010

explain_empty_content

std::string entropic::explain_empty_content(EmptyContentCause cause)

Operator-facing explanation for an empty-content turn.

src/inference/empty_content_diagnosis.h:93

Show on the map →

Called by SCENARIO, warn_if_content_vanished

Calls none

Source · 37 lines
inline std::string explain_empty_content(EmptyContentCause cause) {
    // The gh#137 case deliberately does NOT mention max_tokens: the model chose
    // to stop, so more budget changes nothing and naming it misdirects.
    static const std::string kBudget =
        "The generation hit its token budget while still inside a reasoning "
        "block, so no answer was ever produced and the content is empty. This "
        "is a budget problem: raise max_tokens for this tier.";
    static const std::string kStopped =
        "The model ended the turn while still inside an unterminated reasoning "
        "block, so the content is empty. finish_reason is 'stop', NOT 'length' "
        "— this is not a budget problem and raising max_tokens will not help. "
        "The prompt or tier configuration is not converging on an answer.";
    // gh#159: NOT a fault. `apply_adapter_parse` moves tool calls out of
    // content, so a well-behaved sequential turn arrives here looking
    // exactly like gh#137's failure. Says nothing about reasoning blocks,
    // max_tokens or convergence — a consumer ACTS on those words.
    static const std::string kToolCallOnly =
        "The turn's entire output was tool calls, which the adapter moved out "
        "of the content — nothing was lost. This is the expected shape for a "
        "sequential tool-call tier and needs no tuning.";
    static const std::string kUnknown =
        "The turn produced tokens but delivered no content, and the finish "
        "reason does not explain why. This is not a parse error; report it "
        "with the raw generation attached.";

    std::string out;
    if (cause == EmptyContentCause::tool_call_only) {
        out = kToolCallOnly;
    } else if (cause == EmptyContentCause::budget_truncated) {
        out = kBudget;
    } else if (cause == EmptyContentCause::model_stopped) {
        out = kStopped;
    } else if (cause == EmptyContentCause::unknown) {
        out = kUnknown;
    }
    return out;
}
Activity · 17 steps
lines 96–99static const std::string kBudget = "The generation hit its token budget while still inside a reasoning " "block, so no answer was ever produced and the content is empty. This " "is a budget problem: raise max_tokens for this tier.";lines 100–104static const std::string kStopped = "The model ended the turn while still inside an unterminated reasoning " "block, so the content is empty. finish_reason is 'stop', NOT 'length' " "— this is not a budget problem and raising max_tokens will not help. " "The prompt or tier configuration is not converging on an answer.";lines 109–112static const std::string kToolCallOnly = "The turn's entire output was tool calls, which the adapter moved out " "of the content — nothing was lost. This is the expected shape for a " "sequential tool-call tier and needs no tuning.";lines 113–116static const std::string kUnknown = "The turn produced tokens but delivered no content, and the finish " "reason does not explain why. This is not a parse error; report it " "with the raw generation attached.";lines 118–118std::string out;lines 119–119◇ if (cause == EmptyContentCause::tool_call_only)lines 120–120out = kToolCallOnly;lines 121–121elselines 121–121◇ if (cause == EmptyContentCause::budget_truncated)lines 122–122out = kBudget;lines 123–123elselines 123–123◇ if (cause == EmptyContentCause::model_stopped)lines 124–124out = kStopped;lines 125–125elselines 125–125◇ if (cause == EmptyContentCause::unknown)lines 126–126out = kUnknown;lines 128–128return out;

Requirements

REQ-INFER-010