onEvent 回调,以便在运行期间接收结构化的生命周期事件。
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
实时观察 PHP Agent 的运行、模型轮次、工具、暂停和完成事件。
onEvent 回调,以便在运行期间接收结构化的生命周期事件。
$result = $agent->run(
input: $prompt,
client: $client,
onEvent: function (array $event): void {
$logger->info("agent event", [
"type" => $event["type"],
"run_id" => $event["run_id"],
"details" => $event["details"] ?? [],
]);
}
);