<?php
require 'examples/boot.php';
require_once dirname(__DIR__).'/Support.php';
use Cognesy\Agents\Drivers\Testing\ScenarioStep;
use Cognesy\Agents\Enums\ExecutionStatus;
use Cognesy\Tell\Tell;
use Cognesy\Tell\TellRequest;
use Cognesy\Tell\Testing\TellTestFactory;
$project = TellHarnessExample::project();
try {
$result = Tell::testing($project, 'deterministic answer')->run(
TellRequest::prompt('This prompt never leaves the PHP process.'),
);
$failure = TellTestFactory::steps(
ScenarioStep::error('expected failure'),
)->open($project)->run(
TellRequest::prompt('Exercise a controlled terminal failure.'),
);
echo $result->text()."\n";
echo 'Failure status: '.$failure->status()?->value."\n";
assert($result->isCompleted());
assert(trim($result->text()) === 'deterministic answer');
assert($failure->status() === ExecutionStatus::Failed);
} finally {
TellHarnessExample::remove($project);
}