This commit is contained in:
team 1
2026-05-12 08:38:16 +02:00
parent 3d0092b753
commit 03d4a1d7c3
5 changed files with 190 additions and 9 deletions

View File

@@ -4155,7 +4155,6 @@ final readonly class AgentRunner
$shopSearchQuery === ''
|| trim($commerceHistoryContext) === ''
|| $this->referenceAnchorExtractor->extractFirstProductModelAnchor($prompt) !== ''
|| $this->referenceAnchorExtractor->extractFirstProductModelAnchor($shopSearchQuery) !== ''
) {
return $shopSearchQuery;
}
@@ -4164,10 +4163,6 @@ final readonly class AgentRunner
return $shopSearchQuery;
}
if (!$this->isGenericMainDeviceReferentialShopQuery($shopSearchQuery)) {
return $shopSearchQuery;
}
$modelAnchor = $this->normalizeShopQueryAnchor(
$this->extractLatestHistoryProductModelAnchor($commerceHistoryContext)
);
@@ -4176,9 +4171,43 @@ final readonly class AgentRunner
return $shopSearchQuery;
}
return $this->queryAlreadyContainsAllAnchorTokens($shopSearchQuery, $modelAnchor)
? $shopSearchQuery
: $modelAnchor;
if ($this->queryAlreadyContainsAllAnchorTokens($shopSearchQuery, $modelAnchor)) {
return $this->containsMainDeviceFollowUpAccessoryResidual($shopSearchQuery, $modelAnchor)
? $modelAnchor
: $shopSearchQuery;
}
if (!$this->isGenericMainDeviceReferentialShopQuery($shopSearchQuery)) {
return $shopSearchQuery;
}
return $modelAnchor;
}
private function containsMainDeviceFollowUpAccessoryResidual(string $shopSearchQuery, string $modelAnchor): bool
{
$queryTokens = $this->tokenizeShopQueryCandidate($shopSearchQuery);
if ($queryTokens === []) {
return false;
}
$modelTokens = array_fill_keys($this->tokenizeShopQueryCandidate($modelAnchor), true);
$accessoryTokens = $this->buildShopQueryTokenSet($this->mergeUniqueStrings(
$this->agentRunnerConfig->getNoLlmAccessoryProductRoleKeywords(),
$this->agentRunnerConfig->getRequestedAccessoryCodeTerms()
));
foreach ($queryTokens as $token) {
if (isset($modelTokens[$token])) {
continue;
}
if (isset($accessoryTokens[$token]) || preg_match('/^\d{1,5}$/u', $token) === 1) {
return true;
}
}
return false;
}
private function guardWeakReferentialShopQueryWithHistoryModelAnchor(