@function_tool decorator is the quickest path from a plain Python function to a QitOS tool. It inspects your function’s signature, type hints, and docstring, then builds a complete FunctionTool instance with an enriched ToolSpec — no subclassing required.
Step 1: Basic decorator usage
Apply the decorator without arguments. The function name becomes the tool name and the docstring becomes the description:FunctionTool instance with a populated spec that includes the parameter schema, required fields, and description.
Step 2: Decorator parameters
Pass keyword arguments to the decorator to override defaults and control execution policy:Step 3: Type hints become ToolSpec parameters
The decorator inspects your function’s type hints and converts them into JSON Schema entries insideToolSpec.parameters. Supported types include:
Args: section of the docstring.
Step 4: Registering function tools in ToolRegistry
Once you have aFunctionTool, register it with a ToolRegistry so agents can discover and call it:
Step 5: Comparing @function_tool with class-based BaseTool
QitOS offers two ways to define tools. Use the one that fits your needs:@function_tool — best for simple, stateless operations:
BaseTool subclass — best for stateful tools or complex initialization:
Most tools are simple functions. Start with
@function_tool and reach for BaseTool only when you need constructor state or custom execution behavior.
What’s next
MCP Integration
Bridge external MCP server tools into QitOS using the same FunctionTool interface.
Build your first agent
Use your tools inside an AgentModule with a real LLM loop.
