1 parent 06413eb commit 16afc75Copy full SHA for 16afc75
1 file changed
swarms/structs/agent.py
@@ -3096,10 +3096,19 @@ def _default_max_tokens(self) -> int:
3096
Returns:
3097
int: The maximum number of output tokens for the model. Returns 16000 if undetermined.
3098
"""
3099
- return (
3100
- get_model_info(self.model_name).get("max_output_tokens")
3101
- or 16000
3102
- )
+ # get_model_info raises for an unmapped model id rather than
+ # returning an empty mapping, so an unknown, custom or self-hosted
+ # model would otherwise take down Agent.__init__. The sibling
+ # _default_context_length guards the same call the same way.
3103
+ try:
3104
+ return (
3105
+ get_model_info(self.model_name).get(
3106
+ "max_output_tokens"
3107
+ )
3108
+ or 16000
3109
3110
+ except Exception:
3111
+ return 16000
3112
3113
def reliability_check(self):
3114
0 commit comments