Skip to content

Commit c27ac84

Browse files
jmchiltonclaude
andcommitted
Remove _disabled set, let registry be single source of truth for agent enabled state.
Disabled agents are simply not registered — no separate _disabled tracking, no redundant config re-reads in execute_agent or list_agents API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 61d5e16 commit c27ac84

4 files changed

Lines changed: 7 additions & 36 deletions

File tree

lib/galaxy/agents/registry.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def __init__(self):
2222
"""Initialize empty registry."""
2323
self._agents: dict[str, type[BaseGalaxyAgent]] = {}
2424
self._agent_metadata: dict[str, dict] = {}
25-
self._disabled: set[str] = set()
2625

2726
def register(
2827
self,
@@ -68,8 +67,6 @@ def get_agent(self, agent_type: str, deps: GalaxyAgentDependencies) -> BaseGalax
6867
Raises:
6968
ValueError: If agent type is not registered
7069
"""
71-
if agent_type in self._disabled:
72-
raise ValueError(f"Agent '{agent_type}' is disabled in configuration")
7370
if agent_type not in self._agents:
7471
available = list(self._agents.keys())
7572
raise ValueError(f"Unknown agent type: {agent_type}. Available: {available}")
@@ -149,11 +146,10 @@ def _is_enabled(agent_type: str) -> bool:
149146
return agent_cfg.get("enabled", True)
150147
return True
151148

152-
def _register_or_disable(registry: AgentRegistry, agent_type: str, agent_class: type[BaseGalaxyAgent]):
149+
def _register_if_enabled(registry: AgentRegistry, agent_type: str, agent_class: type[BaseGalaxyAgent]):
153150
if _is_enabled(agent_type):
154151
registry.register(agent_type, agent_class)
155152
else:
156-
registry._disabled.add(agent_type)
157153
log.info(f"Agent '{agent_type}' disabled by configuration, skipping registration")
158154

159155
registry = AgentRegistry()
@@ -163,8 +159,8 @@ def _register_or_disable(registry: AgentRegistry, agent_type: str, agent_class:
163159
log.warning("Router agent cannot be disabled — ignoring enabled: false")
164160
registry.register(AgentType.ROUTER, QueryRouterAgent)
165161

166-
_register_or_disable(registry, AgentType.ERROR_ANALYSIS, ErrorAnalysisAgent)
167-
_register_or_disable(registry, AgentType.CUSTOM_TOOL, CustomToolAgent)
168-
_register_or_disable(registry, AgentType.ORCHESTRATOR, WorkflowOrchestratorAgent)
169-
_register_or_disable(registry, AgentType.TOOL_RECOMMENDATION, ToolRecommendationAgent)
162+
_register_if_enabled(registry, AgentType.ERROR_ANALYSIS, ErrorAnalysisAgent)
163+
_register_if_enabled(registry, AgentType.CUSTOM_TOOL, CustomToolAgent)
164+
_register_if_enabled(registry, AgentType.ORCHESTRATOR, WorkflowOrchestratorAgent)
165+
_register_if_enabled(registry, AgentType.TOOL_RECOMMENDATION, ToolRecommendationAgent)
170166
return registry

lib/galaxy/managers/agents.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from galaxy.agents.registry import AgentRegistry
1111
from galaxy.agents.router import QueryRouterAgent
1212
from galaxy.config import GalaxyAppConfiguration
13-
from galaxy.exceptions import ConfigurationError
1413
from galaxy.managers.context import ProvidesUserContext
1514
from galaxy.managers.jobs import JobManager
1615
from galaxy.model import User
@@ -53,12 +52,6 @@ async def execute_agent(
5352
context: Optional[dict[str, Any]] = None,
5453
) -> AgentResponse:
5554
"""Execute a specific agent and return response."""
56-
# Guard: reject disabled agents before attempting execution
57-
inference_config = getattr(self.config, "inference_services", {}) or {}
58-
agent_cfg = inference_config.get(agent_type, {})
59-
if isinstance(agent_cfg, dict) and not agent_cfg.get("enabled", True):
60-
raise ConfigurationError(f"Agent '{agent_type}' is disabled in configuration")
61-
6255
deps = self.create_dependencies(trans, user)
6356

6457
if context is None:

lib/galaxy/webapps/galaxy/api/agents.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,7 @@ def list_agents(
5959
agents = []
6060
for agent_type in self.agent_service.list_agents():
6161
agent_info = self.agent_service.get_agent_info(agent_type)
62-
63-
# Disabled agents are already excluded from the registry,
64-
# but double-check inference_services config here
6562
agent_config = inference_config.get(agent_type, {})
66-
if isinstance(agent_config, dict) and not agent_config.get("enabled", True):
67-
continue
6863

6964
# Resolve model: agent-specific -> default -> global
7065
model = None

test/unit/app/test_agents.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
QueryRouterAgent,
4040
)
4141
from galaxy.agents.registry import build_default_registry
42-
from galaxy.managers.agents import AgentService
4342

4443
agent_registry = build_default_registry()
4544
from galaxy.agents.error_analysis import ErrorAnalysisResult
@@ -199,24 +198,12 @@ def test_build_registry_no_config_registers_all(self):
199198
registry = build_default_registry()
200199
assert len(registry.list_agents()) == 5
201200

202-
@pytest.mark.asyncio
203-
async def test_disabled_agent_execution_raises(self):
204-
"""Executing a disabled agent should raise ConfigurationError."""
205-
from galaxy.exceptions import ConfigurationError
206-
207-
config = mock.Mock()
208-
config.inference_services = {"custom_tool": {"enabled": False}}
209-
registry = build_default_registry(config)
210-
service = AgentService(config, mock.Mock(), registry)
211-
with pytest.raises(ConfigurationError, match="disabled"):
212-
await service.execute_agent("custom_tool", "test", self.mock_trans, self.mock_user)
213-
214201
def test_disabled_agent_registry_get_agent_raises(self):
215-
"""Registry.get_agent for a disabled agent gives a clear 'disabled' error."""
202+
"""Registry.get_agent for a disabled agent gives 'Unknown agent type' error."""
216203
config = mock.Mock()
217204
config.inference_services = {"custom_tool": {"enabled": False}}
218205
registry = build_default_registry(config)
219-
with pytest.raises(ValueError, match="disabled"):
206+
with pytest.raises(ValueError, match="Unknown agent type"):
220207
registry.get_agent("custom_tool", self.deps)
221208

222209
def test_agent_registry(self):

0 commit comments

Comments
 (0)