Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
6bcf72b
Update dependencies in pyproject.toml and uv.lock
dnandakumar-nv Jul 6, 2025
5a4ba40
Add API type validation and configuration for LLMs
dnandakumar-nv Jul 6, 2025
42e6937
Add API type validation for NVIDIA, OpenAI, and AWS Bedrock
dnandakumar-nv Jul 6, 2025
64b2847
Add OpenAI MCP schema data model
dnandakumar-nv Jul 6, 2025
e2a8012
Add Responses API Agent with support for tool use and error handling
dnandakumar-nv Jul 7, 2025
08bef3a
Refactor LLM config handling and async graph initialization
dnandakumar-nv Jul 7, 2025
1398b34
Refine response content extraction logic in register.py
dnandakumar-nv Jul 7, 2025
ce998e0
Add error handling and logging for tool schema extraction
dnandakumar-nv Jul 7, 2025
80986b3
Refactor tool usage and add default for MCP headers
dnandakumar-nv Jul 7, 2025
934124a
Refactor logging and code style in agent modules
dnandakumar-nv Jul 7, 2025
9c7d2ce
Add config file for response API in simple calculator example
dnandakumar-nv Jul 7, 2025
a0109c2
Add Apache 2.0 license header to `__init__.py`
dnandakumar-nv Jul 7, 2025
2d801fb
Refine llm_config to exclude "api_type" across components
dnandakumar-nv Jul 7, 2025
0151638
Refactor field handling and update model key formatting.
dnandakumar-nv Jul 7, 2025
ece25e3
Improve handling of `api_type` in metadata documentation generation
dnandakumar-nv Jul 7, 2025
b40edee
Add tool output schema and parsing for server-side tools
dnandakumar-nv Jul 7, 2025
48bc4c1
Add logging and handle unsupported streaming in Responses API
dnandakumar-nv Jul 7, 2025
af0a3ff
Add logging to Llama Index and warn about callback limitations
dnandakumar-nv Jul 7, 2025
1ceeacd
Add support for server-side tool usage tracking
dnandakumar-nv Jul 7, 2025
c204422
Refactor `ServerToolUseSchema` to centralize its definition.
dnandakumar-nv Jul 7, 2025
11f5b75
Add validation to disallow Responses API in LLM configs
dnandakumar-nv Jul 7, 2025
2348b8c
Add test cases for LLM client wrappers across frameworks
dnandakumar-nv Jul 8, 2025
a492ece
Add test cases for LLM client wrappers across frameworks
dnandakumar-nv Jul 8, 2025
62df9b1
Merge branch 'refs/heads/develop' into responses-api-support
dnandakumar-nv Jul 8, 2025
570279c
Remove deprecated config_responses_api.yml file
dnandakumar-nv Jul 8, 2025
e934eac
Update Llama-Index dependencies to latest versions
dnandakumar-nv Jul 8, 2025
508c738
Fix logger formatting issue in register.py
dnandakumar-nv Jul 8, 2025
ef887e4
Rename test files for improved clarity and consistency.
dnandakumar-nv Jul 8, 2025
5fc0f68
Fix test assertion and update test discovery paths
dnandakumar-nv Jul 8, 2025
a2faaa7
Refactor path handling to resolve repo-relative paths
dnandakumar-nv Jul 8, 2025
056954e
Refactor test to improve file handling and loop clarity.
dnandakumar-nv Jul 8, 2025
74c988e
Streamline tool schema handling and fix minor issues
dnandakumar-nv Jul 9, 2025
b42d5e0
Refactor "validate_no_responses_api" into shared utility module
dnandakumar-nv Jul 9, 2025
3f10b89
Remove unused APITypeEnum imports across modules
dnandakumar-nv Jul 9, 2025
3f4bb54
Merge branch 'develop' into responses-api-support
dnandakumar-nv Jul 9, 2025
940c3d8
Refactor ValueError messages for Responses API consistency
dnandakumar-nv Jul 9, 2025
bef190d
Merge remote-tracking branch 'origin/responses-api-support' into resp…
dnandakumar-nv Jul 9, 2025
b7d1c62
Simplify tool schema parsing and reduce logging level.
dnandakumar-nv Jul 9, 2025
0e735c2
Add support for tracking cached and reasoning token usage
dnandakumar-nv Jul 10, 2025
184f66f
Add token usage extraction and update MCP dependency version
dnandakumar-nv Jul 14, 2025
8e904a3
Merge branch 'refs/heads/develop' into responses-api-support
dnandakumar-nv Jul 14, 2025
0193123
Update metadata in lockfile for package distributions
dnandakumar-nv Jul 14, 2025
b74958c
Rename ITS tool functions to TTC tool functions
dnandakumar-nv Aug 8, 2025
b8e8b48
Update external/aiqtoolkit-opensource-ui dependencies
dnandakumar-nv Aug 8, 2025
a14acc5
Update AIQ Toolkit UI dependency
dnandakumar-nv Aug 8, 2025
f9919b3
Refactor file path resolution using `importlib.resources`.
dnandakumar-nv Aug 8, 2025
caefb0f
Refactor file path resolution using `importlib.resources`.
dnandakumar-nv Aug 8, 2025
e31c6b6
Remove unit tests for LLM client wrapper plugins
dnandakumar-nv Aug 8, 2025
66a90c0
Update dependencies and resolve compatibility issues
dnandakumar-nv Aug 8, 2025
a56a35a
Update dependencies and simplify platform-specific markers
dnandakumar-nv Aug 8, 2025
0222b38
Fix wildcard pattern in testpaths configuration
dnandakumar-nv Aug 8, 2025
e5f880c
Add unit tests for LLM client wrappers across frameworks
dnandakumar-nv Aug 8, 2025
48b53a0
Update uv.lock to reflect dependency and metadata changes
dnandakumar-nv Aug 8, 2025
c0af5ff
Update weave dependency to use version range
dnandakumar-nv Aug 8, 2025
6876d52
Remove `google-search-results` dependency
dnandakumar-nv Aug 8, 2025
d3a7368
Remove `google-search-results` dependency
dnandakumar-nv Aug 8, 2025
e3d4bda
Merge remote-tracking branch 'upstream/develop' into responses-api-su…
dnandakumar-nv Aug 11, 2025
a46457f
Update dependencies for various packages and libraries
dnandakumar-nv Aug 11, 2025
e6da879
Add pylint disables and update dependencies versions
dnandakumar-nv Aug 11, 2025
4ab26fd
Merge remote-tracking branch 'origin/develop' into responses-api-support
dnandakumar-nv Aug 13, 2025
d20b108
Reset `uv.lock` file revision and remove upload-time metadata
dnandakumar-nv Aug 13, 2025
fb97ed2
Add configuration file for responses API tool-calling agent
dnandakumar-nv Aug 13, 2025
68f7664
Support OpenAI Responses API and refine tool configs
dnandakumar-nv Aug 13, 2025
897ebb8
Merge branch 'develop' into responses-api-support
dnandakumar-nv Aug 13, 2025
06370c7
Disable specific pylint warnings to improve code clarity
dnandakumar-nv Aug 13, 2025
9149a2d
Update README to reflect new CLI commands and formatting
dnandakumar-nv Aug 13, 2025
605de7b
Update README to reflect new CLI commands and formatting
dnandakumar-nv Aug 13, 2025
49697e6
Add documentation for Responses API and agent configuration
dnandakumar-nv Aug 13, 2025
e786c12
Add unit tests for Responses API agent workflow
dnandakumar-nv Aug 13, 2025
66ff758
Add Responses API and Agent documentation and test adjustments
dnandakumar-nv Aug 13, 2025
839164b
Add Responses API and Agent documentation and test adjustments
dnandakumar-nv Aug 13, 2025
98336e7
Merge remote-tracking branch 'upstream/develop' into responses-api-su…
dnandakumar-nv Aug 13, 2025
c10cbe1
Merge branch 'develop' into responses-api-support
dnandakumar-nv Aug 14, 2025
3549c03
Merge branch 'develop' into responses-api-support
dnandakumar-nv Aug 14, 2025
23f93b8
Merge remote-tracking branch 'upstream/develop' into responses-api-su…
dnandakumar-nv Aug 20, 2025
2e07577
Update LLM error messages and dependency versions
dnandakumar-nv Aug 20, 2025
4fc8080
Merge branch 'develop' into responses-api-support
dnandakumar-nv Oct 16, 2025
d2563ee
Update dependencies and improve LLM configuration logic
dnandakumar-nv Oct 16, 2025
12f57ed
Fix typo in file name "reponses" to "responses"
dnandakumar-nv Oct 16, 2025
9910b29
Update tool_outputs to accept a list of ServerToolUseSchema
dnandakumar-nv Oct 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/workflows/about/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ For details on workflow configuration, including sections not utilized in the ab
ReAct Agent <./react-agent.md>
Reasoning Agent <./reasoning-agent.md>
ReWOO Agent <./rewoo-agent.md>
Responses API and Agent <./responses-api-and-agent.md>
Router Agent <./router-agent.md>
Sequential Executor <./sequential-executor.md>
Tool Calling Agent <./tool-calling-agent.md>
Expand Down
131 changes: 131 additions & 0 deletions docs/source/workflows/about/responses-api-and-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

# Responses API and Agent

The NeMo Agent toolkit supports OpenAI's Responses API through two complementary pieces:

1) LLM client configuration via the `api_type` field, and 2) a dedicated workflow agent `_type: responses_api_agent` designed for tool use with the Responses API.

Unlike standard chat-based integrations, the Responses API enables models to use built-in tools (for example, Code Interpreter) and connect to remote tools using the Model Context Protocol (MCP). This page explains how to configure an LLM for Responses and how to use the dedicated agent.
Comment on lines +20 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix initial toolkit naming.

Per the docs guideline, the first mention must read β€œNVIDIA NeMo Agent toolkit”; switch the sentence to β€œThe NVIDIA NeMo Agent toolkit supports…”. Later references can remain β€œNeMo Agent toolkit”.

πŸ€– Prompt for AI Agents
In docs/source/workflows/about/responses-api-and-agent.md around lines 20 to 24,
the initial toolkit name is incorrect; change the first sentence so the very
first mention reads "The NVIDIA NeMo Agent toolkit supports OpenAI's Responses
API..." (subsequent mentions can remain "NeMo Agent toolkit"). Ensure only the
first occurrence is updated to include "NVIDIA" and keep the rest of the
paragraph unchanged.



## Features

- **LLM Client Switch**: Select the LLM client mode using `api_type`.
- **Built-in Tools**: Bind Responses built-ins such as Code Interpreter via `builtin_tools`.
- **MCP Tools**: Connect remote tools using `mcp_tools` with fields like `server_label` and `server_url`.
- **NAT Tools**: Continue to use toolkit tools through `nat_tools` (executed by the agent graph).
- **Agentic Workflow**: The `_type: responses_api_agent` integrates tool binding with the NeMo Agent dual-node graph.


## Requirements

- A model that supports the Responses API and any enabled built-in tools.
- For MCP usage, a reachable MCP server and any necessary credentials.


## LLM Configuration: `api_type`

LLM clients support an `api_type` selector. By default, `api_type` is `chat_completions`. To use the Responses API, set `api_type` to `responses` in your LLM configuration.

### Example

```yaml
llms:
openai_llm:
_type: openai
model_name: gpt-5-mini-2025-08-07
# Default is `chat_completions`; set to `responses` to enable the Responses API
api_type: responses
```
Notes:
- If `api_type` is omitted, the client uses `chat_completions`.
- The Responses API unlocks built-in tools and MCP integration.

## Agent Configuration: `_type: responses_api_agent`

The Responses API agent binds tools directly to the LLM for execution under the Responses API, while NAT tools run via the agent graph. This preserves the familiar flow of the NeMo Agent toolkit with added tool capabilities.

### Example `config.yml`

```yaml
functions:
current_datetime:
_type: current_datetime
llms:
openai_llm:
_type: openai
model_name: gpt-5-mini-2025-08-07
api_type: responses
workflow:
_type: responses_api_agent
llm_name: openai_llm
verbose: true
handle_tool_errors: true
# NAT tools are executed by the agent graph
nat_tools: [current_datetime]
# Built-in tools are bound to the LLM (for example, Code Interpreter)
builtin_tools:
- type: code_interpreter
container:
type: "auto"
# Optional: Remote tools via Model Context Protocol
mcp_tools:
- type: mcp
server_label: deepwiki
server_url: https://mcp.deepwiki.com/mcp
allowed_tools: [read_wiki_structure, read_wiki_contents]
require_approval: never
```

## Configurable Options

- `llm_name`: The LLM to use. Must refer to an entry under `llms`.
- `verbose`: Defaults to `false`. When `true`, the agent logs input, output, and intermediate steps.
- `handle_tool_errors`: Defaults to `true`. When enabled, tool errors are returned to the model (instead of raising) so it can recover.
- `nat_tools`: A list of toolkit tools (by function ref) that run in the agent graph.
- `builtin_tools`: A list of built-in tools to bind on the LLM. Availability depends on the selected model.
- `mcp_tools`: A list of MCP tool descriptors bound on the LLM, with fields `server_label`, `server_url`, `allowed_tools`, and `require_approval`.
- `max_iterations`: Defaults to `15`. Maximum number of tool invocations the agent may perform.
- `description`: Defaults to `Agent Workflow`. Used when the workflow is exported as a function.
- `parallel_tool_calls`: Defaults to `false`. If supported, allows the model runtime to schedule multiple tool calls in parallel.

## Running the Agent

Run from the repository root with a sample prompt:

```bash
nat run --config_file=examples/agents/tool_calling/configs/config-responses-api.yml --input "How many 0s are in the current time?"
```

## MCP Field Reference

When adding entries to `mcp_tools`, each object supports the following fields:

- `type`: Must be `mcp`.
- `server_label`: Short label for the server.
- `server_url`: URL of the MCP endpoint.
- `allowed_tools`: Optional allowlist of tool names the model may call.
- `require_approval`: One of `never`, `always`, or `auto`.
- `headers`: Optional map of HTTP headers to include when calling the server.
103 changes: 103 additions & 0 deletions examples/agents/tool_calling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ A configurable Tool Calling agent. This agent leverages the NeMo Agent toolkit p
- [Starting the NeMo Agent Toolkit Server](#starting-the-nemo-agent-toolkit-server)
- [Making Requests to the NeMo Agent Toolkit Server](#making-requests-to-the-nemo-agent-toolkit-server)
- [Evaluating the Tool Calling Agent Workflow](#evaluating-the-tool-calling-agent-workflow)
- [Using Tool Calling with the OpenAI Responses API](#using-tool-calling-with-the-openai-responses-api)

## Key Features

Expand Down Expand Up @@ -177,3 +178,105 @@ curl --request POST \
```bash
nat eval --config_file=examples/agents/tool_calling/configs/config.yml
```

### Using Tool Calling with the OpenAI Responses API
The NeMo Agent toolkit also provides an agent implementation that uses OpenAI's Responses API to enable built-in tools (such as Code Interpreter) and remote tools via Model Context Protocol (MCP).

#### What is the Responses API?
OpenAI's Responses API is a unified endpoint for reasoning models that supports built-in tools and external tool integrations. Compared to Chat Completions, Responses focuses on agentic behaviors like multi-step tool use, background tasks, and streaming of intermediate items. With Responses, models can:
- Use built-in tools such as Code Interpreter; some models also support file search and image generation.
- Connect to remote tools exposed over the Model Context Protocol (MCP).

For current capabilities and model support, see OpenAI's documentation for the Responses API.

#### Prerequisites
- Set your OpenAI API key in the environment:
```bash
export OPENAI_API_KEY=<YOUR_OPENAI_API_KEY>
```
- Use an OpenAI model that supports the Responses API and the tools you enable (for example, `o3`, `o4-mini`, or a compatible `gpt-*` model that advertises Responses support).

#### Run the Responses API agent
An example configuration is provided at `examples/agents/tool_calling/configs/config-responses-api.yml`. Run it from the NeMo Agent toolkit repo root:

```bash
nat run --config_file=examples/agents/tool_calling/configs/config-responses-api.yml --input "How many 0s are in the current time?"
```

#### Configure the agent for Responses
Key fields in `config-responses-api.yml`:

```yaml
llms:
openai_llm:
_type: openai
model_name: gpt-5-mini
# Setting the `api_type` to responses uses the Responses API
api_type: responses

workflow:
_type: responses_api_agent
llm_name: openai_llm
verbose: true
handle_tool_errors: true
# Tools exposed to the agent:
nat_tools: [current_datetime] # NAT tools executed by the agent graph
builtin_tools: # Built-in OpenAI tools bound directly to the LLM
- type: code_interpreter
container:
type: "auto"
mcp_tools: [] # Optional: remote tools over MCP (see below)
```

- **`nat_tools`**: Tools implemented in NeMo Agent toolkit (for example, `current_datetime`). These run via the tool node in the agent graph.
- **`builtin_tools`**: Tools provided by OpenAI's Responses API and executed by the model runtime. The agent binds them to the LLM; the graph does not run them directly.
- **`mcp_tools`**: Remote tools exposed via MCP. The agent passes the schema to the LLM; the model orchestrates calls to the remote server.

#### Built-in tools for OpenAI models
Built-in tool availability depends on model and account features. Common built-ins include:
- **Code Interpreter**: Execute Python for data analysis, math, and code execution. In this repo, configure it as:
```yaml
builtin_tools:
- type: code_interpreter
container:
type: "auto"
```
- **File search** and **image generation** may be supported by some models in Responses. Refer to OpenAI docs for the latest tool names and required parameters if you choose to add them to `builtin_tools`.

Notes:
- This agent enforces that the selected LLM uses the Responses API.
- When `builtin_tools` or `mcp_tools` are provided, they are bound on the LLM with `strict=True` and optional `parallel_tool_calls` support.

#### Configure MCP tools
You can allow the model to call tools from a remote MCP server by adding entries under `mcp_tools`. The schema is defined in `src/nat/data_models/openai_mcp.py`.

Example:

```yaml
workflow:
_type: responses_api_agent
llm_name: openai_llm
# ...
mcp_tools:
- type: mcp
server_label: deepwiki
server_url: https://mcp.deepwiki.com/mcp
allowed_tools: [read_wiki_structure, read_wiki_contents]
require_approval: never # one of: never, always, auto
headers:
Authorization: Bearer <TOKEN_IF_REQUIRED>
```

Field reference (MCP):
- **type**: Must be `mcp`.
- **`server_label`**: A short label for the server. Used in model outputs and logs.
- **`server_url`**: The MCP server endpoint URL.
- **`allowed_tools`**: Optional allowlist of tool names the model may call. Omit or set empty to allow all server tools.
- **`require_approval`**: `never`, `always`, or `auto` (defaults to `never`). Controls whether tool invocations require approval.
- **headers**: Optional HTTP headers to include on MCP requests.

#### Tips and troubleshooting
- Ensure your model supports the specific built-in tools you enable.
- Some built-ins (for example, file search) may require separate setup in your OpenAI account (vector stores, file uploads). Consult OpenAI documentation for current requirements.
- If tool calls error and `handle_tool_errors` is `true`, the agent will surface an informative message instead of raising.

39 changes: 39 additions & 0 deletions examples/agents/tool_calling/configs/config-responses-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# SPDX-FileCopyrightText: Copyright (c) 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


general:
use_uvloop: true

llms:
openai_llm:
_type: openai
model_name: gpt-5-mini-2025-08-07
api_type: responses

functions:
current_datetime:
_type: current_datetime

workflow:
_type: responses_api_agent
nat_tools: [current_datetime]
builtin_tools:
- type: code_interpreter
container:
type: "auto"
llm_name: openai_llm
verbose: true
handle_tool_errors: true
2 changes: 1 addition & 1 deletion examples/frameworks/multi_frameworks/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies = [
"nvidia-nat[langchain,llama-index,openai,nvidia_haystack]~=1.4",
"arxiv~=2.1.3",
"bs4==0.0.2",
"markdown-it-py~=3.0",
"markdown-it-py~=3.0"
]
requires-python = ">=3.11,<3.14"
description = "Custom NeMo Agent toolkit Workflow"
Expand Down
12 changes: 11 additions & 1 deletion packages/nvidia_nat_agno/src/nat/plugins/agno/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from nat.builder.builder import Builder
from nat.builder.framework_enum import LLMFrameworkEnum
from nat.cli.register_workflow import register_llm_client
from nat.data_models.llm import APITypeEnum
from nat.data_models.llm import LLMBaseConfig
from nat.data_models.retry_mixin import RetryMixin
from nat.data_models.thinking_mixin import ThinkingMixin
Expand All @@ -28,6 +29,7 @@
from nat.llm.utils.thinking import FunctionArgumentWrapper
from nat.llm.utils.thinking import patch_with_thinking
from nat.utils.exception_handlers.automatic_retries import patch_with_retry
from nat.utils.responses_api import validate_no_responses_api
from nat.utils.type_utils import override

ModelType = TypeVar("ModelType")
Expand Down Expand Up @@ -80,6 +82,8 @@ async def nim_agno(llm_config: NIMModelConfig, _builder: Builder):

from agno.models.nvidia import Nvidia

validate_no_responses_api(llm_config)

config_obj = {
**llm_config.model_dump(
exclude={"type", "model_name", "thinking"},
Expand All @@ -97,6 +101,7 @@ async def nim_agno(llm_config: NIMModelConfig, _builder: Builder):
async def openai_agno(llm_config: OpenAIModelConfig, _builder: Builder):

from agno.models.openai import OpenAIChat
from agno.models.openai import OpenAIResponses

config_obj = {
**llm_config.model_dump(
Expand All @@ -106,7 +111,10 @@ async def openai_agno(llm_config: OpenAIModelConfig, _builder: Builder):
),
}

client = OpenAIChat(**config_obj, id=llm_config.model_name)
if llm_config.api_type == APITypeEnum.RESPONSES:
client = OpenAIResponses(**config_obj, id=llm_config.model_name)
else:
client = OpenAIChat(**config_obj, id=llm_config.model_name)

yield _patch_llm_based_on_config(client, llm_config)

Expand All @@ -116,6 +124,8 @@ async def litellm_agno(llm_config: LiteLlmModelConfig, _builder: Builder):

from agno.models.litellm.chat import LiteLLM

validate_no_responses_api(llm_config)

client = LiteLLM(
**llm_config.model_dump(
exclude={"type", "thinking", "model_name"},
Expand Down
Loading