diff --git a/evoagentx/tools/database_faiss.py b/evoagentx/tools/database_faiss.py index 6eeee8ca..a18604ce 100644 --- a/evoagentx/tools/database_faiss.py +++ b/evoagentx/tools/database_faiss.py @@ -802,7 +802,8 @@ class FaissInsertTool(Tool): inputs: Dict[str, Dict[str, Any]] = { "documents": { "type": "array", - "description": "Array of documents to insert. Can be strings (text content or file paths), or objects with 'text', 'metadata', and 'doc_id' fields. If a string contains path separators or file extensions and the file exists, it will be treated as a file path and its content will be read and processed." + "description": "Array of documents to insert. Can be strings (text content or file paths), or objects with 'text', 'metadata', and 'doc_id' fields. If a string contains path separators or file extensions and the file exists, it will be treated as a file path and its content will be read and processed.", + "items": {"anyOf": [{"type": "string"}, {"type": "object"}]} }, "corpus_id": { "type": "string", diff --git a/evoagentx/tools/gmail_tools.py b/evoagentx/tools/gmail_tools.py index 113bb2de..7be4f835 100644 --- a/evoagentx/tools/gmail_tools.py +++ b/evoagentx/tools/gmail_tools.py @@ -656,7 +656,8 @@ class ReadMessagesTool(Tool): }, "label_ids": { "type": "array", - "description": "List of label IDs to filter by (e.g., ['INBOX', 'UNREAD']). Optional." + "description": "List of label IDs to filter by (e.g., ['INBOX', 'UNREAD']). Optional.", + "items": {"type": "string"} }, "max_results": { "type": "integer", @@ -722,7 +723,8 @@ class SearchMessagesTool(Tool): }, "label_ids": { "type": "array", - "description": "Optional list of label IDs to filter by (e.g., ['INBOX', 'UNREAD'])." + "description": "Optional list of label IDs to filter by (e.g., ['INBOX', 'UNREAD']).", + "items": {"type": "string"} }, "max_results": { "type": "integer", @@ -774,7 +776,8 @@ class ReadThreadsTool(Tool): }, "label_ids": { "type": "array", - "description": "List of label IDs to filter by (e.g., ['INBOX', 'UNREAD']). Optional." + "description": "List of label IDs to filter by (e.g., ['INBOX', 'UNREAD']). Optional.", + "items": {"type": "string"} }, "max_results": { "type": "integer", @@ -814,7 +817,8 @@ class TrashMessagesTool(Tool): inputs: Dict[str, Dict[str, str]] = { "message_ids": { "type": "array", - "description": "Optional list of message IDs to move to Trash (as returned by read/search tools)." + "description": "Optional list of message IDs to move to Trash (as returned by read/search tools).", + "items": {"type": "string"} }, "query": { "type": "string", @@ -922,10 +926,14 @@ class ModifyLabelsTool(Tool): "Label names will be resolved to system ids or created if custom." ) inputs: Dict[str, Dict[str, str]] = { - "message_ids": {"type": "array", "description": "List of message IDs to modify"}, + "message_ids": {"type": "array", "description": "List of message IDs to modify", "items": {"type": "string"}}, "query": {"type": "string", "description": "Gmail query to select messages (optional)"}, - "add_labels": {"type": "array", "description": "List of label names to add (e.g., ['STARRED','MyLabel'])"}, - "remove_labels": {"type": "array", "description": "List of label names to remove"}, + "add_labels": { + "type": "array", + "description": "List of label names to add (e.g., ['STARRED','MyLabel'])", + "items": {"type": "string"} + }, + "remove_labels": {"type": "array", "description": "List of label names to remove", "items": {"type": "string"}}, "max_results": {"type": "integer", "description": "Max messages when using query (default 50)"} } required: List[str] = [] @@ -998,7 +1006,8 @@ class CreateDraftTool(Tool): }, "attachments": { "type": "array", - "description": "List of file paths to attach to the draft (optional, e.g., ['/path/to/file1.pdf', '/path/to/file2.txt'])" + "description": "List of file paths to attach to the draft (optional, e.g., ['/path/to/file1.pdf', '/path/to/file2.txt'])", + "items": {"type": "string"} } } required: List[str] = ["to", "subject", "body"] @@ -1292,7 +1301,8 @@ class UpdateDraftTool(Tool): }, "attachments": { "type": "array", - "description": "List of file paths to attach to the draft (optional)" + "description": "List of file paths to attach to the draft (optional)", + "items": {"type": "string"} } } required: List[str] = ["draft_id"] diff --git a/evoagentx/tools/image_tools/openai_image_tools/image_edit.py b/evoagentx/tools/image_tools/openai_image_tools/image_edit.py index 3219be01..91165a56 100644 --- a/evoagentx/tools/image_tools/openai_image_tools/image_edit.py +++ b/evoagentx/tools/image_tools/openai_image_tools/image_edit.py @@ -10,7 +10,7 @@ class OpenAIImageEditTool(Tool): inputs: Dict[str, Dict[str, str]] = { "prompt": {"type": "string", "description": "Edit instruction. Required."}, - "images": {"type": "array", "description": "Image path(s) png/webp/jpg <50MB. Required. Single string accepted and normalized to array."}, + "images": {"type": "array", "description": "Image path(s) png/webp/jpg <50MB. Required. Single string accepted and normalized to array.", "items": {"type": "string"}}, "mask_path": {"type": "string", "description": "Optional PNG mask path (same size as first image)."}, "size": {"type": "string", "description": "1024x1024 | 1536x1024 | 1024x1536 | auto"}, "n": {"type": "integer", "description": "1-10"}, diff --git a/evoagentx/tools/image_tools/openrouter_image_tools/image_generation.py b/evoagentx/tools/image_tools/openrouter_image_tools/image_generation.py index 91849d83..b5a7eb39 100644 --- a/evoagentx/tools/image_tools/openrouter_image_tools/image_generation.py +++ b/evoagentx/tools/image_tools/openrouter_image_tools/image_generation.py @@ -14,8 +14,8 @@ class OpenRouterImageGenerationEditTool(Tool): inputs: Dict[str, Dict] = { "prompt": {"type": "string", "description": "Text prompt."}, - "image_urls": {"type": "array", "description": "Remote image URLs (optional)."}, - "image_paths": {"type": "array", "description": "Local image paths (optional)."}, + "image_urls": {"type": "array", "description": "Remote image URLs (optional).", "items": {"type": "string"}}, + "image_paths": {"type": "array", "description": "Local image paths (optional).", "items": {"type": "string"}}, "model": {"type": "string", "description": "OpenRouter model id.", "default": "google/gemini-2.5-flash-image-preview"}, "api_key": {"type": "string", "description": "OpenRouter API key (fallback to env OPENROUTER_API_KEY)."}, "save_path": {"type": "string", "description": "Directory to save images (when data URLs).", "default": "./openrouter_images"}, diff --git a/evoagentx/tools/request_arxiv.py b/evoagentx/tools/request_arxiv.py index 41c779ef..b2ba67b0 100644 --- a/evoagentx/tools/request_arxiv.py +++ b/evoagentx/tools/request_arxiv.py @@ -277,7 +277,8 @@ class ArxivSearchTool(Tool): }, "id_list": { "type": "array", - "description": "List of arXiv IDs to retrieve (e.g., ['1706.03762', '1810.04805'])" + "description": "List of arXiv IDs to retrieve (e.g., ['1706.03762', '1810.04805'])", + "items": {"type": "string"} }, "max_results": { "type": "integer", diff --git a/tests/src/tools/test_tool_array_schemas.py b/tests/src/tools/test_tool_array_schemas.py new file mode 100644 index 00000000..232ee4fa --- /dev/null +++ b/tests/src/tools/test_tool_array_schemas.py @@ -0,0 +1,44 @@ +import ast +from pathlib import Path + +TOOLS_DIR = Path(__file__).resolve().parents[3] / "evoagentx" / "tools" + + +def _inputs_literals(tree): + for node in ast.walk(tree): + if isinstance(node, ast.AnnAssign): + targets = [node.target] + elif isinstance(node, ast.Assign): + targets = node.targets + else: + continue + if any(isinstance(t, ast.Name) and t.id == "inputs" for t in targets) and isinstance(node.value, ast.Dict): + yield node.value + + +def _arrays_without_items(schema, path): + if not isinstance(schema, dict): + return + if schema.get("type") == "array" and "items" not in schema: + yield path + for key, value in schema.items(): + if isinstance(value, dict): + yield from _arrays_without_items(value, f"{path}.{key}") + elif isinstance(value, list): + for index, item in enumerate(value): + yield from _arrays_without_items(item, f"{path}.{key}[{index}]") + + +def test_tool_array_inputs_declare_items(): + missing = [] + for source in sorted(TOOLS_DIR.rglob("*.py")): + tree = ast.parse(source.read_text(encoding="utf-8")) + for literal in _inputs_literals(tree): + try: + inputs = ast.literal_eval(literal) + except ValueError: + continue + for name, schema in inputs.items(): + for path in _arrays_without_items(schema, name): + missing.append(f"{source.relative_to(TOOLS_DIR)}:{literal.lineno} {path}") + assert not missing, "array parameters without 'items' (OpenAI rejects these):\n" + "\n".join(missing)