Tools Overview
opentine tools are plain Python functions. No decorators, no Pydantic models, no special base classes. If a function has type hints and a docstring, it's a valid tool.
How Tools Work
The tool_schema(fn) utility converts any function with type hints and a docstring into an OpenAI-style tool schema. It maps Python types to JSON Schema types: str, int, float, and bool.
1from opentine.tools import tool_schema
2from opentine.tools.web import search
3
4# Convert any typed function to an OpenAI-style tool schema
5schema = tool_schema(search)
6print(schema)
7# {
8# "type": "function",
9# "function": {
10# "name": "search",
11# "description": "Search the web...",
12# "parameters": {
13# "type": "object",
14# "properties": {
15# "query": {"type": "string", "description": "..."},
16# "max_results": {"type": "integer", "description": "..."}
17# },
18# "required": ["query"]
19# }
20# }
21# }
Built-in Tool Modules
opentine ships with four tool modules that cover the most common agent needs:
- Web & Search — Search the web, fetch pages, and get raw HTTP responses. Auto-selects search provider via environment variables.
- File System — Read, write, edit, and list files. Sandboxed to the current working directory by default.
- Shell & Python — Run shell commands with configurable allowlists and execute Python code in sandboxed subprocesses.
Passing Tools to an Agent
Pass any combination of built-in or custom tools to the Agent constructor. The agent will have access to all of them during execution.
1from opentine import Agent
2from opentine.models.anthropic import Anthropic
3from opentine.tools.web import search, fetch
4from opentine.tools.fs import read, write, ls
5from opentine.tools.shell import run
6from opentine.tools.python import execute
7
8agent = Agent(
9 model=Anthropic("claude-sonnet-4-20250514"),
10 tools=[search, fetch, read, write, ls, run, execute],
11)
Custom Tools
Any function with type hints and a Google-style docstring is a valid tool. The tool_schema() function extracts parameter descriptions from the Args section of the docstring.
1def get_weather(city: str, units: str = "celsius") -> str:
2 """Get the current weather for a city.
3
4 Args:
5 city: The city name to look up.
6 units: Temperature units — celsius or fahrenheit.
7 """
8 # Your implementation here
9 return f"Weather in {city}: 22 {units}"
10
11# Pass it directly to an Agent — tool_schema() is called automatically
12agent = Agent(
13 model=Anthropic("claude-sonnet-4-20250514"),
14 tools=[get_weather],
15)
Parameters with default values become optional in the schema. Parameters without defaults are marked as required.
Next Steps
- Web & Search — search, fetch, and fetch_raw
- File System — read, write, edit, and ls
- Shell & Python — run and execute
- Research Agent recipe — see tools in action