context_fit.h

src/inference/context_fit.h

@file context_fit.h @brief v2.13.0 prompt-vs-context admission arithmetic for one turn.

Owners: @tvanfossen

context_fit_breakdown

std::string entropic::context_fit_breakdown(const ContextFit &f)

Per-contributor token breakdown, as one clause.

src/inference/context_fit.h:114

Show on the map →

Called by context_overflow_message

Calls context_fit_history_tokens

Source · 7 lines
inline std::string context_fit_breakdown(const ContextFit& f) {
    return "staged tools " + std::to_string(f.tool_tokens) + " tok ("
         + std::to_string(f.tool_count) + " tools, "
         + std::to_string(f.tool_bytes) + " bytes); system prompt "
         + std::to_string(f.system_tokens) + " tok; message history "
         + std::to_string(context_fit_history_tokens(f)) + " tok";
}
Activity · 1 steps
lines 115–119return "staged tools " + std::to_string(f.tool_tokens) + " tok (" + std::to_string(f.tool_count) + " tools, " + std::to_string(f.tool_bytes) + " bytes); system prompt " + std::to_string(f.system_tokens) + " tok; message history " + std::to_string(context_fit_history_tokens(f)) + " tok";

Requirements

REQ-INFER-026

context_fit_overflows

bool entropic::context_fit_overflows(const ContextFit &f)

Whether this turn's prompt cannot fit the tier's context at all.

src/inference/context_fit.h:65

Show on the map →

Called by SCENARIO, refuse_over_context

Calls none

Source · 3 lines
inline bool context_fit_overflows(const ContextFit& f) {
    return f.context_length > 0 && f.prompt_tokens >= f.context_length;
}
Activity · 1 steps
lines 66–66return f.context_length > 0 && f.prompt_tokens >= f.context_length;

Requirements

REQ-INFER-026

context_overflow_message

std::string entropic::context_overflow_message(const ContextFit &f)

The refusal an operator reads, carrying every number they need.

src/inference/context_fit.h:135

Show on the map →

Called by SCENARIO, refuse_over_context

Calls context_fit_breakdown, context_fit_largest_contributor

Source · 13 lines
inline std::string context_overflow_message(const ContextFit& f) {
    return "Prompt does not fit this tier's context: "
         + std::to_string(f.prompt_tokens) + " prompt tokens against "
           "context_length=" + std::to_string(f.context_length)
         + " (over by "
         + std::to_string(f.prompt_tokens - f.context_length)
         + " tokens). Largest contributor: "
         + context_fit_largest_contributor(f) + ". Breakdown: "
         + context_fit_breakdown(f)
         + ". Refused before decode — compaction cannot shrink the staged "
           "tool block. Raise this tier's context_length, or narrow its "
           "allowed_tools.";
}
Activity · 1 steps
lines 136–146return "Prompt does not fit this tier's context: " + std::to_string(f.prompt_tokens) + " prompt tokens against " "context_length=" + std::to_string(f.context_length) + " (over by " + std::to_string(f.prompt_tokens - f.context_length) + " tokens). Largest contributor: " + context_fit_largest_contributor(f) + ". Breakdown: " + context_fit_breakdown(f) + ". Refused before decode — compaction cannot shrink the staged " "tool block. Raise this tier's context_length, or narrow its " "allowed_tools.";

Requirements

REQ-INFER-026