include/entropic/types/generation_result.h

← API

include/entropic/types/generation_result.h

Functions

GenerationRecord entropic::make_generation_record(const GenerationResult &r)

Project a result down to the record kept for metrics.

Parameters
  • r — Completed generation result.
Returns
The metric fields, without content or tool calls.

entropic::GenerationRecord

One generation's metrics, without its text (gh#154).

std::string entropic::GenerationRecord::finish_reason

"stop", "length", "error"

int entropic::GenerationRecord::token_count

Tokens generated.

int entropic::GenerationRecord::prefill_tokens

Prompt tokens actually decoded (gh#144)

double entropic::GenerationRecord::throughput_tok_s

Measured decode throughput.

int entropic::GenerationRecord::n_drafted

Speculative/MTP tokens proposed.

int entropic::GenerationRecord::n_accepted

Of those, accepted by the target.

GrammarProvenance entropic::GenerationRecord::grammar

What constrained the decode.

entropic::GenerationResult

Result of a single generation call.

std::string entropic::GenerationResult::content

Generated text (cleaned by adapter)

std::string entropic::GenerationResult::raw_content

Raw model output before adapter processing.

std::vector<ToolCall> entropic::GenerationResult::tool_calls

Tool calls parsed from content.

std::string entropic::GenerationResult::finish_reason

Finish reason: "stop", "length", "error".

int entropic::GenerationResult::token_count

Generated token count.

double entropic::GenerationResult::generation_time_ms

Wall-clock generation time.

int entropic::GenerationResult::prefill_tokens

Prompt tokens actually pushed through llama_decode during this run's prefill (gh#144, v2.12.0).

The instrumentation every prefill-reuse claim rests on. A correctness test passes via full-reprefill fallback even when reuse is completely dead, so "the answer was right" says nothing about whether a prefix was reused — this does. Zero when the path does not report it.

double entropic::GenerationResult::routing_ms

Router classification time.

double entropic::GenerationResult::swap_ms

Model swap time.

double entropic::GenerationResult::total_ms

Total end-to-end time.

double entropic::GenerationResult::throughput_tok_s

Measured throughput for this generation (tok/s).

Computed from token_count / generation_time_ms. 0.0 if either is 0.

bool entropic::GenerationResult::time_limited

true if generation was terminated by time limit rather than EOS/stop sequence/max_tokens.

int entropic::GenerationResult::original_max_tokens

Original max_tokens before auto-adaptation reduced it.

0 if no adaptation occurred.

int entropic::GenerationResult::seq_id

Sequence identifier for multi-sequence backends.

0 for single-sequence backends (default). Set by generate_seq() to track which sequence produced this result.

int entropic::GenerationResult::n_drafted

Tokens proposed by the draft/MTP head across all rounds.

0 when no speculative kernel ran (plain decode). The instrumentation signal that MTP/speculative actually engaged vs silently fell back.

int entropic::GenerationResult::n_accepted

Draft tokens the target accepted (≤ n_drafted).

>0 proves the head's drafts are lossless-verified hits, not just proposed.

GrammarProvenance entropic::GenerationResult::grammar

What constrained this decode and who asked for it.

Populated by the orchestrator from the SAME inputs the sampler's application site uses, so the record cannot disagree with what ran.

entropic_error_t entropic::GenerationResult::error_code

Error code (ENTROPIC_OK if no error)

std::string entropic::GenerationResult::error_message

Error description (empty if no error)

bool entropic::GenerationResult::ok() const

True if generation completed without error.

Returns
true when error_code == ENTROPIC_OK.

entropic::GrammarProvenance

What constrained one decode, and what asked for it (gh#154).

std::string entropic::GrammarProvenance::source

"request" | "tier" | "tool_call" | "none".

std::string entropic::GrammarProvenance::key

Registry key / frontmatter stem that was named ("" = none).

bool entropic::GrammarProvenance::resolved

true when a grammar text actually constrained this decode.

std::string entropic::GrammarProvenance::conflict_winner

The winning source when two grammars collided ("" = no collision).

A request grammar displacing a tool-call grammar means the staged tools were NOT structurally enforced.