-
Notifications
You must be signed in to change notification settings - Fork 391
Added new agent and example utilizing the OpenAI Responses API #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dnandakumar-nv
wants to merge
80
commits into
NVIDIA:develop
Choose a base branch
from
dnandakumar-nv:responses-api-support
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 5a4ba40
Add API type validation and configuration for LLMs
dnandakumar-nv 42e6937
Add API type validation for NVIDIA, OpenAI, and AWS Bedrock
dnandakumar-nv 64b2847
Add OpenAI MCP schema data model
dnandakumar-nv e2a8012
Add Responses API Agent with support for tool use and error handling
dnandakumar-nv 08bef3a
Refactor LLM config handling and async graph initialization
dnandakumar-nv 1398b34
Refine response content extraction logic in register.py
dnandakumar-nv ce998e0
Add error handling and logging for tool schema extraction
dnandakumar-nv 80986b3
Refactor tool usage and add default for MCP headers
dnandakumar-nv 934124a
Refactor logging and code style in agent modules
dnandakumar-nv 9c7d2ce
Add config file for response API in simple calculator example
dnandakumar-nv a0109c2
Add Apache 2.0 license header to `__init__.py`
dnandakumar-nv 2d801fb
Refine llm_config to exclude "api_type" across components
dnandakumar-nv 0151638
Refactor field handling and update model key formatting.
dnandakumar-nv ece25e3
Improve handling of `api_type` in metadata documentation generation
dnandakumar-nv b40edee
Add tool output schema and parsing for server-side tools
dnandakumar-nv 48bc4c1
Add logging and handle unsupported streaming in Responses API
dnandakumar-nv af0a3ff
Add logging to Llama Index and warn about callback limitations
dnandakumar-nv 1ceeacd
Add support for server-side tool usage tracking
dnandakumar-nv c204422
Refactor `ServerToolUseSchema` to centralize its definition.
dnandakumar-nv 11f5b75
Add validation to disallow Responses API in LLM configs
dnandakumar-nv 2348b8c
Add test cases for LLM client wrappers across frameworks
dnandakumar-nv a492ece
Add test cases for LLM client wrappers across frameworks
dnandakumar-nv 62df9b1
Merge branch 'refs/heads/develop' into responses-api-support
dnandakumar-nv 570279c
Remove deprecated config_responses_api.yml file
dnandakumar-nv e934eac
Update Llama-Index dependencies to latest versions
dnandakumar-nv 508c738
Fix logger formatting issue in register.py
dnandakumar-nv ef887e4
Rename test files for improved clarity and consistency.
dnandakumar-nv 5fc0f68
Fix test assertion and update test discovery paths
dnandakumar-nv a2faaa7
Refactor path handling to resolve repo-relative paths
dnandakumar-nv 056954e
Refactor test to improve file handling and loop clarity.
dnandakumar-nv 74c988e
Streamline tool schema handling and fix minor issues
dnandakumar-nv b42d5e0
Refactor "validate_no_responses_api" into shared utility module
dnandakumar-nv 3f10b89
Remove unused APITypeEnum imports across modules
dnandakumar-nv 3f4bb54
Merge branch 'develop' into responses-api-support
dnandakumar-nv 940c3d8
Refactor ValueError messages for Responses API consistency
dnandakumar-nv bef190d
Merge remote-tracking branch 'origin/responses-api-support' into respβ¦
dnandakumar-nv b7d1c62
Simplify tool schema parsing and reduce logging level.
dnandakumar-nv 0e735c2
Add support for tracking cached and reasoning token usage
dnandakumar-nv 184f66f
Add token usage extraction and update MCP dependency version
dnandakumar-nv 8e904a3
Merge branch 'refs/heads/develop' into responses-api-support
dnandakumar-nv 0193123
Update metadata in lockfile for package distributions
dnandakumar-nv b74958c
Rename ITS tool functions to TTC tool functions
dnandakumar-nv b8e8b48
Update external/aiqtoolkit-opensource-ui dependencies
dnandakumar-nv a14acc5
Update AIQ Toolkit UI dependency
dnandakumar-nv f9919b3
Refactor file path resolution using `importlib.resources`.
dnandakumar-nv caefb0f
Refactor file path resolution using `importlib.resources`.
dnandakumar-nv e31c6b6
Remove unit tests for LLM client wrapper plugins
dnandakumar-nv 66a90c0
Update dependencies and resolve compatibility issues
dnandakumar-nv a56a35a
Update dependencies and simplify platform-specific markers
dnandakumar-nv 0222b38
Fix wildcard pattern in testpaths configuration
dnandakumar-nv e5f880c
Add unit tests for LLM client wrappers across frameworks
dnandakumar-nv 48b53a0
Update uv.lock to reflect dependency and metadata changes
dnandakumar-nv c0af5ff
Update weave dependency to use version range
dnandakumar-nv 6876d52
Remove `google-search-results` dependency
dnandakumar-nv d3a7368
Remove `google-search-results` dependency
dnandakumar-nv e3d4bda
Merge remote-tracking branch 'upstream/develop' into responses-api-suβ¦
dnandakumar-nv a46457f
Update dependencies for various packages and libraries
dnandakumar-nv e6da879
Add pylint disables and update dependencies versions
dnandakumar-nv 4ab26fd
Merge remote-tracking branch 'origin/develop' into responses-api-support
dnandakumar-nv d20b108
Reset `uv.lock` file revision and remove upload-time metadata
dnandakumar-nv fb97ed2
Add configuration file for responses API tool-calling agent
dnandakumar-nv 68f7664
Support OpenAI Responses API and refine tool configs
dnandakumar-nv 897ebb8
Merge branch 'develop' into responses-api-support
dnandakumar-nv 06370c7
Disable specific pylint warnings to improve code clarity
dnandakumar-nv 9149a2d
Update README to reflect new CLI commands and formatting
dnandakumar-nv 605de7b
Update README to reflect new CLI commands and formatting
dnandakumar-nv 49697e6
Add documentation for Responses API and agent configuration
dnandakumar-nv e786c12
Add unit tests for Responses API agent workflow
dnandakumar-nv 66ff758
Add Responses API and Agent documentation and test adjustments
dnandakumar-nv 839164b
Add Responses API and Agent documentation and test adjustments
dnandakumar-nv 98336e7
Merge remote-tracking branch 'upstream/develop' into responses-api-suβ¦
dnandakumar-nv c10cbe1
Merge branch 'develop' into responses-api-support
dnandakumar-nv 3549c03
Merge branch 'develop' into responses-api-support
dnandakumar-nv 23f93b8
Merge remote-tracking branch 'upstream/develop' into responses-api-suβ¦
dnandakumar-nv 2e07577
Update LLM error messages and dependency versions
dnandakumar-nv 4fc8080
Merge branch 'develop' into responses-api-support
dnandakumar-nv d2563ee
Update dependencies and improve LLM configuration logic
dnandakumar-nv 12f57ed
Fix typo in file name "reponses" to "responses"
dnandakumar-nv 9910b29
Update tool_outputs to accept a list of ServerToolUseSchema
dnandakumar-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
|
||
|
||
|
||
## 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
examples/agents/tool_calling/configs/config-responses-api.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.