Class: RailsAi::Agents::CoordinatorAgent

Inherits:
BaseAgent
  • Object
show all
Defined in:
lib/rails_ai/agents/specialized_agents.rb

Overview

Coordinator Agent - Specialized in managing and coordinating other agents

Instance Attribute Summary

Attributes inherited from BaseAgent

#active_tasks, #capabilities, #completed_tasks, #created_at, #failed_tasks, #last_activity, #memory, #name, #role, #state

Instance Method Summary collapse

Methods inherited from BaseAgent

#accept_delegated_task, #assign_task, #can_handle_task?, #collaborate_with, #complete_task, #decide_next_action, #delegate_task, #fail_task, #forget, #get_messages, #has_capability?, #health_check, #pause!, #recall, #receive_message, #remember, #resume!, #send_message, #start!, #status, #stop!, #think

Constructor Details

#initialize(name: "CoordinatorAgent", **opts) ⇒ CoordinatorAgent

Returns a new instance of CoordinatorAgent.



290
291
292
293
294
295
296
297
# File 'lib/rails_ai/agents/specialized_agents.rb', line 290

def initialize(name: "CoordinatorAgent", **opts)
  super(
    name: name,
    role: "Coordination Specialist",
    capabilities: [:coordination, :project_management, :resource_allocation, :conflict_resolution],
    **opts
  )
end

Instance Method Details

#coordinate_task(task, available_agents) ⇒ Object



299
300
301
302
303
304
305
306
307
# File 'lib/rails_ai/agents/specialized_agents.rb', line 299

def coordinate_task(task, available_agents)
  return "[stubbed] Coordination plan for: #{task[:description]}" if RailsAi.config.stub_responses

  coordination_prompt = build_coordination_prompt(task, available_agents)
  result = think(coordination_prompt, context: { task: task, agents: available_agents })
  
  remember("coordination_#{task[:id]}", result, importance: :high)
  result
end

#optimize_workflow(workflow_description, constraints) ⇒ Object



319
320
321
322
323
324
325
326
327
# File 'lib/rails_ai/agents/specialized_agents.rb', line 319

def optimize_workflow(workflow_description, constraints)
  return "[stubbed] Workflow optimization for: #{workflow_description}" if RailsAi.config.stub_responses

  optimization_prompt = build_optimization_prompt(workflow_description, constraints)
  result = think(optimization_prompt, context: { workflow: workflow_description, constraints: constraints })
  
  remember("workflow_optimization_#{Time.now.to_i}", result, importance: :normal)
  result
end

#resolve_conflict(conflict_description, involved_agents) ⇒ Object



309
310
311
312
313
314
315
316
317
# File 'lib/rails_ai/agents/specialized_agents.rb', line 309

def resolve_conflict(conflict_description, involved_agents)
  return "[stubbed] Conflict resolution for: #{conflict_description}" if RailsAi.config.stub_responses

  conflict_prompt = build_conflict_resolution_prompt(conflict_description, involved_agents)
  result = think(conflict_prompt, context: { conflict: conflict_description, agents: involved_agents })
  
  remember("conflict_resolution_#{Time.now.to_i}", result, importance: :high)
  result
end