Class: Roast::Workflow::AgentStep
- Defined in:
- lib/roast/workflow/agent_step.rb
Instance Attribute Summary collapse
-
#continue ⇒ Object
Returns the value of attribute continue.
-
#include_context_summary ⇒ Object
Returns the value of attribute include_context_summary.
-
#resume ⇒ Object
Returns the value of attribute resume.
Attributes inherited from BaseStep
#available_tools, #coerce_to, #context_path, #json, #model, #name, #params, #print_response, #resource, #workflow
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(workflow, **kwargs) ⇒ AgentStep
constructor
A new instance of AgentStep.
Constructor Details
#initialize(workflow, **kwargs) ⇒ AgentStep
Returns a new instance of AgentStep.
8 9 10 11 12 13 |
# File 'lib/roast/workflow/agent_step.rb', line 8 def initialize(workflow, **kwargs) super # Set default values for agent-specific options @include_context_summary = false @continue = false end |
Instance Attribute Details
#continue ⇒ Object
Returns the value of attribute continue.
6 7 8 |
# File 'lib/roast/workflow/agent_step.rb', line 6 def continue @continue end |
#include_context_summary ⇒ Object
Returns the value of attribute include_context_summary.
6 7 8 |
# File 'lib/roast/workflow/agent_step.rb', line 6 def include_context_summary @include_context_summary end |
#resume ⇒ Object
Returns the value of attribute resume.
6 7 8 |
# File 'lib/roast/workflow/agent_step.rb', line 6 def resume @resume end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/roast/workflow/agent_step.rb', line 15 def call # For inline prompts (detected by plain text step names), use the name as the prompt # For file-based steps, load from the prompt file prompt_content = if name.plain_text? name.to_s else read_sidecar_prompt end # Handle resume option by copying session ID from referenced step if @resume.present? if (session_id = workflow..dig(@resume, "coding_agent_session_id")) workflow.[name.to_s] ||= {} workflow.[name.to_s]["coding_agent_session_id"] = session_id else Roast::Helpers::Logger.warn("Cannot resume from step '#{@resume}'. It does not have a coding_agent_session_id in its metadata.") end end # Use agent-specific configuration that was applied by StepLoader # If resume is set and a session_id is available, translate it to continue = { include_context_summary: @include_context_summary, continue: @continue || session_id.present?, # Use continue if either continue is set or a session_id to resume from is available } # Call CodingAgent directly with the prompt content and options result = Roast::Tools::CodingAgent.call(prompt_content, **) # Parse as JSON if json: true is configured (since CodingAgent response is not handled by Raix) if @json && result.is_a?(String) # Don't try to parse error messages as JSON if result.start_with?("Error running CodingAgent:") raise result end # Extract JSON from markdown code blocks anywhere in the response cleaned_result = extract_json_from_markdown(result) begin result = JSON.parse(cleaned_result) rescue JSON::ParserError => e raise "Failed to parse CodingAgent result as JSON: #{e.}" end end # Process output if print_response is enabled process_output(result, print_response:) # Apply coercion if configured apply_coercion(result) end |