FunctionToolConfig lets agent nodes call Python functions defined in the repo. Implementation lives in entity/configs/tooling.py, utils/function_catalog.py, and functions/function_calling/.
| Field | Description |
|---|---|
tools |
List of FunctionToolEntryConfig. Each entry requires name. |
timeout |
Tool execution timeout (seconds). |
FunctionToolEntryConfig specifics:
name: top-level function name infunctions/function_calling/.
- The dropdown displays each function as
module_name:function_name, wheremodule_nameis the relative Python file underfunctions/function_calling/(without.py, nested folders joined by/). This preserves semantic grouping for large catalogs. - Every module automatically prepends a
module_name:Allentry, and allAllentries are sorted lexicographically ahead of concrete functions. Choosing it expands to all functions in that module during config parsing, preserving alphabetical order. module_name:Allis strictly for bulk imports; overridingdescription/parameters/auto_fillalongside it raises a validation error. Customize individual functions after expansion if needed.- Both modules and functions are sorted alphabetically, and YAML still stores the plain function names;
module_name:Allis merely an input shortcut.
- Path:
functions/function_calling/(override withMAC_FUNCTIONS_DIR). - Functions must live at module top level.
- Provide Python type hints; for enums/descriptions use
typing.Annotated[..., ParamMeta(...)]. - Parameters beginning with
_or splats (*args/**kwargs) are hidden from the agent call. - The docstring’s first paragraph becomes the description (truncated to ~600 chars).
utils/function_catalog.pybuilds JSON Schemas at startup for the frontend/CLI.
The executor passes _context into each function:
| Key | Value |
|---|---|
attachment_store |
utils.attachments.AttachmentStore for querying/registering attachments. |
python_workspace_root |
Session code_workspace/ shared by Python nodes. |
graph_directory |
Session root directory for relative path helpers. |
| others | Environment-specific extras (session/node IDs, etc.). |
| Functions can declare `_context: dict | None = Noneand parse it (seefunctions/function_calling/file.py’s FileToolContext`). |
from typing import Annotated
from utils.function_catalog import ParamMeta
def read_text_file(
path: Annotated[str, ParamMeta(description="workspace-relative path")],
*,
encoding: str = "utf-8",
_context: dict | None = None,
) -> str:
ctx = FileToolContext(_context)
target = ctx.resolve_under_workspace(path)
return target.read_text(encoding=encoding)YAML usage:
nodes:
- id: summarize
type: agent
config:
tooling:
type: function
config:
tools:
- name: describe_available_files
- name: read_text_file- Add your function under
functions/function_calling/. - Supply type hints +
ParamMeta; setauto_fill: falsewith customparametersif you need manual JSON Schema. - If the function needs extra packages, declare them in
pyproject.toml/requirements.txt, or use the bundledinstall_python_packagessparingly. - Run
python -m tools.export_design_template ...so the frontend picks up new enums.
- If the frontend/CLI reports function
foonot found, double-check the name and ensure it resides underMAC_FUNCTIONS_DIR. - When
function_catalogfails to load,FunctionToolEntryConfig.field_specs()includes the error—fix syntax or dependencies first. - Tool timeouts bubble up to the agent; raise
timeoutor handle exceptions inside the function for friendlier responses.