This commit is contained in:
team 1
2026-05-04 17:49:01 +02:00
parent 387506b239
commit 794ab1a30b
9 changed files with 256 additions and 107 deletions

View File

@@ -310,6 +310,20 @@ final readonly class RetriexEffectiveConfigProvider
$errors[] = 'Missing shop query context fallback filter term: ' . $term;
}
}
$currentInputPreservationTerms = $this->effectiveShopQueryCurrentInputPreservationTerms();
$checks['shop_query_current_input_preservation_enabled'] = $this->agentRunnerConfig->isShopQueryCurrentInputPreservationEnabled();
if (!$checks['shop_query_current_input_preservation_enabled']) {
$errors[] = 'Shop query current-input term preservation is disabled.';
}
foreach ($this->governanceConfig->getRegressionShopQueryCurrentInputPreservationTerms() as $term) {
$key = 'shop_query_current_input_preservation_' . $this->guardrailCheckKey($term);
$checks[$key] = in_array($term, $currentInputPreservationTerms, true);
if (!$checks[$key]) {
$errors[] = 'Missing shop query current-input preservation term: ' . $term;
}
}
$checks['shop_query_context_fallback_history_budget_positive'] = $this->agentRunnerConfig->getShopQueryContextFallbackHistoryBudgetChars() > 0;
if (!$checks['shop_query_context_fallback_history_budget_positive']) {
$errors[] = 'Shop query context fallback history budget must be greater than zero.';
@@ -369,6 +383,15 @@ final readonly class RetriexEffectiveConfigProvider
);
}
/** @return string[] */
private function effectiveShopQueryCurrentInputPreservationTerms(): array
{
return $this->mergeUniqueStrings(
$this->languageCleanupConfig->getProtectedTerms(),
$this->agentRunnerConfig->getShopQueryCurrentInputPreservationTerms()
);
}
/**
* @param string[] $left
* @param string[] $right
@@ -583,7 +606,6 @@ final readonly class RetriexEffectiveConfigProvider
'max_length_ratio_percent' => $this->agentRunnerConfig->getInputNormalizationMaxLengthRatioPercent(),
'heartbeat_message' => $this->agentRunnerConfig->getInputNormalizationHeartbeatMessage(),
'output_prefix_pattern' => $this->agentRunnerConfig->getInputNormalizationOutputPrefixPattern(),
'placeholder_outputs' => $this->agentRunnerConfig->getInputNormalizationPlaceholderOutputs(),
'skip_patterns' => $this->agentRunnerConfig->getInputNormalizationSkipPatterns(),
'prompt' => [
'intro' => $this->agentRunnerConfig->getInputNormalizationIntro(),
@@ -603,10 +625,6 @@ final readonly class RetriexEffectiveConfigProvider
'terms' => $this->agentRunnerConfig->getInputNormalizationFuzzyRoutingTerms(),
],
],
'followup_actions' => [
'commerce' => $this->agentRunnerConfig->getCommerceFollowUpActions(),
'knowledge' => $this->agentRunnerConfig->getKnowledgeFollowUpActions(),
],
'messages' => [
'empty_prompt' => $this->agentRunnerConfig->getEmptyPromptMessage(),
'analyze_request' => $this->agentRunnerConfig->getAnalyzeRequestMessage(),
@@ -660,6 +678,10 @@ final readonly class RetriexEffectiveConfigProvider
'context_usage' => [
'referential_terms' => $this->agentRunnerConfig->getShopQueryContextUsageReferentialTerms(),
],
'current_input_preservation' => [
'enabled' => $this->agentRunnerConfig->isShopQueryCurrentInputPreservationEnabled(),
'terms' => $this->agentRunnerConfig->getShopQueryCurrentInputPreservationTerms(),
],
'context_anchor_enrichment' => [
'enabled' => $this->agentRunnerConfig->isShopQueryContextAnchorEnrichmentEnabled(),
'max_query_terms' => $this->agentRunnerConfig->getShopQueryContextAnchorEnrichmentMaxQueryTerms(),
@@ -934,9 +956,6 @@ final readonly class RetriexEffectiveConfigProvider
return [
'stopwords' => $this->stopWordsConfig->getStopWords(),
'protected_terms' => $this->languageCleanupConfig->getProtectedTerms(),
'normalization' => [
'ascii_transliteration' => $this->languageCleanupConfig->getAsciiTransliterationMap(),
],
'cleanup_profile_names' => $this->languageCleanupConfig->getCleanupProfileNames(),
'cleanup_profiles' => $profiles,
];
@@ -1208,7 +1227,6 @@ final readonly class RetriexEffectiveConfigProvider
private function validateAgent(array $agent, array &$errors, array &$warnings): void
{
$this->validateStringListMap($agent['messages'] ?? [], 'agent.messages', $errors, $warnings);
$this->validateStringListMap($agent['followup_actions'] ?? [], 'agent.followup_actions', $errors, $warnings);
$this->validateStringListMap($agent['source_labels'] ?? [], 'agent.source_labels', $errors, $warnings);
$this->validateStringListMap($agent['html_templates'] ?? [], 'agent.html_templates', $errors, $warnings);
@@ -1226,9 +1244,6 @@ final readonly class RetriexEffectiveConfigProvider
$errors[] = 'agent.follow_up_context.commercial_table_follow_up.query_template_without_model must not be empty.';
}
$inputNormalization = is_array($agent['input_normalization'] ?? null) ? $agent['input_normalization'] : [];
$this->validateStringList($this->toList($inputNormalization['placeholder_outputs'] ?? []), 'agent.input_normalization.placeholder_outputs', $errors, $warnings);
$ragEvidence = is_array($agent['rag_evidence_guard'] ?? null) ? $agent['rag_evidence_guard'] : [];
$ragEvidenceCleanupProfile = $ragEvidence['cleanup_profile'] ?? null;
if (!is_string($ragEvidenceCleanupProfile) || trim($ragEvidenceCleanupProfile) === '') {
@@ -1255,6 +1270,17 @@ final readonly class RetriexEffectiveConfigProvider
$errors[] = 'agent.shop_prompt.meta_query_guard.cleanup_profile references unknown language cleanup profile: ' . $shopContextCleanupProfile . '.';
}
$currentInputPreservation = is_array($shopPrompt['current_input_preservation'] ?? null) ? $shopPrompt['current_input_preservation'] : [];
if (array_key_exists('enabled', $currentInputPreservation) && !is_bool($currentInputPreservation['enabled'])) {
$errors[] = 'agent.shop_prompt.current_input_preservation.enabled must be boolean.';
}
$this->validateStringList(
$this->toList($currentInputPreservation['terms'] ?? []),
'agent.shop_prompt.current_input_preservation.terms',
$errors,
$warnings
);
$this->validateStringListMap($agent['shop_query_optimizer'] ?? [], 'agent.shop_query_optimizer', $errors, $warnings);
$this->validateRegexPattern($agent['optimized_shop_query_prefix_pattern'] ?? null, 'agent.optimized_shop_query_prefix_pattern', $errors);