fix shop research intent fix 2

This commit is contained in:
team 1
2026-04-27 17:15:38 +02:00
parent 8c40153745
commit 0f75a9208b
4 changed files with 28 additions and 6 deletions

View File

@@ -143,6 +143,12 @@ parameters:
- im - im
- in - in
- nach - nach
- danach
- dazu
- damit
- dafür
- dafuer
- hierzu
- den - den
- die - die
- das - das

View File

@@ -127,6 +127,7 @@ final readonly class AgentRunner
commerceHistoryContext: $commerceHistoryContext, commerceHistoryContext: $commerceHistoryContext,
userId: $userId userId: $userId
); );
$usedResolvedOptimizedShopQuery = $optimizedShopQuery !== '' && $shopSearchQuery === $optimizedShopQuery;
if ($shopSearchQuery === '') { if ($shopSearchQuery === '') {
$this->agentLogger->info('Commerce search skipped because no concrete shop query could be resolved', [ $this->agentLogger->info('Commerce search skipped because no concrete shop query could be resolved', [
@@ -157,7 +158,7 @@ final readonly class AgentRunner
$this->buildShopSearchMetaMessage( $this->buildShopSearchMetaMessage(
query: $shopQueryPreview->searchText !== '' ? $shopQueryPreview->searchText : $shopSearchQuery, query: $shopQueryPreview->searchText !== '' ? $shopQueryPreview->searchText : $shopSearchQuery,
commerceIntent: $commerceIntent, commerceIntent: $commerceIntent,
usedOptimizedQuery: $optimizedShopQuery !== '', usedOptimizedQuery: $usedResolvedOptimizedShopQuery,
originalQuery: $shopSearchQuery originalQuery: $shopSearchQuery
), ),
'meta' 'meta'
@@ -166,7 +167,7 @@ final readonly class AgentRunner
$this->agentLogger->info('Commerce search prepared', [ $this->agentLogger->info('Commerce search prepared', [
'userId' => $userId, 'userId' => $userId,
'commerceIntent' => $commerceIntent, 'commerceIntent' => $commerceIntent,
'usedOptimizedShopQuery' => $optimizedShopQuery !== '', 'usedOptimizedShopQuery' => $usedResolvedOptimizedShopQuery,
'optimizedShopQuery' => $optimizedShopQuery, 'optimizedShopQuery' => $optimizedShopQuery,
'shopSearchQuery' => $shopSearchQuery, 'shopSearchQuery' => $shopSearchQuery,
'hasCommerceHistoryContext' => $commerceHistoryContext !== '', 'hasCommerceHistoryContext' => $commerceHistoryContext !== '',
@@ -482,7 +483,7 @@ final readonly class AgentRunner
return []; return [];
} }
if (preg_match_all('/^Question:\s*(.+)$/mi', $history, $matches) !== 1) { if (preg_match_all('/^Question:\s*(.+)$/mi', $history, $matches) < 1) {
return []; return [];
} }
@@ -723,11 +724,20 @@ final readonly class AgentRunner
string $commerceHistoryContext, string $commerceHistoryContext,
string $userId string $userId
): string { ): 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; return $optimizedShopQuery;
} }
if (!$this->isMetaOnlyShopQuery($prompt)) { if (!$promptIsMetaOnly) {
return $prompt; return $prompt;
} }
@@ -837,7 +847,7 @@ final readonly class AgentRunner
$value = mb_strtolower(trim($value), 'UTF-8'); $value = mb_strtolower(trim($value), 'UTF-8');
$value = str_replace(['-', '/', '_'], ' ', $value); $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 []; return [];
} }

View File

@@ -415,6 +415,12 @@ final class AgentRunnerConfig
'im', 'im',
'in', 'in',
'nach', 'nach',
'danach',
'dazu',
'damit',
'dafür',
'dafuer',
'hierzu',
'den', 'den',
'die', 'die',
'das', 'das',