Skip to content
Merged
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
2 changes: 1 addition & 1 deletion agentstack/_tools/neon/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"dependencies": [
"neon-api>=0.1.5",
"psycopg2-binary"
"psycopg2-binary==2.9.10"
],
"tools": ["create_database", "execute_sql_ddl", "run_sql_query"],
"cta": "Create an API key at https://www.neon.tech"
Expand Down
20 changes: 17 additions & 3 deletions tests/test_tool_config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
import unittest
import re
from pathlib import Path
from agentstack._tools import ToolConfig, get_all_tool_paths, get_all_tool_names

BASE_PATH = Path(__file__).parent


class ToolConfigTest(unittest.TestCase):
def test_minimal_json(self):
config = ToolConfig.from_json(BASE_PATH / "fixtures/tool_config_min.json")
Expand All @@ -29,6 +29,20 @@ def test_maximal_json(self):
assert config.post_install == "install.sh"
assert config.post_remove == "remove.sh"

def test_dependency_versions(self):
"""Test that all dependencies specify a version constraint."""
for tool_name in get_all_tool_names():
config = ToolConfig.from_tool_name(tool_name)

if hasattr(config, 'dependencies') and config.dependencies:
version_pattern = r'[><=~!]=|[@><=~!]'
for dep in config.dependencies:
if not re.search(version_pattern, dep):
raise AssertionError(
f"Dependency '{dep}' in {config.name} does not specify a version constraint. "
"All dependencies must include version specifications."
)

def test_all_json_configs_from_tool_name(self):
for tool_name in get_all_tool_names():
config = ToolConfig.from_tool_name(tool_name)
Expand All @@ -41,8 +55,8 @@ def test_all_json_configs_from_tool_path(self):
config = ToolConfig.from_json(f"{path}/config.json")
except json.decoder.JSONDecodeError:
raise Exception(
f"Failed to decode tool json at {path}. Does your tool config fit the required formatting? https://github.com/AgentOps-AI/AgentStack/blob/main/agentstack/tools/~README.md"
f"Failed to decode tool json at {path}. Does your tool config fit the required formatting? "
"https://github.com/AgentOps-AI/AgentStack/blob/main/agentstack/tools/~README.md"
)

assert config.name == path.stem
# We can assume that pydantic validation caught any other issues