This commit is contained in:
team 1
2026-05-10 10:53:05 +02:00
parent 5c09e17f9c
commit b2bd9f89e0
7 changed files with 278 additions and 3 deletions

View File

@@ -5648,6 +5648,10 @@ final readonly class AgentRunner
continue;
}
if (!$this->shouldShowRenderedFollowUpAction($item, $context, $actionPrompt)) {
continue;
}
$key = mb_strtolower($label . "\n" . $actionPrompt, 'UTF-8');
if (isset($seenActionKeys[$key])) {
continue;
@@ -5702,6 +5706,37 @@ final readonly class AgentRunner
return true;
}
/**
* @param array<string, mixed> $item
* @param array{shop_query:string, shop_price_query:string, answer_has_price:bool, answer_text:string, answer_anchor:string, answer_detail_score:int, role_counts:array<string,int>} $context
*/
private function shouldShowRenderedFollowUpAction(array $item, array $context, string $renderedPrompt): bool
{
if (!$this->optionalFollowUpActionBool($item, 'hide_when_material_query_matches_current')) {
return true;
}
$currentQuery = $this->normalizeShopQueryForComparison($context['shop_query']);
if ($currentQuery === '') {
return true;
}
$materialQueryTemplate = isset($item['material_query_template']) && is_scalar($item['material_query_template'])
? trim((string) $item['material_query_template'])
: '';
$materialQuery = $materialQueryTemplate !== ''
? $this->renderFollowUpActionPrompt($materialQueryTemplate, $context)
: $renderedPrompt;
$materialQuery = $this->normalizeShopQueryForComparison($materialQuery);
if ($materialQuery === '') {
return true;
}
return $materialQuery !== $currentQuery;
}
private function optionalFollowUpActionBool(array $item, string $key): bool
{
if (!array_key_exists($key, $item)) {