Class: ActiveAgent::Team

Inherits:
Object
  • Object
show all
Defined in:
lib/active_agent/team.rb

Overview

Orchestrates multiple agents and tasks in sequential or hierarchical processes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(agents:, tasks:, process: :sequential) ⇒ Team

Returns a new instance of Team.



8
9
10
11
12
# File 'lib/active_agent/team.rb', line 8

def initialize(agents:, tasks:, process: :sequential)
  @agents = agents
  @tasks = tasks
  @process = process
end

Instance Attribute Details

#agentsObject (readonly)

Returns the value of attribute agents.



6
7
8
# File 'lib/active_agent/team.rb', line 6

def agents
  @agents
end

#processObject (readonly)

Returns the value of attribute process.



6
7
8
# File 'lib/active_agent/team.rb', line 6

def process
  @process
end

#tasksObject (readonly)

Returns the value of attribute tasks.



6
7
8
# File 'lib/active_agent/team.rb', line 6

def tasks
  @tasks
end

Instance Method Details

#kickoffObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_agent/team.rb', line 14

def kickoff
  accumulated_context = []

  @tasks.each_with_index do |task, index|
    context_str = accumulated_context.last
    say_verbose "🤖 Task #{index + 1}/#{@tasks.size} [#{task.agent.role}]: #{task.description[0..80]}..."

    result = task.execute(context: context_str)
    accumulated_context << result
  end

  accumulated_context.last
end