Class: AIA::TaskDecomposer

Inherits:
Object
  • Object
show all
Includes:
ContentExtractor
Defined in:
lib/aia/task_decomposer.rb

Instance Method Summary collapse

Methods included from ContentExtractor

#extract_content, #extract_network_content, #format_duration, #output_to_file, #present_result, #store_results_in_memory

Constructor Details

#initialize(lead_robot:, ui_presenter:) ⇒ TaskDecomposer

Returns a new instance of TaskDecomposer.



15
16
17
18
# File 'lib/aia/task_decomposer.rb', line 15

def initialize(lead_robot:, ui_presenter:)
  @lead = lead_robot
  @ui   = ui_presenter
end

Instance Method Details

#decompose(prompt, robot_names) ⇒ Array<Hash>

Decompose a prompt into subtasks assigned to specific robots.

Parameters:

  • prompt (String)

    the original user prompt

  • robot_names (Array<String>)

    available robot names

Returns:

  • (Array<Hash>)

    steps with :title and :assignee, or [] on failure



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/aia/task_decomposer.rb', line 25

def decompose(prompt, robot_names)
  @ui.display_info("#{@lead.name} analyzing and delegating...")

  plan_result = @lead.run(<<~PROMPT, mcp: :none, tools: :none)
    Break this request into subtasks. Assign each to the most
    appropriate team member based on their model capabilities.

    Team: #{robot_names.join(', ')}
    Request: #{prompt}

    Respond with ONLY a JSON array:
    [{"title": "subtask description", "assignee": "robot_name"}]
  PROMPT

  reply = extract_content(plan_result)
  parse_plan(reply, robot_names)
end