@@ -108,12 +108,20 @@ def adapt(
108
108
109
109
# Extract and resolve outputSchema if present (only if structured_output=True)
110
110
output_schema = None
111
- if self .structured_output and hasattr (mcp_tool , 'outputSchema' ) and mcp_tool .outputSchema :
111
+ if (
112
+ self .structured_output
113
+ and hasattr (mcp_tool , "outputSchema" )
114
+ and mcp_tool .outputSchema
115
+ ):
112
116
try :
113
117
output_schema = jsonref .replace_refs (mcp_tool .outputSchema )
114
118
except Exception as e :
115
- logger .warning (f"Failed to resolve outputSchema for tool { mcp_tool .name } : { e } " )
116
- output_schema = mcp_tool .outputSchema # Use unresolved schema as fallback
119
+ logger .warning (
120
+ f"Failed to resolve outputSchema for tool { mcp_tool .name } : { e } "
121
+ )
122
+ output_schema = (
123
+ mcp_tool .outputSchema
124
+ ) # Use unresolved schema as fallback
117
125
118
126
# Always use "object" output_type for maximum flexibility
119
127
# Smolagents will handle type detection at runtime
@@ -138,7 +146,9 @@ def __init__(
138
146
self .is_initialized = True
139
147
self .skip_forward_signature_validation = True
140
148
141
- def forward (self , * args , ** kwargs ) -> Union [str , "PILImage" , "torch.Tensor" , Any ]:
149
+ def forward (
150
+ self , * args , ** kwargs
151
+ ) -> Union [str , "PILImage" , "torch.Tensor" , Any ]:
142
152
if len (args ) > 0 :
143
153
if len (args ) == 1 and isinstance (args [0 ], dict ) and not kwargs :
144
154
mcp_output = func (args [0 ])
@@ -156,7 +166,10 @@ def forward(self, *args, **kwargs) -> Union[str, "PILImage", "torch.Tensor", Any
156
166
# Handle structured features if enabled
157
167
if self .structured_output :
158
168
# Prioritize structuredContent if available
159
- if hasattr (mcp_output , 'structuredContent' ) and mcp_output .structuredContent is not None :
169
+ if (
170
+ hasattr (mcp_output , "structuredContent" )
171
+ and mcp_output .structuredContent is not None
172
+ ):
160
173
return mcp_output .structuredContent
161
174
162
175
# Handle multiple content warning (unified for both modes)
0 commit comments