Class: Collavre::AiAgent::A2aDispatcher
- Inherits:
-
Object
- Object
- Collavre::AiAgent::A2aDispatcher
- Defined in:
- app/services/collavre/ai_agent/a2a_dispatcher.rb
Overview
Handles agent-to-agent (A2A) orchestration dispatch. Detects mentioned agents, records interactions for loop prevention, and dispatches system events for downstream processing.
Instance Method Summary collapse
-
#dispatch ⇒ Object
Dispatch A2A events if the response mentions any AI agents.
-
#initialize(agent:, reply_comment:, context:) ⇒ A2aDispatcher
constructor
A new instance of A2aDispatcher.
Constructor Details
#initialize(agent:, reply_comment:, context:) ⇒ A2aDispatcher
Returns a new instance of A2aDispatcher.
9 10 11 12 13 |
# File 'app/services/collavre/ai_agent/a2a_dispatcher.rb', line 9 def initialize(agent:, reply_comment:, context:) @agent = agent @reply_comment = reply_comment @context = context end |
Instance Method Details
#dispatch ⇒ Object
Dispatch A2A events if the response mentions any AI agents
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/services/collavre/ai_agent/a2a_dispatcher.rb', line 16 def dispatch return unless @reply_comment&.content.present? mentioned_agents = find_mentioned_agents return if mentioned_agents.empty? creative = @reply_comment.creative record_interactions(mentioned_agents, creative) dispatch_event(creative) rescue StandardError => e Rails.logger.error("[AiAgent::A2aDispatcher] A2A dispatch failed: #{e.}") end |