에이전트 계획 수립
class PlanningAgent {
async plan(task: string) {
const plan = await this.llm.generate(`
Task: ${task}
Available tools: ${this.tools.map(t => t.name).join(", ")}
Create a step-by-step plan.
`);
return this.parsePlan(plan);
}
async executeWithReflection(plan: Step[]) {
for (const step of plan) {
const result = await this.executeTool(step);
const reflection = await this.reflect(step, result);
if (reflection.needsRevision) {
return this.replan(reflection.reason);
}
}
}
}ReAct 패턴
Reasoning + Acting. 생각하고, 행동하고, 관찰하는 루프를 반복합니다.
댓글 0