This commit is contained in:
team 1
2026-04-30 15:11:54 +02:00
parent 26fc9f7ad1
commit 652f54c674
4 changed files with 168 additions and 5 deletions

View File

@@ -116,27 +116,27 @@ final class AgentRunnerConfig
public function getCommerceHistoryBudgetChars(): int
{
return $this->getInt('commerce_history_budget_chars', 1000);
return $this->getRequiredInt('commerce_history_budget_chars');
}
public function getProductSearchKnowledgeChunkLimit(): int
{
return $this->getInt('product_search_knowledge_chunk_limit', 6);
return $this->getRequiredInt('product_search_knowledge_chunk_limit');
}
public function getAdvisoryProductSearchKnowledgeChunkLimit(): int
{
return $this->getInt('advisory_product_search_knowledge_chunk_limit', 9);
return $this->getRequiredInt('advisory_product_search_knowledge_chunk_limit');
}
public function getOptimizedShopQueryPrefixPattern(): string
{
return $this->getString('optimized_shop_query_prefix_pattern', '/^(?:keywords?|suchquery|search\\s*query|query)\\s*:\\s*/iu');
return $this->getRequiredString('optimized_shop_query_prefix_pattern');
}
public function getOptimizedShopQueryTrimCharacters(): string
{
return $this->getString('optimized_shop_query_trim_characters', " \t\n\r\0\x0B\"'`");
return $this->getRequiredString('optimized_shop_query_trim_characters');
}
private function getInt(string $key, int $default): int
@@ -176,6 +176,28 @@ final class AgentRunnerConfig
return is_string($value) && $value !== '' ? $value : $default;
}
private function getRequiredInt(string $key): int
{
$value = $this->requiredValue($key);
if (is_numeric($value)) {
return (int) $value;
}
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must be numeric.', $key));
}
private function getRequiredString(string $key): string
{
$value = $this->requiredValue($key);
if (is_string($value) && $value !== '') {
return $value;
}
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" must be a non-empty string.', $key));
}
/**
* @param string[] $default
* @return string[]
@@ -220,6 +242,21 @@ final class AgentRunnerConfig
return $current;
}
private function requiredValue(string $key): mixed
{
$current = $this->config;
foreach (explode('.', $key) as $segment) {
if (!is_array($current) || !array_key_exists($segment, $current)) {
throw new \InvalidArgumentException(sprintf('RetrieX agent config key "%s" is required.', $key));
}
$current = $current[$segment];
}
return $current;
}
public function getEmptyPromptMessage(): string
{
return $this->getString('messages.empty_prompt', '❌ Empty prompt.');