Class: Legion::CLI::Chat::Tools::SpawnAgent
Class Method Summary
collapse
Methods inherited from Tools::Base
deferred, deferred?, description, error_response, extension, handle_exception, input_schema, log, mcp_category, mcp_tier, runner, sticky, tags, text_response, tool_name, trigger_words
Class Method Details
.call(task:, model: nil) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/legion/cli/chat/tools/spawn_agent.rb', line 23
def self.call(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
|
.notify_complete(agent_id, result) ⇒ Object
41
42
43
44
45
|
# File 'lib/legion/cli/chat/tools/spawn_agent.rb', line 41
def self.notify_complete(agent_id, result)
output = result[:output] || result[:error] || 'No output'
warn "\n [subagent #{agent_id}] Complete: #{output.lines.first&.strip}"
end
|