refactor: убрать onAnswer из хуков агента

- onAnswer дублировал возврат Agent::ask() — убран
- остались onStep, onToolStart, onToolEnd, shouldStop
- пример 14 печатает ответ из возврата ask()
- 116 тестов
This commit is contained in:
rsgrinko committed 2026-11-13 00:38:11 +03:00
1 parent 4c25111c0e
commit 204d449519
7 files changed
+15 -27

No files matched your search

+1 -3
View File
@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace AiSdk;
/**
* Диалог с моделью и цикл вызова инструментов.
*
@@ -173,7 +172,6 @@ final class Agent
$text = $result->text !== '' ? $result->text : '(модель вернула пустой ответ)';
$this->messages[] = ['role' => 'assistant', 'content' => $text];
$this->hooks?->answer($text);
return $text;
}
@@ -341,7 +339,6 @@ final class Agent
{
$text = $result !== '' ? $result : '(модель завершила работу без результата)';
$this->messages[] = ['role' => 'assistant', 'content' => $text];
$this->hooks?->answer($text);
return $text;
}
@@ -468,3 +465,4 @@ final class Agent
*/
}