NeMo-Agent-Toolkit / nat-workflows
Cursor rule2.7k starsChanged 16 months agoApache-2.0View on GitHub
Follow these rules when the user's request involves implementing, adding, creating, or modifying functions within NeMo Agent Toolkit workflows
Trending
Quiet since August.about the whole repository
Who's talking about NVIDIA/NeMo-Agent-Toolkit
- awslabs/agentcore-samples“02-use-cases - TypeError: _patch_asyncio.<locals>.run() got an unexpected keyword argument 'loop_factory'”GitHub · Sep 29, 2025 · 3 reactions
- NVIDIA-AI-Blueprints/deep-researcher-agent“feat: add exa_web_search data source”GitHub · Apr 14, 2026 · 2 reactions
- astral-sh/uv“Stabilize conflicting modules warning”GitHub · Aug 18, 2025 · 1 reactions
- olga-mir/experiments“68 moaar agents and design canvas”GitHub · Aug 23, 2026
- LennyMalcolm0/langchain“ChatOpenAI/ChatAnthropic: request_timeout=None (default) disables SDK timeout, causing infinite hangs”GitHub · Jul 17, 2026
The biggest 5 of 15 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 15
Talked about on GitHub (15 times).
On GitHub · 15
- Sep 29, 202502-use-cases - TypeError: _patch_asyncio.<locals>.run() got an unexpected keyword argument 'loop_factory' — awslabs/agentcore-samples3 reactions · 5 comments
- Apr 14, 2026feat: add exa_web_search data source — NVIDIA-AI-Blueprints/deep-researcher-agent2 reactions · 7 comments
- Aug 18, 2025Stabilize conflicting modules warning — astral-sh/uv1 reaction · 2 comments
- Aug 23, 202668 moaar agents and design canvas — olga-mir/experiments0 reactions
- Jul 17, 2026ChatOpenAI/ChatAnthropic: request_timeout=None (default) disables SDK timeout, causing infinite hangs — LennyMalcolm0/langchain0 reactions
10 more on GitHub
- Jun 3, 2026ChatNVIDIA forwards verify_ssl into chat completion payload — langchain-ai/langchain-nvidia0 reactions
- May 22, 2026[BUZZOK-30879] streaming memory agent plugin — datarobot-oss/datarobot-genai0 reactions · 1 comment
- May 2, 2026feat(learning): add expected-output assertions + accuracy scoring to batch-runner (NeMo parity) — subinium/CrowClaw0 reactions · 1 comment
- Apr 14, 2026[Question] when an A2A server has OAuth enabled, how does the A2A client know how to generate the corresponding token? — a2aproject/A2A0 reactions · 4 comments
- Apr 2, 2026Enable eager authentication — NVIDIA/NeMo-Agent-Toolkit-UI0 reactions · 5 comments
- Apr 2, 2026Enable redirect-based OAuth flow — NVIDIA/NeMo-Agent-Toolkit-UI0 reactions · 3 comments
- Mar 6, 2026ChatOpenAI/ChatAnthropic: request_timeout=None (default) disables SDK timeout, causing infinite hangs — langchain-ai/langchain0 reactions · 8 comments
- Mar 6, 2026Add agent thought process outputs — NVIDIA/NeMo-Agent-Toolkit-UI0 reactions · 4 comments
- Jan 29, 2026Add sandbox agent example with Docker and Daytona support — NVIDIA/NeMo-Agent-Toolkit-Examples0 reactions · 16 comments
- Oct 24, 2025Add support for exporting telemetry to DBNL — dbnlAI/NeMo-Agent-Toolkit0 reactions
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository38 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/nat-agent-configuration/references/agents.mdAGENTS.md
- .cursor/rules/cursor-rules.mdcCursor rule
- .cursor/rules/documentation/capitalization.mdcCursor rule
- .cursor/rules/documentation/categories.mdcCursor rule
- .cursor/rules/documentation/formatting.mdcCursor rule
- .cursor/rules/documentation/general.mdcCursor rule
- .cursor/rules/documentation/latinisms.mdcCursor rule
- .cursor/rules/documentation/lists-and-tables.mdcCursor rule
- .cursor/rules/documentation/numbers-and-dates.mdcCursor rule
- .cursor/rules/documentation/punctuation.mdcCursor rule
- .cursor/rules/documentation/voice-and-tone.mdcCursor rule
- .cursor/rules/documentation/writing-process.mdcCursor rule
- .cursor/rules/general.mdcCursor rule
- .cursor/rules/nat-agents/general.mdcCursor rule
- .cursor/rules/nat-cli/general.mdcCursor rule
- .cursor/rules/nat-cli/nat-eval.mdcCursor rule
- .cursor/rules/nat-cli/nat-info.mdcCursor rule
- .cursor/rules/nat-cli/nat-run-serve.mdcCursor rule
- .cursor/rules/nat-cli/nat-workflow.mdcCursor rule
- .cursor/rules/nat-setup/general.mdcCursor rule
- .cursor/rules/nat-setup/nat-toolkit-installation.mdcCursor rule
- .cursor/rules/nat-tests/general.mdcCursor rule
- .cursor/rules/nat-tests/integration-tests.mdcCursor rule
- .cursor/rules/nat-tests/nat-test-llm.mdcCursor rule
- .cursor/rules/nat-workflows/add-tools.mdcCursor rule
- .cursor/rules/nat-workflows/general.mdcCursor rule
- nat-agent-configurationSkill
- nat-evaluationSkill
- nat-installationSkill
- nat-mcp-and-servingSkill
- nat-optimizationSkill
- nat-path-checksSkill
- nat-telemetrySkill
- nat-tools-and-functionsSkill
- nat-user-rulesSkill
- nat-workflow-creationSkill
- skill-evolutionSkill
The file
We split this add-functions.mdc into the rules it gives an agent
7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Asynchronous: All functions are asynchronous.
- Distinctive: line 13
Type-Safe: Use Python type hints for inputs and outputs.
- Very specific: line 22
Every function needs a configuration class that inherits from nat.data_models.function.FunctionBaseConfig.
- Very specific: line 25
Use Pydantic's Field to provide default values, descriptions, and validation for configuration options.
- Very specific: line 95
Use the @register_function decorator on an async generator function.
- Distinctive: line 134
If your callable has multiple arguments, an input schema is automatically created.
- Very specific: line 150
Use builder.get_function() inside the registration function to get instances of other functions.
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Follow these rules when the user's request involves implementing, adding, creating, or modifying functions within NeMo Agent Toolkit workflows
globs:
alwaysApply: false
---
# Creating NeMo Agent Toolkit Functions
This document provides rules and guidelines for creating functions (also referred to as tools) in the NeMo Agent Toolkit. Functions are the core building blocks for defining workflow logic.
## Core Concepts
- **Asynchronous**: All functions are asynchronous. Use `async`/`await`.
- **Type-Safe**: Use Python type hints for inputs and outputs. Pydantic is used for validation.
- **I/O Modes**: Functions can have a single output (`ainvoke`) and/or a streaming output (`astream`).
- **Registration**: Functions must be registered using the `@register_function` decorator to be available in the toolkit.
- **Configuration**: Each function has a Pydantic configuration class inheriting from `FunctionBaseConfig`.
## Step-by-Step Guide to Creating a Function
### 1. Define the Configuration Class
Every function needs a configuration class that inherits from `nat.data_models.function.FunctionBaseConfig`. This class defines the function's configuration parameters.
- The class must have a `name` attribute, which is the unique identifier for the function.
- Use Pydantic's `Field` to provide default values, descriptions, and validation for configuration options.
**Example:**
```python
from nat.data_models.function import FunctionBaseConfig
from pydantic import Field
class MyFunctionConfig(FunctionBaseConfig, name="my_function"):
"""Configuration for My Function."""
greeting: str = Field("Hello", description="The greeting to use.")
repeat_count: int = Field(1, description="Number of times to repeat the greeting.", gt=0)
```
### 2. Write the Function Logic
There are two primary ways to implement a function's logic:
#### A. As a Callable (Recommended for simplicity)
Implement the logic as an `async` Python function.
- The function's description is taken from its docstring.
- The input and output types are inferred from type annotations.
- For multiple arguments, a Pydantic model is automatically generated.
**Example (Single Output):**
```python
async def _my_simple_function(message: str) -> str:
"""
A simple function that returns a greeting.
"""
return f"Hello, {message}"
```
**Example (Streaming Output):**
```python
from typing import AsyncGenerator
async def _my_streaming_function(message: str) -> AsyncGenerator[str, None]:
"""
A simple streaming function.
"""
for i in range(3):
yield f"Stream {i}: {message}"
```
#### B. As a `Function` Subclass (For complex state or logic)
Inherit from `nat.builder.function.Function` and implement `_ainvoke` and/or `_astream`.
- Generic parameters `Function[InputType, StreamOutputType, SingleOutputType]`. Use `None` or `NoneType` if an output type is not supported.
**Example:**
```python
from nat.builder.function import Function
from typing import AsyncGenerator, NoneType
class MyComplexFunction(Function[str, str, str]):
async def _ainvoke(self, value: str) -> str:
# Single output logic
return f"Single output: {value}"
async def _astream(self, value: str) -> AsyncGenerator[str, None]:
# Streaming output logic
for i in range(3):
yield f"Stream {i}: {value}"
```
### 3. Register the Function
Use the `@register_function` decorator on an `async` generator function. This registration function `yield`s the actual function logic.
- The `config_type` in the decorator must match your configuration class.
- The registration function receives the `config` instance and a `builder` object.
- **IMPORTANT**: To avoid premature loading, define or import the function logic *inside* the registration function.
**Example (Registering a Callable):**
```python
from nat.cli.register_workflow import register_function
from nat.builder.builder import Builder
@register_function(config_type=MyFunctionConfig)
async def register_my_function(config: MyFunctionConfig, builder: Builder):
# Initialization logic here (e.g., loading models)
print("Initializing my function...")
async def _my_function(message: str) -> str:
"""My function implementation."""
# Access config: config.greeting, config.repeat_count
return f"{config.greeting}, {message}" * config.repeat_count
yield _my_function
# Cleanup logic here
print("Cleaning up my function...")
```
**Example (Registering a `Function` subclass):**
```python
@register_function(config_type=MyFunctionConfig)
async def register_my_complex_function(config: MyFunctionConfig, builder: Builder):
# Import or define the class inside
from .my_complex_function_module import MyComplexFunction
yield MyComplexFunction(config=config)
```
### 4. Handling Multiple Arguments
If your callable has multiple arguments, an input schema is automatically created. You invoke it with a dictionary.
```python
async def multi_arg_fn(text: str, count: int) -> str:
return text * count
# When invoking:
# await function.ainvoke({"text": "a", "count": 3})
```
The input schema will be `class MultiArgFnInput(BaseModel): text: str; count: int`.
### 5. Function Composition
To call other functions, use the `builder` object passed to the registration function.
- In the config class, declare references to other functions using `nat.data_models.component_ref.FunctionRef`.
- Use `builder.get_function()` inside the registration function to get instances of other functions.
**Example:**
```python
from nat.data_models.component_ref import FunctionRef
class MyCompositeConfig(FunctionBaseConfig, name="my_composite_function"):
"""Config for a composite function."""
first_function: FunctionRef
second_function: FunctionRef
@register_function(config_type=MyCompositeConfig)
async def register_composite_function(config: MyCompositeConfig, builder: Builder):
"""Registers a function that calls two other functions."""
func1 = await builder.get_function(config.first_function)
func2 = await builder.get_function(config.second_function)
async def _composite_function(data: str) -> str:
res1 = await func1.ainvoke(data)
res2 = await func2.ainvoke(res1)
return res2
yield _composite_function
```
## Advanced Topics
### Overriding Schemas
You can provide custom Pydantic schemas for input/output validation and documentation by passing `input_schema` or `output_schema` to `FunctionInfo.from_fn`.
### Custom Type Converters
Provide a list of converter functions to `FunctionInfo.from_fn` via the `converters` argument. A converter is a function with type annotations for its input and output.
```python
def my_converter(value: int) -> str:
return f"Converted from int: {value}"
# When creating FunctionInfo
yield FunctionInfo.from_fn(
_my_function,
description="...",
converters=[my_converter]
)
```
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

