Define and use tools within Rigging pipelines.
@tool
decorator and pass that into pipelines.
@tool
for Functions@rigging.tool
to make it usable by the Rigging framework.
typing.Annotated
to provide descriptions for parameters where needed.@tool_method
for Class Methodsself
), use the @rigging.tool_method
decorator instead.
@tool_method
correctly handles the self
argument, ensuring it’s not included in the schema presented to the language model. Use @tool
for static methods if they don’t require self
.Tool.from_callable()
internally to wrap your function/method into a Tool
object. This object holds the function, its generated schema, name, and description.
async def
for all your tool functions, and you can opt into any asynchronous behavior later when you start to scale your pipelines.
ChatPipeline.using()
method.
.using()
, and Rigging will automatically discover and include all methods decorated with @tool_method
:
.using()
, Rigging uses Python’s inspect
module to discover all methods decorated with @tool_method
. This automatic discovery only includes methods that have been properly decorated - regular methods without the @tool_method
decorator will be ignored.mode
)mode
parameter in .using()
controls how Rigging interacts with the language model for tool calls:
auto
(Default): Rigging checks if the model provider supports API-level function calling (like OpenAI, Anthropic, Google). If yes, it uses that native, efficient mechanism. If not, it falls back to xml
.api
: Forces the use of the provider’s function calling API. Will fail if the provider doesn’t support it.xml
: Rigging injects instructions and an XML schema into the prompt, telling the model how to format its output to request a tool call using specific XML tags. Rigging parses this XML.json-in-xml
: Similar to xml
, but the model is instructed to place a JSON object containing the arguments within the XML tags.json-with-tag
: Similar to json
, but the JSON object is wrapped in a specific tag (e.g., <tool_call>
).json
: The model is instructed to output tool calls as raw JSON anywhere in the message content with name
and arguments
fieldsauto
is recommended as it leverages the most efficient method available.
max_depth
)max_depth
parameter limits how many levels deep tool calls can go. If a tool itself triggers another prompt that uses tools, this prevents infinite loops.
rigging.Stop
exception with a message to be passed back to the model for context.
rg.Stop
exception instead of raising it is helpful if you don’t want any surrounding code (decorators that wrap the tool function) to catch the exception, alter it, or behave as if a typical exception occurred.rigging.mcp
function, specifying the transport method (stdio
or sse
) and the connection parameters. It returns an async context manager.
mcp
context manager handles the connection, tool discovery, and communication with the MCP server. Inside the async with
block, mcp_client.tools
provides the list of discovered Tool
objects ready to be used with .using()
.
rigging.as_mcp
function is the primary way to create an MCP server from your tools. It takes a list of Rigging Tool
objects (or raw Python functions) and returns a mcp.server.fastmcp.FastMCP
server instance, which you can then configure and run.
How it works:
as_mcp
.rigging.Tool
objects.rigging.Message
and rigging.Stop
) into a format the MCP client can understand.FastMCP
server instance, ready to be run.file_writer
tool.
1. Define your tool(s) in a file (e.g., file_writer.py
):
rigging.robopages
function to connect to a Robopages endpoint and retrieve its tools.
.using()
:
mode
.api
mode, the definitions (ApiToolDefinition
) are passed to the model provider’s API.xml
or json-in-xml
modes, Rigging injects the tool schemas and usage instructions into the system prompt.api
mode, the provider returns structured tool call information (ApiToolCall
).XmlToolCall
or JsonInXmlToolCall
).Message
with role="tool
for API calls, or a user message containing NativeToolResult
for native calls) and sent back to the model.max_depth
is reached.json.JSONDecodeError
: When the model provides malformed JSON argumentsValidationError
: When the model’s arguments don’t match the tool’s type signature@tool_method
operate on class instances, they can maintain and modify state across multiple calls within a single pipeline execution.