Class
Overview
ToolSpec describes a tool’s interface as JSON Schema. It is used by SyntheticWorld to tell the backend what kind of response to generate.
In most cases you don’t create ToolSpec manually — the @world.tool decorator calls ToolSpec.from_function() automatically. Use ToolSpec directly when you need full control over the schema.
Constructor
string
required
Tool name. Used as the identifier in
world.call().string
required
Human-readable description of what the tool does.
dict
required
JSON Schema for the tool’s input parameters.
dict
required
JSON Schema for the tool’s return value.
list[str] | None
default:"None"
Ordered parameter names for positional argument mapping. Set automatically by
from_function().Methods
from_function(fn)
ToolSpec from a Python function using its type hints and docstring.
Type mapping:
Parameters with default values are marked as optional. Parameters without defaults are
required.
to_schema()
name, description, parameters, and returns keys.
build_input(*args, **kwargs)
@world.tool decorator.
Examples
Manual schema
From function
See Also
- create_synthetic_world() — Create a world to use tools in
- Synthetic Worlds Guide — Full usage guide

