Common use cases
Custom tools are most often used to:- Access internal knowledge stores — proprietary data sources or repositories unique to your business
- Transform or enrich data — clean, format, or augment text, numerical, or structured data
- Execute specialized business logic — operations tailored to specific organizational needs
Quick start
1. Define your Python function
Each custom tool must be implemented in its own.py file. The following example creates a simple tool that adds two integers:
2. Create the custom function
file_path accepts a relative or absolute path to the .py file containing your function.
3. Create a code interpreter tool with the custom function
Custom functions run within the code interpreter. Create a code interpreter tool and include the function IDs in its configuration:Parameters
| Parameter | Required | Description |
|---|---|---|
name | Yes | A unique name for the tool. |
description | Yes | Description that helps the agent understand when to use this tool. |
function_ids | No | List of custom function IDs to include. Without this parameter, the tool functions as a standard code interpreter. |
4. Link to an agent
5. Run the agent
Run the agent as you would for any other tool configuration. For details, see Create and manage agents.Docstring requirements
Your function must contain a valid docstring in Google-style format. A Google-style docstring has four components:- Short description: A brief, one-line description of what the function does.
- Long description (optional): A more detailed explanation of the function’s purpose, behavior, and when to use it.
- Args: Documentation for each parameter, including the parameter name, type, and description.
- Returns: Documentation of the return value, including its type and description.
Manage custom functions
Update a custom function
Active must be demoted and re-promoted for the updated function to take effect:
Delete a custom function
List all custom functions
| Parameter | Description |
|---|---|
limit | Maximum number of functions to return. |
order | Sort direction ("asc" or "desc") based on creation time. |
offset | Number of records to skip before returning results. |
Retrieve a custom function
Best practices
Write clear, purposeful docstrings
The reasoning model relies heavily on function docstrings to determine when and how to invoke your custom tools. Well-crafted docstrings directly impact tool performance and reliability.- Function description: Include both a short and long description. The short description should describe when to invoke the function. The long description should specify the conditions or scenarios when the agent should use this tool versus other available options.
- Parameter documentation: Provide clear, specific descriptions for each parameter that help the reasoning model map conversation context to each argument. Avoid generic descriptions like “input value” — instead use contextual descriptions like “user’s email address from the conversation” or “the product ID mentioned in the request.”
- Return value documentation: Clearly describe what the function returns and how the agent should interpret or use the result in its response.
Test functions locally before deployment
SeekrFlow does not validate Python syntax or runtime behavior when you create a custom function — it will be created successfully even if the code contains errors. However, when the agent attempts to invoke a faulty function during a conversation, it will fail. Before creating a custom function, always:- Verify the function runs without syntax errors
- Test with representative input data
- Handle expected edge cases (null values, empty strings, invalid inputs)
Use external services for complex logic
Custom tools support single function definitions only — helper functions and nested functions within the same file are not supported. For workflows requiring multiple functions or complex business logic, create an external service that your custom tool can call.Imports and package support
SeekrFlow uses Pyodide to execute custom tools in a secure sandboxed environment.- Natively supported packages: Pyodide includes many popular Python packages out of the box. See the complete list of pre-installed packages.
- External packages: For packages not natively supported, Pyodide automatically attempts to install them at runtime using
micropip. This works for pure Python packages — those that do not require compiled extensions or system-level dependencies.
Package best practices
- Use natively supported packages when possible for faster execution and guaranteed compatibility.
- Verify pure Python compatibility for external packages — check that they have wheels available on PyPI and do not depend on C extensions.
- Test thoroughly when using external packages, as installation failures will cause your custom tool to fail at runtime.
- If a required package does not compile in Pyodide, create an external service that uses the package and call it from your custom tool via API.