Orchestrator-Workers
Оркестратор понимает задачу и вызывает специалистов-исполнителей.
Пример: реализация фичи
$response = agent(
instructions: 'You are a senior software architect. Analyze feature requests and use the available tools to implement each required file change.',
tools: [
new CreateFileAgentTool,
new ModifyFileAgentTool,
new DeleteFileAgentTool,
],
)->prompt("Implement this feature: {$featureRequest}");
Worker как Tool
class CreateFileAgentTool implements Tool
{
public function description(): Stringable|string
{
return 'Creates a new file with the appropriate code following best practices.';
}
public function schema(JsonSchema $schema): array
{
return [
'path' => $schema->string()->required(),
'content' => $schema->string()->required(),
];
}
public function handle(Request $request): string
{
$agent = agent(
instructions: 'Generate code for the file.',
);
$code = $agent->prompt($request->get('content'))->text;
file_put_contents($request->get('path'), $code);
return 'File created';
}
}
Когда использовать
- Сложные задачи с неизвестными шагами
- Динамическое планирование
- Модель сама решает, что вызывать
Итоги
- Оркестратор с tools-агентами
- Worker — вложенный агент
- Модель планирует сама
- Для сложных задач