You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Motivation
<!-- Why is this change necessary? -->
# Content
<!-- Please include a summary of the change -->
# Testing
<!-- How was the change tested? -->
# Please check the following before marking your PR as ready for review
- [ ] I have added tests for my changes
- [ ] I have updated the documentation or added new documentation as
needed
---------
Co-authored-by: kopekC <[email protected]>
type_errors.append(f"'{field_name}' must be a string, not a JSON object or dictionary")
167
+
elif"str_type"inerror_type:
168
+
type_errors.append(f"'{field_name}' must be a string")
169
+
elif"int_type"inerror_type:
170
+
type_errors.append(f"'{field_name}' must be an integer")
171
+
elif"bool_type"inerror_type:
172
+
type_errors.append(f"'{field_name}' must be a boolean")
173
+
elif"list_type"inerror_type:
174
+
type_errors.append(f"'{field_name}' must be a list")
175
+
else:
176
+
type_errors.append(f"'{field_name}' has an incorrect type")
177
+
178
+
iftype_errors:
179
+
errors_str="\n- ".join(type_errors)
180
+
returnf"Error using {tool_name} tool: Parameter type errors:\n- {errors_str}\n\nYou provided: {tool_input}\n\nPlease try again with the correct parameter types."
181
+
182
+
# Get missing fields by comparing tool input with required fields
183
+
missing_fields= []
184
+
iftoolandhasattr(tool, "args_schema"):
185
+
try:
186
+
# Get the schema class
187
+
schema_cls=tool.args_schema
188
+
189
+
# Handle Pydantic v2 (preferred) or v1 with warning suppression
f"Error using {tool_name} tool: Missing required parameter(s): {fields_str}\n\nYou provided: {tool_input}\n{tool_docs}{example}\nPlease try again with all required parameters."
266
+
)
267
+
268
+
# Common error patterns for specific tools (as fallback)
269
+
iftool_name=="create_file":
270
+
if"content"notintool_input:
271
+
return (
272
+
"Error: When using the create_file tool, you must provide both 'filepath' and 'content' parameters.\n"
273
+
"The 'content' parameter is missing. Please try again with both parameters.\n\n"
returnf"Error: Could not identify the tool you're trying to use.\n\nAvailable tools:\n{available_tools}\n\nPlease use one of the available tools with the correct parameters."
311
+
312
+
# For other types of errors
313
+
returnf"Error executing tool: {error_msg}\n\nPlease check your tool usage and try again with the correct parameters."
0 commit comments