Skip to content

Commit db68df9

Browse files
authored
Remove silent exception swallowing in agent adapter gather_config() (#53)
Simplified SmolAgentAdapter.gather_config() by removing the manual fallback that caused silent failure of config collection.
1 parent 95941d9 commit db68df9

File tree

5 files changed

+24
-42
lines changed

5 files changed

+24
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- Fixed `MessageHistory.to_list()` returning a reference to the internal list instead of a copy, causing simulator logs to contain future conversation messages that hadn't occurred at the time of logging. (PR: #PR_NUMBER_PLACEHOLDER)
1515

16+
**Interface**
17+
18+
- Agent adapter `gather_config()` in smolagents, langgraph, and llamaindex no longer silently swallows exceptions, ensuring config collection errors are visible instead of producing incomplete configuration data. (PR: #53)
19+
1620
### Added
1721

1822
**Core**

maseval/interface/agents/langgraph.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,15 @@ def gather_config(self) -> dict[str, Any]:
218218
safe_config["configurable"] = {"has_thread_id": "thread_id" in value if isinstance(value, dict) else False}
219219
langgraph_config["config"] = safe_config
220220

221-
# Try to get graph structure info
221+
# Get graph structure info — let errors propagate so they're
222+
# visible in the registry's error output.
222223
if hasattr(self.agent, "get_graph"):
223-
try:
224-
graph = self.agent.get_graph()
225-
if graph:
226-
langgraph_config["graph_info"] = {
227-
"num_nodes": len(graph.nodes) if hasattr(graph, "nodes") else None,
228-
"num_edges": len(graph.edges) if hasattr(graph, "edges") else None,
229-
}
230-
except Exception:
231-
pass
224+
graph = self.agent.get_graph()
225+
if graph:
226+
langgraph_config["graph_info"] = {
227+
"num_nodes": len(graph.nodes) if hasattr(graph, "nodes") else None,
228+
"num_edges": len(graph.edges) if hasattr(graph, "edges") else None,
229+
}
232230

233231
if langgraph_config:
234232
base_config["langgraph_config"] = langgraph_config

maseval/interface/agents/llamaindex.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,12 @@ def gather_config(self) -> Dict[str, Any]:
211211
for tool in tools
212212
]
213213

214-
# Check if it's a workflow
214+
# Check if it's a workflow — let errors propagate so they're
215+
# visible in the registry's error output.
215216
if hasattr(self.agent, "get_config"):
216-
try:
217-
workflow_config = self.agent.get_config()
218-
if workflow_config:
219-
llamaindex_config["workflow_config"] = workflow_config
220-
except Exception:
221-
pass
217+
workflow_config = self.agent.get_config()
218+
if workflow_config:
219+
llamaindex_config["workflow_config"] = workflow_config
222220

223221
if llamaindex_config:
224222
base_config["llamaindex_config"] = llamaindex_config

maseval/interface/agents/smolagents.py

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -425,32 +425,11 @@ def gather_config(self) -> dict[str, Any]:
425425
base_config = super().gather_config()
426426
_check_smolagents_installed()
427427

428-
# Get comprehensive config from smolagents' native to_dict() method
429-
smolagents_config = {}
428+
# Get comprehensive config from smolagents' native to_dict() method.
429+
# No try/except: if to_dict() exists but fails, the error should
430+
# propagate so it's visible in the registry's error output.
430431
if hasattr(self.agent, "to_dict"):
431-
try:
432-
smolagents_config = self.agent.to_dict()
433-
except Exception:
434-
# If to_dict fails, fall back to basic attributes
435-
pass
436-
437-
# Add smolagents-specific config if available
438-
if smolagents_config:
439-
base_config["smolagents_config"] = smolagents_config
440-
else:
441-
# Fallback: manually collect common attributes
442-
config_attrs = {}
443-
for attr in ["max_steps", "planning_interval", "name", "description"]:
444-
if hasattr(self.agent, attr):
445-
config_attrs[attr] = getattr(self.agent, attr)
446-
447-
# CodeAgent-specific attributes
448-
for attr in ["additional_authorized_imports", "authorized_imports", "executor_type"]:
449-
if hasattr(self.agent, attr):
450-
config_attrs[attr] = getattr(self.agent, attr)
451-
452-
if config_attrs:
453-
base_config["smolagents_config"] = config_attrs
432+
base_config["smolagents_config"] = self.agent.to_dict()
454433

455434
return base_config
456435

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ def __init__(self, responses: Optional[List[str]] = None):
217217
self._responses = responses or ["mock response"]
218218
self._call_index = 0
219219

220+
def to_dict(self) -> dict:
221+
return {"class": self.__class__.__name__, "model_id": self.model_id}
222+
220223
def __call__(self, *args, **kwargs):
221224
return self.generate(*args, **kwargs)
222225

0 commit comments

Comments
 (0)