Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
grammar_source.h File Reference

Which grammar source constrains a decode (gh#134). More...

#include <entropic/types/config.h>
#include <entropic/types/generation_result.h>
#include <string>
Include dependency graph for grammar_source.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Enumerations

enum class  entropic::GrammarSource {
  entropic::none , entropic::request , entropic::tier , entropic::tool_call ,
  entropic::count
}
 Which source, if any, constrains the decode. More...
 

Functions

constexpr int entropic::grammar_source_count ()
 Number of declared grammar sources, sentinel excluded.
 
GrammarSource entropic::resolve_grammar_source (const std::string &request_grammar, const std::string &tool_grammar, bool request_from_tier=false)
 Resolve which grammar wins.
 
bool entropic::is_request_grammar (GrammarSource source)
 Whether a source is applied as a request-side grammar.
 
bool entropic::tier_grammar_unresolved (const GenerationParams &params)
 A TIER named a grammar and nothing resolved it (gh#154).
 
const char * entropic::grammar_source_name (GrammarSource source)
 Stable wire name for a grammar source.
 
bool entropic::grammar_sources_collide (const std::string &request_grammar, const std::string &tool_grammar)
 Whether both sources are active — a config error worth reporting.
 
GrammarProvenance entropic::describe_grammar (const GenerationParams &params, const std::string &tool_grammar)
 Describe what constrained one decode, for the result record (gh#154).
 

Detailed Description

Which grammar source constrains a decode (gh#134).

Entropic has two grammar sources and they cannot compose — they constrain output to different languages:

  • the REQUEST grammar (GenerationParams::grammar, also fed by grammar_key and identity grammar:)
  • the TOOL-CALL grammar llama.cpp derives from the staged tool schemas during common_chat_templates_apply

Kept as a pure function with no vendor types so the precedence rule — the only part carrying judgment — is unit-testable without a model. Before v2.10.4 the tool-call source was discarded at the render entirely, so a tools-staged tier decoded unconstrained; see llama_cpp_backend.cpp.

Version
2.10.4

Definition in file grammar_source.h.