Class: Observ::AgentSelectionService

Inherits:
Object
  • Object
show all
Defined in:
app/services/observ/agent_selection_service.rb

Overview

Service for providing agent selection options in the Observ domain

This service encapsulates the workflow of:

1. Discovering available agents (via Observ::AgentProvider)
2. Formatting them for UI presentation (via AgentSelectPresenter)

This service acts as the single entry point for agent selection, hiding the complexity of agent discovery and presentation from controllers and views.

Usage in controllers:

@agent_select_options = Observ::AgentSelectionService.options

Usage in helpers:

def agent_select_options
Observ::AgentSelectionService.options
end

Example output:

[
["Default Agent", ""],
["Deep Research", "DeepResearchAgent"],
["Simple Research", "ResearchAgent"]
]

Class Method Summary collapse

Class Method Details

.all_agentsArray<Class>

Returns all available agents (pass-through to Observ::AgentProvider)

Useful when you need the raw agent classes instead of formatted options. For most UI purposes, prefer using .options instead.

Returns:

  • (Array<Class>)

    array of agent classes implementing Observ::AgentSelectable



48
49
50
# File 'app/services/observ/agent_selection_service.rb', line 48

def all_agents
  Observ::AgentProvider.all_agents
end

.optionsArray<Array<String>>

Returns formatted select options for agent selection dropdown

This method orchestrates the entire agent selection workflow:

  • Discovers all available agents
  • Formats them for use in Rails select helpers

Returns:

  • (Array<Array<String>>)

    options array for Rails select helper Format: [["Display Name", "ClassName"], ...]



38
39
40
# File 'app/services/observ/agent_selection_service.rb', line 38

def options
  AgentSelectPresenter.options(agents: Observ::AgentProvider.all_agents)
end