Class: RubynCode::Tools::SpawnAgent
- Defined in:
- lib/rubyn_code/tools/spawn_agent.rb
Constant Summary collapse
- TOOL_NAME =
'spawn_agent'- DESCRIPTION =
'Spawn an isolated sub-agent to handle a task. The sub-agent gets its own ' \ "fresh context, works independently, and returns only a summary. Use 'explore' " \ "type for research/reading, 'worker' type for writing code/files. The sub-agent " \ 'shares the filesystem but not your conversation.'
- PARAMETERS =
{ prompt: { type: :string, description: 'The task for the sub-agent to perform', required: true }, agent_type: { type: :string, description: "Type of agent: 'explore' (read-only) or 'worker' (full write access). Default: explore", required: false, enum: %w[explore worker] } }.freeze
- RISK_LEVEL =
:execute
Constants inherited from Base
Instance Attribute Summary collapse
-
#llm_client ⇒ Object
writeonly
These get injected by the executor or the REPL.
-
#on_status ⇒ Object
writeonly
These get injected by the executor or the REPL.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
description, #initialize, parameters, requires_confirmation?, risk_level, #safe_path, summarize, to_schema, tool_name, #truncate
Constructor Details
This class inherits a constructor from RubynCode::Tools::Base
Instance Attribute Details
#llm_client=(value) ⇒ Object (writeonly)
These get injected by the executor or the REPL
30 31 32 |
# File 'lib/rubyn_code/tools/spawn_agent.rb', line 30 def llm_client=(value) @llm_client = value end |
#on_status=(value) ⇒ Object (writeonly)
These get injected by the executor or the REPL
30 31 32 |
# File 'lib/rubyn_code/tools/spawn_agent.rb', line 30 def on_status=(value) @on_status = value end |
Instance Method Details
#execute(prompt:, agent_type: 'explore') ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rubyn_code/tools/spawn_agent.rb', line 32 def execute(prompt:, agent_type: 'explore') type = agent_type.to_sym callback = @on_status || method(:default_status) @tool_count = 0 callback.call(:started, "Spawning #{type} agent...") tools = tools_for_type(type) result, hit_limit = run_sub_agent( prompt: prompt, tools: tools, type: type, callback: callback ) callback.call(:done, "Agent finished (#{@tool_count} tool calls).") summary = RubynCode::SubAgents::Summarizer.call(result, max_length: 3000) format_agent_result(type, summary, hit_limit) end |