Class: Legion::CLI::Chat::Tools::SpawnAgent

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/legion/cli/chat/tools/spawn_agent.rb

Instance Method Summary collapse

Instance Method Details

#execute(task:, model: nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/legion/cli/chat/tools/spawn_agent.rb', line 17

def execute(task:, model: nil)
  require 'legion/cli/chat/subagent'
  result = Subagent.spawn(
    task:        task,
    model:       model,
    on_complete: method(:notify_complete)
  )

  if result[:error]
    "Subagent error: #{result[:error]}"
  else
    "Subagent #{result[:id]} started: #{task}"
  end
rescue StandardError => e
  Legion::Logging.warn("SpawnAgent#execute failed: #{e.message}") if defined?(Legion::Logging)
  "Error spawning subagent: #{e.message}"
end