Class: Collavre::Orchestration::Arbiter
- Inherits:
-
Object
- Object
- Collavre::Orchestration::Arbiter
- Defined in:
- app/services/collavre/orchestration/arbiter.rb
Overview
Arbiter decides which agents will actually respond from the qualified candidates. This implements “floor control” - preventing multiple agents from responding simultaneously.
Strategies:
-
all: All candidates respond (original behavior)
-
primary_first: Primary agent responds, others only if primary unavailable
-
round_robin: Rotate between agents for each message
-
bid: Select agent based on relevance score (expertise matching)
Constant Summary collapse
- DEFAULT_CONFIDENCE_THRESHOLD =
Default confidence threshold for bid strategy
0.3
Instance Method Summary collapse
-
#initialize(context, policy_resolver: nil) ⇒ Arbiter
constructor
A new instance of Arbiter.
-
#select(candidates) ⇒ Array<User>
Select which agents will respond from the candidates.
Constructor Details
#initialize(context, policy_resolver: nil) ⇒ Arbiter
Returns a new instance of Arbiter.
17 18 19 20 |
# File 'app/services/collavre/orchestration/arbiter.rb', line 17 def initialize(context, policy_resolver: nil) @context = context @policy_resolver = policy_resolver || PolicyResolver.new(context) end |
Instance Method Details
#select(candidates) ⇒ Array<User>
Select which agents will respond from the candidates
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/collavre/orchestration/arbiter.rb', line 25 def select(candidates) return [] if candidates.empty? strategy = @policy_resolver.arbitration_strategy selected = apply_strategy(strategy, candidates) # Apply max_responders limit if set max = @policy_resolver.max_responders selected = selected.take(max) if max.present? && max.positive? selected end |