Use this file to discover all available pages before exploring further.
Tools are functions that agents can call to perform actions beyond text generation. They enable agents to search the web, query databases, call APIs, manipulate files, and more.
Klisk uses type hints to automatically generate the JSON schema that tells the agent how to call your tool:
@toolasync def search(query: str, max_results: int = 10) -> list[dict]: """Search for information. Args: query: The search query string max_results: Maximum number of results to return """ # Implementation return results
The agent receives:
{ "name": "search", "description": "Search for information.", "parameters": { "type": "object", "properties": { "query": {"type": "string", "description": "The search query string"}, "max_results": {"type": "integer", "description": "Maximum number of results to return", "default": 10} }, "required": ["query"] }}
The docstring becomes the tool’s description that the agent sees. Write clear descriptions that explain:
What the tool does
When to use it
What parameters mean
What the return value contains
@toolasync def analyze_sentiment(text: str, language: str = "en") -> dict: """Analyze the emotional sentiment of text. Use this to determine if text is positive, negative, or neutral. Supports multiple languages. Args: text: The text to analyze language: ISO language code (default: "en") Returns: Dict with 'sentiment' (positive/negative/neutral) and 'confidence' (0-1) """ # Implementation return {"sentiment": "positive", "confidence": 0.92}
@tool(name_override="custom_name")async def my_function(x: str) -> str: """This tool will be registered as 'custom_name' instead of 'my_function'.""" return x
All parameters supported by the OpenAI Agents SDK @function_tool are available.
from klisk import toolimport aiohttp@toolasync def fetch_user(user_id: int) -> dict: """Fetch user data from the API. Args: user_id: The numeric user ID Returns: Dict containing user profile data """ async with aiohttp.ClientSession() as session: async with session.get(f"https://api.example.com/users/{user_id}") as resp: return await resp.json()@toolasync def analyze_data(data: list[float], method: str = "mean") -> float: """Analyze a list of numbers. Args: data: List of numeric values method: Analysis method - "mean", "median", or "sum" Returns: The computed statistic """ if method == "mean": return sum(data) / len(data) elif method == "median": sorted_data = sorted(data) n = len(sorted_data) return sorted_data[n // 2] if n % 2 else (sorted_data[n//2-1] + sorted_data[n//2]) / 2 elif method == "sum": return sum(data) else: raise ValueError(f"Unknown method: {method}")
src/main.py:
from klisk import define_agent, get_toolsimport toolsagent = define_agent( name="DataAssistant", instructions="Help users fetch and analyze data.", model="gpt-5.2", tools=get_tools("fetch_user", "analyze_data"),)