diff --git a/config/retriex/agent.yaml b/config/retriex/agent.yaml index df9d875..b8530b6 100644 --- a/config/retriex/agent.yaml +++ b/config/retriex/agent.yaml @@ -143,6 +143,12 @@ parameters: - im - in - nach + - danach + - dazu + - damit + - dafür + - dafuer + - hierzu - den - die - das diff --git a/rag-inprogress-shop-advisory-intent-fix-patch-only.zip b/rag-inprogress-shop-advisory-intent-fix-patch-only.zip deleted file mode 100644 index f9711a3..0000000 Binary files a/rag-inprogress-shop-advisory-intent-fix-patch-only.zip and /dev/null differ diff --git a/src/Agent/AgentRunner.php b/src/Agent/AgentRunner.php index c44d48a..9c4bb69 100644 --- a/src/Agent/AgentRunner.php +++ b/src/Agent/AgentRunner.php @@ -127,6 +127,7 @@ final readonly class AgentRunner commerceHistoryContext: $commerceHistoryContext, userId: $userId ); + $usedResolvedOptimizedShopQuery = $optimizedShopQuery !== '' && $shopSearchQuery === $optimizedShopQuery; if ($shopSearchQuery === '') { $this->agentLogger->info('Commerce search skipped because no concrete shop query could be resolved', [ @@ -157,7 +158,7 @@ final readonly class AgentRunner $this->buildShopSearchMetaMessage( query: $shopQueryPreview->searchText !== '' ? $shopQueryPreview->searchText : $shopSearchQuery, commerceIntent: $commerceIntent, - usedOptimizedQuery: $optimizedShopQuery !== '', + usedOptimizedQuery: $usedResolvedOptimizedShopQuery, originalQuery: $shopSearchQuery ), 'meta' @@ -166,7 +167,7 @@ final readonly class AgentRunner $this->agentLogger->info('Commerce search prepared', [ 'userId' => $userId, 'commerceIntent' => $commerceIntent, - 'usedOptimizedShopQuery' => $optimizedShopQuery !== '', + 'usedOptimizedShopQuery' => $usedResolvedOptimizedShopQuery, 'optimizedShopQuery' => $optimizedShopQuery, 'shopSearchQuery' => $shopSearchQuery, 'hasCommerceHistoryContext' => $commerceHistoryContext !== '', @@ -482,7 +483,7 @@ final readonly class AgentRunner return []; } - if (preg_match_all('/^Question:\s*(.+)$/mi', $history, $matches) !== 1) { + if (preg_match_all('/^Question:\s*(.+)$/mi', $history, $matches) < 1) { return []; } @@ -723,11 +724,20 @@ final readonly class AgentRunner string $commerceHistoryContext, string $userId ): string { - if ($optimizedShopQuery !== '' && !$this->isMetaOnlyShopQuery($optimizedShopQuery)) { + $promptIsMetaOnly = $this->isMetaOnlyShopQuery($prompt); + + /** + * A pure meta command such as "suche im shop" has no own product + * semantics. In that case the LLM optimizer must not be trusted as the + * primary source because it can copy instruction terms from the query + * prompt itself (for example "Shopware 6"). Resolve meta commands + * deterministically from the recent conversation instead. + */ + if (!$promptIsMetaOnly && $optimizedShopQuery !== '' && !$this->isMetaOnlyShopQuery($optimizedShopQuery)) { return $optimizedShopQuery; } - if (!$this->isMetaOnlyShopQuery($prompt)) { + if (!$promptIsMetaOnly) { return $prompt; } @@ -837,7 +847,7 @@ final readonly class AgentRunner $value = mb_strtolower(trim($value), 'UTF-8'); $value = str_replace(['-', '/', '_'], ' ', $value); - if (preg_match_all('/\d+(?:[,.]\d+)?|[\p{L}\p{N}]+/u', $value, $matches) !== 1) { + if (preg_match_all('/\d+(?:[,.]\d+)?|[\p{L}\p{N}]+/u', $value, $matches) < 1) { return []; } diff --git a/src/Config/AgentRunnerConfig.php b/src/Config/AgentRunnerConfig.php index 6c4919c..f0dcb6c 100644 --- a/src/Config/AgentRunnerConfig.php +++ b/src/Config/AgentRunnerConfig.php @@ -415,6 +415,12 @@ final class AgentRunnerConfig 'im', 'in', 'nach', + 'danach', + 'dazu', + 'damit', + 'dafür', + 'dafuer', + 'hierzu', 'den', 'die', 'das',