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
30 changes: 28 additions & 2 deletions spoon_ai/agents/custom_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CustomAgent(ToolCallAgent):
max_steps: int = 10
tool_choice: str = "auto"

avaliable_tools: ToolManager = Field(default_factory=lambda: ToolManager([]))
available_tools: ToolManager = Field(default_factory=lambda: ToolManager([]))
llm: ChatBot = Field(default_factory=lambda: ChatBot())

# MCP integration configuration
Expand Down Expand Up @@ -201,6 +201,7 @@ def get_tool_info(self) -> Dict[str, Dict[str, Any]]:
logger.error(f"Error getting tool info: {e}")

return tool_info


def validate_tools(self) -> Dict[str, Any]:
"""
Expand Down Expand Up @@ -297,4 +298,29 @@ def clear(self):
except Exception as e:
logger.error(f"Error checking tools after clear: {e}")

logger.debug(f"CustomAgent '{self.name}' fully cleared and validated")
logger.debug(f"CustomAgent '{self.name}' fully cleared and validated")


@property
def avaliable_tools(self):
"""Backward compatibility property for misspelled field name."""
import warnings
warnings.warn(
"avaliable_tools is deprecated and will be removed in v2.0. "
"Use available_tools instead.",
DeprecationWarning,
stacklevel=2
)
return self.available_tools

@avaliable_tools.setter
def avaliable_tools(self, value):
"""Backward compatibility setter for misspelled field name."""
import warnings
warnings.warn(
"avaliable_tools is deprecated and will be removed in v2.0. "
"Use available_tools instead.",
DeprecationWarning,
stacklevel=2
)
self.available_tools = value
27 changes: 26 additions & 1 deletion spoon_ai/agents/spoon_react.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SpoonReactAI(ToolCallAgent):
max_steps: int = 10
tool_choice: str = "auto"

avaliable_tools: ToolManager = Field(default_factory=lambda: ToolManager([]))
available_tools: ToolManager = Field(default_factory=lambda: ToolManager([]))
llm: ChatBot = Field(default_factory=create_configured_chatbot)

mcp_transport: Union[str, WSTransport, SSETransport, PythonStdioTransport, NpxStdioTransport, FastMCPTransport, FastMCPStdioTransport, UvxStdioTransport] = Field(default="mcp_server")
Expand All @@ -71,3 +71,28 @@ async def initialize(self, __context: Any = None):
if __context and hasattr(__context, 'report_error'):
await __context.report_error(e)
raise


@property
def avaliable_tools(self):
"""Backward compatibility property for misspelled field name."""
import warnings
warnings.warn(
"avaliable_tools is deprecated and will be removed in v2.0. "
"Use available_tools instead.",
DeprecationWarning,
stacklevel=2
)
return self.available_tools

@avaliable_tools.setter
def avaliable_tools(self, value):
"""Backward compatibility setter for misspelled field name."""
import warnings
warnings.warn(
"avaliable_tools is deprecated and will be removed in v2.0. "
"Use available_tools instead.",
DeprecationWarning,
stacklevel=2
)
self.available_tools = value
43 changes: 43 additions & 0 deletions tests/test_typo_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import pytest
import warnings
from spoon_ai.agents.custom_agent import CustomAgent
from spoon_ai.tools import ToolManager
from unittest.mock import Mock

class TestTypoFix:
"""Test the available_tools typo fix and backward compatibility"""

def test_available_tools_field_exists(self):
"""Test that available_tools field works correctly"""
agent = CustomAgent(name="test", llm=Mock())
assert hasattr(agent, 'available_tools')
assert isinstance(agent.available_tools, ToolManager)

def test_backward_compatibility_property(self):
"""Test that avaliable_tools still works with deprecation warning"""
agent = CustomAgent(name="test", llm=Mock())

# Should raise deprecation warning
with pytest.warns(DeprecationWarning, match="avaliable_tools is deprecated"):
tools = agent.avaliable_tools

assert tools is agent.available_tools

def test_backward_compatibility_setter(self):
"""Test that avaliable_tools setter works with deprecation warning"""
agent = CustomAgent(name="test", llm=Mock())
new_tools = ToolManager([])

# Should raise deprecation warning
with pytest.warns(DeprecationWarning, match="avaliable_tools is deprecated"):
agent.avaliable_tools = new_tools

assert agent.available_tools is new_tools

def test_no_regression_in_functionality(self):
"""Test that core functionality still works"""
agent = CustomAgent(name="test", llm=Mock())

# Test that tool operations work
assert agent.list_tools() == []
assert isinstance(agent.get_tool_info(), dict)