from agno.tools import tool@tooldef get_weather(city: str) -> str: """Get the weather for a city. Args: city: The name of the city """ return f"Weather in {city}: Sunny"
The decorator automatically generates JSON schemas from:
Type hints: Function parameter and return types
Docstrings: Parameter descriptions using Google, NumPy, or Sphinx style
Default values: Optional parameters vs required
@tooldef search_web(query: str, max_results: int = 10) -> str: """Search the web for information. Args: query: The search query max_results: Maximum number of results to return """ # Implementation return "Search results"
@tool(requires_confirmation=True, show_result=True)def delete_file(path: str) -> str: """Delete a file from disk. Args: path: Path to the file to delete """ os.remove(path) return f"Deleted {path}"
@toolasync def fetch_data(url: str) -> str: """Fetch data from a URL. Args: url: The URL to fetch """ async with aiohttp.ClientSession() as session: async with session.get(url) as resp: return await resp.text()