Skip to content

Commit 9563ec1

Browse files
committed
support better para check
1 parent 5a47710 commit 9563ec1

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "tooluniverse"
7-
version = "1.0.15.2"
7+
version = "1.0.15.3"
88
description = "A comprehensive collection of scientific tools for Agentic AI, offering integration with the ToolUniverse SDK and MCP Server to support advanced scientific workflows."
99
authors = [
1010
{ name = "Shanghua Gao", email = "shanghuagao@gmail.com" }

src/tooluniverse/base_tool.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,29 @@ def validate_parameters(self, arguments: Dict[str, Any]) -> Optional[ToolError]:
194194
jsonschema.validate(filtered_arguments, schema)
195195
return None
196196
except jsonschema.ValidationError as e:
197+
# Create a more agent-friendly error message
198+
error_msg = f"Parameter validation failed for '{e.path[-1] if e.path else 'root'}': {e.message}"
199+
200+
# Add type hint if it's a type error
201+
if e.validator == "type":
202+
error_msg += (
203+
f". Expected {e.validator_value}, got {type(e.instance).__name__}."
204+
)
205+
206+
# Add allowed values if it's an enum error
207+
if e.validator == "enum":
208+
error_msg += f". Allowed values: {e.validator_value}."
209+
197210
return ToolValidationError(
198-
f"Parameter validation failed: {e.message}",
211+
error_msg,
199212
details={
200213
"validation_error": str(e),
201214
"path": list(e.absolute_path) if e.absolute_path else [],
202215
"schema": schema,
216+
"parameter": str(e.path[-1]) if e.path else "root",
217+
"expected": str(e.validator_value)
218+
if hasattr(e, "validator_value")
219+
else None,
203220
},
204221
)
205222
except Exception as e:

src/tooluniverse/tools/execute_tool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def execute_tool(
1515
stream_callback: Optional[Callable[[str], None]] = None,
1616
use_cache: bool = False,
1717
validate: bool = True,
18+
**kwargs: Any,
1819
) -> dict[str, Any]:
1920
"""
2021
Execute a ToolUniverse tool directly with custom arguments. This is the primary way to run any to...

0 commit comments

Comments
 (0)