ai_agents_test-1.0.0-alpha1/src/Plugin/AgentsParameterTest/NotSetTest.php
src/Plugin/AgentsParameterTest/NotSetTest.php
<?php
declare(strict_types=1);
namespace Drupal\ai_agents_test\Plugin\AgentsParameterTest;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\ai\Service\FunctionCalling\ExecutableFunctionCallInterface;
use Drupal\ai_agents_test\AgentsParameterTestPluginBase;
use Drupal\ai_agents_test\Attribute\AgentsParameterTest;
/**
* Plugin implementation of the agents_parameter_test.
*/
#[AgentsParameterTest(
id: 'not_set',
label: new TranslatableMarkup('Not Set'),
description: new TranslatableMarkup('Is the value not set.'),
)]
final class NotSetTest extends AgentsParameterTestPluginBase {
/**
* {@inheritdoc}
*/
public function runTest(ExecutableFunctionCallInterface $tool, array $values, string $parameter_name, array $rule, string $tool_name): void {
$actual = $values[$parameter_name];
if ($actual) {
$error_message = sprintf('Parameter %s for tool %s was set.', $parameter_name, $tool->getToolsId());
$this->errors[] = $error_message;
$this->details[] = $this->createDetailedResultRow(
result: FALSE,
object: "Tool: $tool_name, Parameter: $parameter_name",
type: 'Not Set',
expected: '',
actual: $actual,
details: $error_message,
);
}
else {
$this->details[] = $this->createDetailedResultRow(
result: TRUE,
object: "Tool: $tool_name, Parameter: $parameter_name",
type: 'Not Set',
expected: '',
actual: '',
details: '',
);
}
}
}
