[BUGF] Fix reasoning agent model compatibility and HierarchicalSwarm error propagation - #1213
Closed
Steve-Dusty wants to merge 4 commits into
Closed
[BUGF] Fix reasoning agent model compatibility and HierarchicalSwarm error propagation#1213Steve-Dusty wants to merge 4 commits into
Steve-Dusty wants to merge 4 commits into
Conversation
| ReasoningAgentRouter, | ||
| ) | ||
|
|
||
| from dotenv import load_dotenv |
Check failure
Code scanning / Pyre
Undefined import Error test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR addresses two unrelated issues:
gpt-4o
Problem 1: Reasoning Agent Model Not Found
Error
litellm.exceptions.NotFoundError: AnthropicException - {
"type": "error",
"error": {
"type": "not_found_error",
"message": "model: claude-3-5-sonnet-20240620"
}
}
Root Cause: The default reasoning_model_name parameter used claude-3-5-sonnet-20240620, which is not available or has
been deprecated by Anthropic.
Location:
Solution
Changed default reasoning model to gpt-4o, which is stable and widely available:
Before
reasoning_model_name: Optional[str] = "claude-3-5-sonnet-20240620"
After
reasoning_model_name: Optional[str] = "gpt-4o"
Rationale:
Problem 2: HierarchicalSwarm Exception Swallowing
Error
def test_hierarchical_swarm_error_handling():
try:
HierarchicalSwarm(agents=[])
assert False, "Should have raised ValueError for empty agents list"
except ValueError:
pass # Expected
Test FAILED - ValueError was never raised
Root Cause: The reliability_checks() method caught exceptions for logging but failed to re-raise them:
def reliability_checks(self):
try:
if not self.agents or len(self.agents) == 0:
raise ValueError("No agents found...")
except Exception as e:
logger.error(f"[ERROR] Reliability checks failed: {str(e)}")
# Missing: raise ← Exception swallowed here!
Location: swarms/structs/hiearchical_swarm.py:917
Solution
Added raise statement to propagate the exception after logging:
except Exception as e:
logger.error(f"[ERROR] Reliability checks failed: {str(e)}")
raise # ← Added this line
Impact:
Changes Made
Files Modified
Testing
Reasoning Agent Fix:
Before: NotFoundError from Anthropic
After: Successfully uses gpt-4o model
HierarchicalSwarm Fix:
$ pytest test_hierarchical_swarm.py::test_hierarchical_swarm_error_handling -v
test_hierarchical_swarm_error_handling PASSED ✅
Breaking Changes
None. Both fixes are backwards compatible:
Benefits
Checklist
📚 Documentation preview 📚: https://swarms--1213.org.readthedocs.build/en/1213/