Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion evoagentx/tools/database_faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
28 changes: 19 additions & 9 deletions evoagentx/tools/gmail_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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] = []
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
3 changes: 2 additions & 1 deletion evoagentx/tools/request_arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 44 additions & 0 deletions tests/src/tools/test_tool_array_schemas.py
Original file line number Diff line number Diff line change
@@ -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)