Skip to content

Commit 509bee1

Browse files
committed
Remove silent exception swallowing in agent adapter gather_config()
The except Exception: pass blocks in smolagents, langgraph, and llamaindex adapters silently swallowed errors during config collection, causing loss of configuration data (including model_id) with no visibility into why. For research code, truthfulness matters more than uptime — let errors propagate so they can be diagnosed and fixed. Also simplified SmolAgentAdapter.gather_config() by removing the manual fallback that partially reconstructed config when to_dict() failed, since the error now surfaces directly.
1 parent 95941d9 commit 509bee1

3 files changed

Lines changed: 17 additions & 42 deletions

File tree

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

0 commit comments

Comments
 (0)