Class: RCrewAI::Planning
- Inherits:
-
Object
- Object
- RCrewAI::Planning
- Defined in:
- lib/rcrewai/planning.rb
Overview
Runs a single planning pass over a crew's tasks before execution. Asks an LLM to draft a short, concrete plan for each task and folds that plan into the task's description, so the executing agent starts with a game plan.
Mirrors CrewAI's planning=True. Best-effort: if the planner errors or
returns unparseable output, execution proceeds with the original tasks.
Instance Method Summary collapse
-
#initialize(crew, llm: nil, logger: nil) ⇒ Planning
constructor
A new instance of Planning.
- #plan! ⇒ Object
Constructor Details
#initialize(crew, llm: nil, logger: nil) ⇒ Planning
Returns a new instance of Planning.
14 15 16 17 18 |
# File 'lib/rcrewai/planning.rb', line 14 def initialize(crew, llm: nil, logger: nil) @crew = crew @llm = llm || LLMClient.for_provider @logger = logger end |
Instance Method Details
#plan! ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rcrewai/planning.rb', line 20 def plan! return if @crew.tasks.empty? plans = request_plans return if plans.nil? || plans.empty? @crew.tasks.each do |task| step = plans[task.name] || plans[task.name.to_s] task.enrich_description("Plan: #{step}") if step end rescue StandardError => e @logger&.warn("Planning pass failed, continuing without a plan: #{e.}") nil end |