patch 20p

This commit is contained in:
team 1
2026-05-03 17:12:57 +02:00
parent 814510456b
commit 1a24590863
5 changed files with 108 additions and 2 deletions

View File

@@ -1847,14 +1847,57 @@ final readonly class AgentRunner
$contextQuery = $this->buildContextFallbackShopQuery($question);
if ($contextQuery !== '' && !$this->isMetaOnlyShopQuery($contextQuery)) {
if ($this->isUsableContextualShopQuery($contextQuery)) {
return $contextQuery;
}
}
return $this->extractContextualShopSearchQueryFromHistoryTurns($commerceHistoryContext);
}
private function extractContextualShopSearchQueryFromHistoryTurns(string $commerceHistoryContext): string
{
foreach ($this->extractHistoryTurnsNewestFirst($commerceHistoryContext) as $turn) {
$question = $this->extractQuestionFromHistoryTurn($turn);
if ($question !== '' && !$this->isMetaOnlyShopQuery($question)) {
$contextQuery = $this->buildContextFallbackShopQuery($question);
if ($this->isUsableContextualShopQuery($contextQuery)) {
return $contextQuery;
}
}
$modelAnchor = $this->extractFirstTestomatModelAnchor($turn);
if ($modelAnchor !== '' && !$this->isMetaOnlyShopQuery($modelAnchor)) {
return mb_strtolower($modelAnchor, 'UTF-8');
}
}
return '';
}
private function extractQuestionFromHistoryTurn(string $turn): string
{
if (preg_match($this->agentRunnerConfig->getFollowUpHistoryQuestionPattern(), $turn, $matches) !== 1) {
return '';
}
return $this->sanitizeHistoryQuestion((string) ($matches[1] ?? ''));
}
private function isUsableContextualShopQuery(string $query): bool
{
$query = trim($query);
if ($query === '' || $this->isMetaOnlyShopQuery($query)) {
return false;
}
return $this->tokenizeShopQueryCandidate($query) !== [];
}
private function buildContextFallbackShopQuery(string $question): string
{
$tokens = $this->tokenizeShopQueryCandidate($question);