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

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

#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::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)
 Resolve which grammar wins.
 
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.
 

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.