13namespace entropic::config {
24 for (
const auto& entry : tools) {
25 if (entry.find(
'.') == std::string::npos) {
26 return "allowed_tools entry '" + entry
27 +
"' must use '{server_name}.{tool_name}' format";
45 err =
"context_length must be in [512, 131072], got "
47 }
else if (config.
adapter.empty()) {
48 err =
"adapter must not be empty";
49 }
else if (config.
n_batch < 1) {
50 err =
"n_batch must be >= 1, got "
51 + std::to_string(config.
n_batch);
68 if (!config.
tiers.empty()
89 err =
"compaction.threshold_percent must be in [0.5, 0.99], got "
93 err =
"compaction.warning_threshold_percent ("
95 +
") must be less than threshold_percent ("
99 err =
"compaction.preserve_recent_turns must be in [1, 10], got "
110 err =
"compaction.tool_result_ttl must be >= 1, got "
126 const std::string& fallback,
127 const std::unordered_map<std::string, TierConfig>& tiers)
129 if (tiers.count(fallback) == 0) {
130 return "routing.fallback_tier '" + fallback +
"' not in tiers";
144 const std::unordered_map<std::string, std::string>& tier_map,
145 const std::unordered_map<std::string, TierConfig>& tiers)
147 for (
const auto& [key, tier] : tier_map) {
148 if (tiers.count(tier) == 0) {
149 return "routing.tier_map['" + key +
"'] = '" + tier
165 const std::unordered_map<std::string, std::vector<std::string>>& rules,
166 const std::unordered_map<std::string, TierConfig>& tiers)
168 for (
const auto& [source, targets] : rules) {
169 if (tiers.count(source) == 0) {
170 return "routing.handoff_rules key '" + source
173 for (
const auto& target : targets) {
174 if (tiers.count(target) == 0) {
175 return "routing.handoff_rules['" + source
176 +
"'] contains '" + target +
"' not in tiers";
197 if (models.
tiers.empty()) {
200 err =
"routing.enabled is true but models.router is not configured";
224 const std::unordered_map<std::string, TierConfig>& tiers,
225 const std::unordered_map<std::string, std::vector<std::string>>&
228 std::string warnings;
229 for (
const auto& [name, tier] : tiers) {
230 if (tier.auto_chain.has_value() && !tier.auto_chain->empty()
231 && handoff_rules.count(name) == 0) {
232 if (!warnings.empty()) {
235 warnings +=
"tier '" + name
236 +
"' has auto_chain but no handoff_rules entry";
252 return "inference.prompt_cache: enabled=true but max_bytes=0";
269 for (
const auto& [name, tier] : models.
tiers) {
272 err =
"models." + name +
": " + err;
278 if (err.empty() && models.
router.has_value()) {
281 err =
"models.router: " + err;
298 std::vector<std::string>& warnings)
300 s_log->info(
"Config validation start");
316 warnings.push_back(w);
321 s_log->info(
"Config validation passed ({} warning(s))",
324 s_log->error(
"Config validation failed: {}", err);
spdlog initialization and logger access.
ENTROPIC_EXPORT std::shared_ptr< spdlog::logger > get(const std::string &name)
Get or create a named logger.
Auto-compaction configuration.
float warning_threshold_percent
Warning trigger (0.3–0.9)
int preserve_recent_turns
Turns to preserve (1–10)
int tool_result_ttl
Tool result TTL in turns (>= 1; v2.1.3 #6: gated on fill, no upper bound)
float threshold_percent
Compaction trigger (0.5–0.99)
Model configuration for a single tier.
int context_length
Context window size (512–131072)
int n_batch
Batch size for prompt processing.
std::optional< std::vector< std::string > > allowed_tools
Tool whitelist (nullopt = all)
std::string adapter
Chat adapter name.
Configuration for all models (tiers + router).
std::optional< ModelConfig > router
Router model (separate from tiers)
std::unordered_map< std::string, TierConfig > tiers
Tier name → config.
std::string default_tier
Default tier name.
Full parsed configuration.
PromptCacheConfig prompt_cache
Prompt KV cache settings.
CompactionConfig compaction
Auto-compaction settings.
RoutingConfig routing
Routing rules.
ModelsConfig models
Tiers + router.
Prompt caching configuration.
size_t max_bytes
Maximum cache RAM (512 MB default)
bool enabled
Master switch (false = no caching)
Configuration for model routing.
std::string fallback_tier
Fallback when routing fails.
std::unordered_map< std::string, std::vector< std::string > > handoff_rules
Tier handoff rules.
bool enabled
Enable routing.
std::unordered_map< std::string, std::string > tier_map
Classification → tier mapping.
static std::string validate_model_tiers(const ModelsConfig &models)
Validate model tiers and router.
Config validation functions.
ENTROPIC_EXPORT std::string validate_handoff_rules(const std::unordered_map< std::string, std::vector< std::string > > &rules, const std::unordered_map< std::string, TierConfig > &tiers)
Check all handoff_rules keys and values exist in tiers.
ENTROPIC_EXPORT std::string validate_routing(const RoutingConfig &routing, const ModelsConfig &models)
Validate RoutingConfig against defined tiers.
ENTROPIC_EXPORT std::string validate_tier_map(const std::unordered_map< std::string, std::string > &tier_map, const std::unordered_map< std::string, TierConfig > &tiers)
Check all tier_map values exist in tiers.
ENTROPIC_EXPORT std::string validate_config(const ParsedConfig &config, std::vector< std::string > &warnings)
Validate the full ParsedConfig.
ENTROPIC_EXPORT std::string validate_fallback_tier(const std::string &fallback, const std::unordered_map< std::string, TierConfig > &tiers)
Check fallback_tier exists in tiers.
ENTROPIC_EXPORT std::string warn_auto_chain_without_targets(const std::unordered_map< std::string, TierConfig > &tiers, const std::unordered_map< std::string, std::vector< std::string > > &handoff_rules)
Warn if tier has auto_chain but no handoff_rules entry.
ENTROPIC_EXPORT std::string validate(const ModelConfig &config)
Validate a ModelConfig.
ENTROPIC_EXPORT std::string validate_allowed_tools(const std::vector< std::string > &tools)
Validate allowed_tools entries use "server.tool" format.