Class: XAeonAgents::Agents::ReviewResolverAgent
- Inherits:
-
ComposableAgents::Agent
- Object
- ComposableAgents::Agent
- XAeonAgents::Agents::ReviewResolverAgent
- Includes:
- XAeonAgents::AgentDefaults
- Defined in:
- lib/x_aeon_agents/agents/review_resolver_agent.rb
Overview
Agent responsible for addressing Pull Request review comments directed at X-Aeon Agents
Instance Method Summary collapse
-
#initialize(**agent_params) ⇒ ReviewResolverAgent
constructor
Constructor.
-
#input_artifacts_contracts ⇒ Hash{Symbol => Object}
Define input artifacts contracts.
-
#run(pull_request_number: nil) ⇒ Hash{Symbol => Object}
Execute the agent to address Pull Request review comments.
Methods included from XAeonAgents::AgentDefaults
#new_agent, prepended, singleton_session_id
Constructor Details
#initialize(**agent_params) ⇒ ReviewResolverAgent
Constructor
17 18 19 |
# File 'lib/x_aeon_agents/agents/review_resolver_agent.rb', line 17 def initialize(**agent_params) super(name: 'ReviewResolver', **agent_params) end |
Instance Method Details
#input_artifacts_contracts ⇒ Hash{Symbol => Object}
Define input artifacts contracts
10 11 12 |
# File 'lib/x_aeon_agents/agents/review_resolver_agent.rb', line 10 def input_artifacts_contracts { pull_request_number: 'The Pull Request number to address comments for' } end |
#run(pull_request_number: nil) ⇒ Hash{Symbol => Object}
Execute the agent to address Pull Request review comments
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/x_aeon_agents/agents/review_resolver_agent.rb', line 26 def run(pull_request_number: nil) raise 'Unable to find the Github repository' unless Helpers.github_repo pull_request_number = resolve_pull_request_number(pull_request_number) # Gather comments is always executed (never cached) so that new comments are detected on # every run, even when resuming a session where development/replies are cached. @artifacts[:conversations] = gather_comments(pull_request_number) if @artifacts[:conversations].empty? log_debug "No PR reviews conversations found that need X-Aeon Agents input for PR ##{pull_request_number}" else log_debug "Found #{@artifacts[:conversations].size} PR reviews conversations that need X-Aeon Agents input for PR ##{pull_request_number}" @artifacts[:open_comments_to_agents] = @artifacts[:conversations].map do |conversation| conversation.select { |comment| comment['need_ai_reply'] } end.flatten(1) log_debug "Found #{@artifacts[:open_comments_to_agents].size} PR review comments that need X-Aeon Agents to reply for PR ##{pull_request_number}" step(:extract_requirements) do pr = Helpers.github.pull_request(Helpers.github_repo, pull_request_number) feedback_analyst_agent = new_agent(FeedbackAnalystAgent, **Config.['free_complex_planning']) step_agent( feedback_analyst_agent, pr_description: <<~EO_DESCRIPTION.strip, pr_files_diffs: Helpers.git.diff("#{pr.base.sha}...#{pr.head.sha}").to_s, user_instructions: { ordered_list: [ <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION Extract clear, actionable requirements from the comments in an artifact named `#{feedback_analyst_agent.artifact_ref(:requirements)}` - If no implementation is required (e.g., comments are just questions), output "No requirements" EO_INSTRUCTION ] } ) @artifacts[:requirements] = 'No requirements' if @artifacts[:requirements].strip.downcase == 'no requirements' end if @artifacts[:requirements] == 'No requirements' @artifacts[:plan] = 'No implementation plan' @artifacts[:files_diffs] = 'No changes' else step_agent(new_agent(DeveloperAgent, commit: true, pull_request: true)) end @artifacts[:open_comments_to_agents].each.with_index do |comment, comment_idx| step(:"reply_to_comment_#{comment_idx}") do review_responder_agent = new_agent(ReviewResponderAgent, **Config.['free_complex_planning']) step_agent( review_responder_agent, open_comment_for_reply: comment, user_instructions: { ordered_list: [ <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION, <<~EO_INSTRUCTION Generate a professional, helpful reply that addresses the comment appropriately, in the artifact named `#{review_responder_agent.artifact_ref(:reply)}` - If requirements were implemented, explain what was done and how it addresses the comment. - If no requirements existed, provide a helpful response explaining the situation. EO_INSTRUCTION ] } ) full_reply = "[X-Aeon Agent #{review_responder_agent.full_name}] - #{@artifacts[:reply]}" @artifacts[:replies] ||= [] @artifacts[:replies] << { 'comment_id' => comment['comment_id'], 'reply' => full_reply } Helpers.github.create_pull_request_comment_reply(Helpers.github_repo, pull_request_number, full_reply, comment['comment_id']) end end end @artifacts end |