-
Couldn't load subscription status.
- Fork 406
Forward-merge release/1.3 into develop #919
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
Forward-merge release/1.3 into develop #919
Conversation
… match (NVIDIA#893) Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * Documentation * Clarified MCP transport configuration in client workflow docs: when using Server-Sent Events (SSE), start the MCP server with the --transport sse flag, and ensure the client and server transport types match. Documented that the default transport is streamable-http, requiring an explicit override for SSE to ensure compatibility. This guidance is now included in the MCP client documentation. Authors: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - Will Killian (https://github.com/willkill07) - David Gardner (https://github.com/dagardner-nv) URL: NVIDIA#893
## Description <!-- Note: The pull request title will be included in the CHANGELOG. --> <!-- Provide a standalone description of changes in this PR. --> <!-- Reference any issues closed by this PR with "closes #1234". All PRs should have an issue they close--> Closes AIQ-1957 - Made the default workflow a react-based workflow - Used `python_safe_workflow_name` instead for the module name - Edited `workflow_commands.py` by replacing `workflow_name` with `package_name`, to ensure imports work (because `package_name` doesn't have `-`) ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added an echo tool (configurable prefix) and a current_datetime tool to workflows. - Introduced a default NIM LLM using meta/llama-3.1-70b-instruct (temperature 0.0). - Workflows gain LangChain wrapper support and parse-agent response retry set to 3. - **Refactor** - Workflow templates now use a ReAct agent type and reference the NIM LLM and tools. - Generated workflow names/exports now use Python-safe naming conventions. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Daniel Wang <[email protected]> Signed-off-by: Zhongxuan (Daniel) Wang <[email protected]> Signed-off-by: Zhongxuan (Daniel) Wang <[email protected]> Co-authored-by: Yuchen Zhang <[email protected]> Co-authored-by: Will Killian <[email protected]>
This PR significantly improves OpenAI Chat Completions API compatibility by fixing response format compliance, and removing unused code. The changes ensure that NAT's OpenAI-compatible endpoints fully adhere to the OpenAI specification for both streaming and non-streaming responses. Closes: NVIDIA#818 A follow-up issue has been created to address accurate calculation and passing of usage statistics from workflows to ChatResponse objects in OpenAI-compatible endpoints: [Issue: 891](NVIDIA#891). ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - New Features - All responses — including error replies — now include usage statistics (prompt, completion, total tokens). - Refactor - OpenAI-compatible non‑streaming path simplified to return a single JSON response; Content-Type set explicitly for JSON and streaming. - Default model identifier standardized to "unknown-model" in responses. - Compatibility - Streaming chunk roles standardized to an enum-style role; response payloads and tests now include and expect usage metadata. Authors: - Eric Evans II (https://github.com/ericevans-nv) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#889
Enable optional token storage for MCP OAuth2 with in-memory or external object-store backends (e.g., S3/MinIO), which are persistent and also more secure. Also enabled users to implement their own external object-store interface. Closes AIQ-1965 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - New Features - Secure token storage for MCP OAuth2: in-memory default with optional external object-store backing, persistent across restarts, multi-user isolation, automatic refresh, and graceful fallback. - Documentation - Added “Secure Token Storage” guide with examples and deployment guidance; MCP auth docs and index updated to reference it. - Tests - Extensive tests covering token storage backends, key hashing/serialization, provider integration, lazy object-store resolution, and persistence. Authors: - Yuchen Zhang (https://github.com/yczhang-nv) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#883
Cleans up the default configuration + workflow template a little more ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - New Features - None - Refactor - Simplified generated workflow configuration by removing redundant logging and frontend blocks and a deprecated retry option. - Aligned workflow registration naming to a consistent convention. - Documentation - Added comprehensive docstrings to the workflow and helper to improve clarity and editor hints. - Chores - Cleaned up default config output to reduce noise and simplify generated templates. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#899
Update the CLI tree based on features since 1.2 release Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Documentation** * Expanded CLI reference with new top-level groups: mcp (client, serve), object-store (mysql, redis, s3), and sizing (calc). * Reorganized structure: promoted sizing to top-level; removed nested serve/client subtree from Start workflow. * Adjusted Workflow ordering: “delete” now precedes “reinstall” under Reinstall/Delete. * Updated navigation and anchors for clarity and discoverability. * Content-only changes; no impact on command behavior. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#900
## Description <!-- Note: The pull request title will be included in the CHANGELOG. --> <!-- Provide a standalone description of changes in this PR. --> <!-- Reference any issues closed by this PR with "closes #1234". All PRs should have an issue they close--> Closes 1897 **Added**: - `ContextState` fields: `workflow_run_id`, `workflow_trace_id` (`src/nat/builder/context.py`) - Non-zero ID generators & validators for OpenTelemetry-sized IDs (`src/nat/data_models/span.py`) - Workflow start/end event emission with metadata: `workflow_run_id`, `workflow_trace_id`, `conversation_id` (`src/nat/runtime/runner.py`) - Span attributes for correlation: `.workflow.run_id`, `.workflow.trace_id`, `.conversation.id` (`src/nat/observability/exporter/span_exporter.py`) - Tests: `tests/nat/opentelemetry/test_otel_span_ids.py`, `tests/nat/runtime/test_runner_trace_ids.py`, `tests/nat/runtime/test_session_traceparent.py`, updates to `tests/nat/runtime/test_runner.py` **Changed**: - Ensure non-zero 128-bit trace IDs and 64-bit span IDs in OTEL plugin (`packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/otel_span.py`) - Runner establishes workflow-scoped run/trace IDs and resets them on exit (`src/nat/runtime/runner.py`) - Exporter prefers parent/context trace ID; falls back to workflow trace ID and sets correlated attributes (`src/nat/observability/exporter/span_exporter.py`) - `SpanContext` defaults & field validators enforce size/range and non-zero invariants (`src/nat/data_models/span.py`) - Parse/propagate incoming W3C `traceparent` and workflow headers to session/runner (`src/nat/runtime/session.py`, `tests/nat/runtime/test_session_traceparent.py`) **Removed**: - None **Why it matters**: - Consistent cross-span correlation and easier log/trace joins across agents and sub-spans - Fewer broken traces: eliminates zero/invalid IDs, aligns with OpenTelemetry sizing - Improves debugging and fleet-wide reporting via explicit `.workflow.*` and `.conversation.id` attributes - Safer header handling for external callers; preserves upstream traces **Breaking changes / Migrations**: - None **Docs**: - None ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Workflow-level run and trace IDs are created, stored in context, propagated, and emitted with WORKFLOW_START/WORKFLOW_END events. * Incoming HTTP tracing headers (traceparent, workflow-trace-id, workflow-run-id) are parsed into context. * **Improvements** * Span metadata now includes workflow IDs and richer attributes (event type, function info, timestamps, conversation/run IDs). * ID generation and validation tightened to ensure non-zero, correctly sized trace and span IDs; span context ID generation approach updated. * **Tests** * Added tests validating span ID formats, runner trace/run ID behavior, and header parsing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Daniel Wang <[email protected]> Signed-off-by: Zhongxuan (Daniel) Wang <[email protected]>
In the last PR NVIDIA#885 I forgot to add this file to the commit, resulting in the bug still persisting. Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - Chores - Updated demo module linting configuration to reduce false-positive warnings and streamline code maintenance. - Adjusted imports to align with available tool integrations, preparing the demo for time and weather-related capabilities. - No changes to existing user workflows or features; behavior remains unchanged. - Tests - No test impact identified. - Documentation - No user-facing documentation changes. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Zhongxuan (Daniel) Wang (https://github.com/zhongxuanwang-nv) URL: NVIDIA#901
Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * Documentation * Restructured and expanded the MCP section with clearer hierarchy. * Added a new MCP Client subsection with command usage, examples, and help summaries. * Enhanced Serve documentation with clearer defaults, updated examples, and a note on running workflows via the MCP front end. * Documented options and defaults consistently across client and serve commands, including authentication and JSON output. * Updated examples to reflect default host/port behavior and available endpoints. * Applied minor formatting tweaks for consistency and readability. Authors: - Yuchen Zhang (https://github.com/yczhang-nv) - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) - Zhongxuan (Daniel) Wang (https://github.com/zhongxuanwang-nv) - Eric Evans II (https://github.com/ericevans-nv) - Will Killian (https://github.com/willkill07) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#903
Update CLI documentation with Optimize command ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Documentation** * Added an “Optimize” section to the CLI reference covering the nat optimize command for hyperparameter and prompt optimization. * Documented key options: --config_file, --dataset, --result_json_path, --endpoint, and --endpoint_timeout. * Included usage examples, including a local configuration invocation. * Clarifies underlying approach and links to the reference guide, improving discoverability for tuning workflows. Authors: - Dhruv Nandakumar (https://github.com/dnandakumar-nv) - Will Killian (https://github.com/willkill07) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#902
* Exports notebooks to markdown files in a temporary directory, and then runs vale on those * Remove out of date exclusion of the `nv_internal` directory ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - Documentation - Polished example notebooks: corrected wording/capitalization, standardized terminology (e.g., LlamaIndex, FastAPI), improved code/reference formatting, and clarified the GPU sizing notebook intro and notes. - Removed certain in-notebook execution snippets to streamline guidance. - Expanded documentation vocabulary to reduce linting false positives. - Chores - Documentation linting now includes converted notebooks for more comprehensive checks. - Improved robustness of docs checks with clearer error handling and temporary file management. - Added nbconvert to development dependencies to support notebook conversion. Authors: - David Gardner (https://github.com/dagardner-nv) Approvers: - Will Killian (https://github.com/willkill07) - https://github.com/Salonijain27 URL: NVIDIA#896
Added a note in CONTRIBUTIONS.md mentioning that contributors may need to run `ulimit -n 4096` when building with uv to avoid "Too many open files (os error 24)" errors. ## Breaking Changes None - this is an addition. ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Documentation** * Added an inline troubleshooting note to the setup instructions addressing the “Too many open files (os error 24)” issue and recommending increasing the file descriptor limit (example: ulimit -n 4096 on Linux/macOS) before building; the note is integrated into the primary setup flow. * **Bug Fixes** * Fixed a minor typo in the command example, changing “ulmit” to “ulimit.” Authors: - ノウラ | Flare (https://github.com/nouraellm) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#897
1. Add a simple utility that provides a `deprecated` decorator 2. Add a deprecation notice for mcp_tool_wrapper - ``` 2025-10-02 23:25:05,415 - nat.utils.decorators - WARNING - mcp_tool_wrapper is deprecated and will be removed in a future release. Reason: This function is being replaced with the new mcp_client function group that supports additional MCP features. ``` ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - **New Features** - Added standardized deprecation utilities: a one-time warning helper and a decorator that supports sync/async/generator callables, plus a compatibility alias. - **Chores** - Marked the MCP tool registration path as deprecated and pointed callers to the replacement; existing behavior unchanged aside from advisory warnings. - **Tests** - Added tests ensuring single-warning behavior, message contents, sync/async/generator coverage, metadata validation, and the alias. Authors: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#904
Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - Documentation - Added a GPU Cluster Sizing section to the CLI reference covering the nat sizing calc command, modes (online/offline), options, and defaults. - Included detailed usage/help output and option descriptions (e.g., config file, latency/runtime targets, users, GPU count, concurrency, passes, output, endpoint, timeouts). - Provided three example workflows: online metrics collection, offline estimation, and combined runs. - Surfaced the sizing guidance in the Optimize section to highlight this capability. Authors: - Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#908
* There is now a 1:1 of each package under `packages/` and the list in the doc. Closes NVIDIA#715 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - Documentation - Expanded installation options with four new optional extras in the NeMo Agent Toolkit docs: “all” (installs all optional dependencies), “ingestion” (data ingestion), “mcp” (Model Context Protocol), and “profiling” (performance profiling). - Clarified availability under Framework Integrations to help users choose appropriate install profiles. - No changes to functionality or public APIs. Authors: - David Gardner (https://github.com/dagardner-nv) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#906
**Session-Aware MCP Client Feature Summary**
This PR Implements per-session isolation for MCP clients, allowing multiple users to interact with MCP tools simultaneously while maintaining complete session separation. Doing this:
1. Improves performance and prevents one user's traffic from impacting another user
2. Provides a cleaner AuthAdapter separation between users
```
Function Group (MCPFunctionGroup)
├── Base Client (MCPStreamableHTTPClient)
│ └── AuthAdapter (user_id: default_user_id)
│ └── Shared Auth Provider (MCPOAuth2Provider)
│ └── Cache: {default_user_id: AuthResult}
│
└── Session Clients (per session)
├── mcp_client_user_1 (MCPStreamableHTTPClient)
│ └── AuthAdapter (user_id: session_1)
│ └── Shared Auth Provider (MCPOAuth2Provider)
│ └── Cache: {session_1: AuthResult}
│
├── mcp_client_user_2 (MCPStreamableHTTPClient)
│ └── AuthAdapter (user_id: session_2)
│ └── Shared Auth Provider (MCPOAuth2Provider)
│ └── Cache: {session_2: AuthResult}
│
└── mcp_client_user_N (MCPStreamableHTTPClient)
└── AuthAdapter (user_id: session_N)
└── Shared Auth Provider (MCPOAuth2Provider)
└── Cache: {session_N: AuthResult}
```
**_Session Lifecycle:_**
- Automatic session client creation on first tool call
- Configurable maximum session limits to prevent resource exhaustion
- Automatic cleanup of inactive sessions based on idle timeout
- Session activity tracking for cleanup decisions
**_Resource Management:_**
- Session limits to prevent resource exhaustion
- Configurable idle timeout for automatic cleanup
- Cleanup triggers on new session creation when limits are reached
- Reference counting to prevent cleanup of active sessions
**_Configuration Options_**
- max_sessions: Maximum number of concurrent sessions
- session_idle_timeout: Time before inactive sessions are cleaned up
**_Other Changes_**
- MCP client config moved to a separate file
- Add docs warnings to ensure the user set their own jira url instead of copy-pasting the sample it the README
## By Submitting this PR I confirm:
- I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md).
- We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
- Any contribution which contains commits that are not Signed-Off will not be accepted.
- When the PR is ready for review, new or existing tests cover these changes.
- When the PR is ready for review, the documentation is up to date with these changes.
## Summary by CodeRabbit
- New Features
- Session-aware MCP client: per-session routing, lifecycle management, and client-level user_id handling for authentication.
- Configurable session limits and idle cleanup (max_sessions, session_idle_timeout).
- Truncated session IDs in logs for clearer output.
- Documentation
- Warnings to set CORPORATE_MCP_JIRA_URL to your protected Jira MCP URL.
- Added Session Management Configuration docs and updated README examples.
- Refactor
- MCP client configuration moved to a dedicated configuration module; imports updated.
- Tests
- Comprehensive session management tests and updated MCP client tests.
- Chores
- Added aiorwlock dependency.
Authors:
- Anuradha Karuppiah (https://github.com/AnuradhaKaruppiah)
Approvers:
- Will Killian (https://github.com/willkill07)
- Yuchen Zhang (https://github.com/yczhang-nv)
- David Gardner (https://github.com/dagardner-nv)
URL: NVIDIA#898
Fixes a test failure in the Haystack Deep Researcher example Closes nvbugs-5557788 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Tests** * Updated test setup to reflect the new package namespace, ensuring tests run against the correct modules and configurations. No user-facing behavior changes. * **Chores** * Aligned internal references with the updated package naming for consistency across the project. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#910
…IA#911) When installing a preleased version of NAT through PyPi, it was impossible for `nat workflow create` to work because `pip` would never use `--pre`. Manually adding `--pre` also didn't work since the version specifier also requires the "patch". This PR properly accounts for prereleases by: - detecting a prerelease - emitting the prerelease version major.minor.patch if required - automatically injecting `--pre` into `pip install` Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **New Features** * Smarter dependency resolution aligns installed versions with workflow dependencies. * Automatically installs prerelease builds during workflow creation when applicable. * Clearer logs explaining version detection and dependency selection. * **Bug Fixes** * Reduced installation failures by correctly handling prerelease and unversioned dependencies. * **Tests** * Added tests for version detection and prerelease handling to ensure reliable install behavior. Authors: - Will Killian (https://github.com/willkill07) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: NVIDIA#911
…IA#909) * Work around readthedocs/sphinx-autoapi#298 by copying the contents of plugin packages into the staged API tree. Also refactor this logic into a method. * Rename the `span_to_dfw_record` module to `span_to_dfw` this fixes an issue where the `span_to_dfw_record` contained a function of the same name, which was also imported into the package, making the rest of the module difficult to import. * Rename dataflyweel's `Request` class to `ESRequest` as this was conflicting with the `nat.data_models.api_server.Request` class * Fix Sphinx docstring parsing errors such as `**kwargs` in a parameter list is interpreted as a bold open, without a closing `**`. * Add missing `__init__.py` files * Since dataflywheel was not included in v1.2, I'm claiming this to be a non-breaking change. ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - Refactor - Streamlined docs build with dynamic API tree generation, improved path handling, and path logging. - Renamed Elasticsearch request model to ESRequest; updated related components accordingly. - OTLP span redaction exporter now accepts an otlp_kwargs dict instead of variadic kwargs. - Documentation - Standardized docstrings across plugins: kwargs naming, “Example::” formatting, and spacing; no behavioral changes. - Tests - Updated tests to new trace conversion module paths; coverage preserved. - Chores - Added licensing boilerplate to a utilities package initializer. Authors: - David Gardner (https://github.com/dagardner-nv) Approvers: - Will Killian (https://github.com/willkill07) URL: NVIDIA#909
Add CLI documentation for `nat object-store` Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Documentation** * Added a new “Object Store Commands” section covering the CLI group and its subcommands (MySQL, Redis, S3). * Included usage examples, help outputs, and supported operations (e.g., upload, delete) to guide users through common workflows. * Note: The new documentation content appears twice on the page and will need consolidation in a follow-up. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Yuchen Zhang (https://github.com/yczhang-nv) URL: NVIDIA#907
This PR rewrites most of the example notebooks and enhances the documentation. We also suggest running within Jupyter or Google Colab. Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - **New Features** - Added refreshed example notebooks: Getting Started with NAT, Bringing Your Own Agent, and Adding Tools and Agents (RAG, data visualization, multi-agent/HITL). - **Documentation** - Updated examples README with clearer walkthroughs, Colab/Brev/Jupyter guidance, and local install/run instructions. - **Chores** - Removed legacy/duplicated example packages, outdated notebooks, configs, sample data, and updated project example listings; CI path-ignore and vocabulary accept lists adjusted. - **Bug Fixes** - Fixed a typo in a user-facing error message. Authors: - Will Killian (https://github.com/willkill07) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: NVIDIA#912
…VIDIA#913) Updates the Observability, Evaluation, and Profiling example notebook Closes ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - New Features - Added an end-to-end notebook for observability, evaluation, and profiling with Phoenix-based tracing. - Introduced a unified workflow combining data analysis, visualization, and RAG agents. - Enabled evaluation and profiling runs with metrics, profiler outputs, and charts. - Documentation - Added step-by-step setup, installation, API key handling, and run commands. - Clarified local vs. hosted execution and observability guidance. - Chores - Included sample retail sales data, product catalog, and evaluation dataset. - Added ready-to-use workflow, evaluation, and profiling configurations. - Expanded accepted vocabulary to include "Gantt". Authors: - Will Killian (https://github.com/willkill07) Approvers: - David Gardner (https://github.com/dagardner-nv) URL: NVIDIA#913
This fixes a coroutine missing await when running with TTC. It also fixes the related type hints for input+output schema. Closes nvbugs-5560791 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - New Features - None - Bug Fixes - Improved reliability by ensuring function resolution is awaited before execution, reducing timing-related issues. - Refactor - Transitioned a function retrieval step to asynchronous execution for smoother control flow. - Updated schema handling to use type-based definitions, improving compatibility with dynamic structured outputs. - Chores - Internal typing adjustments to align with expected schema types. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#914
Fix quote escapes for ReWOO example for cURL POST commands Closes nvbugs-5560823 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit * **Documentation** * Updated sample curl examples to use properly escaped JSON strings (escaped double quotes) so pasted commands run reliably in shells. * Clarified example payload quoting to avoid terminal parsing errors when input contains quotes or apostrophes. * No changes to functionality, APIs, or runtime behavior—examples only. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#915
…cs (NVIDIA#916) * Redeclare `ARG` after `FROM` stage to ensure visibility. * Fix path typo in documentation (should reference NeMo Agent toolkit rather than example) Closes nvbugs-5561420 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. ## Summary by CodeRabbit - New Features - Docker images now support configurable build-time versions for Python, UV, and NAT via build arguments. - UV binaries are bundled during build for faster, reproducible environments. - Build-time validation ensures NAT version is provided. - Chores - Standardized build-arg declarations across example Dockerfiles for consistency and easier parameterization. - Documentation - Updated example guides to reference the NeMo Agent toolkit repository. - Refreshed Docker build instructions to align with the new configurable build args. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#916
Improve the directions for configuring MinIO with the `simple_web_query_eval` example Closes nvbugs-5561545 ## By Submitting this PR I confirm: - I am familiar with the [Contributing Guidelines](https://github.com/NVIDIA/NeMo-Agent-Toolkit/blob/develop/docs/source/resources/contributing.md). - We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license. - Any contribution which contains commits that are not Signed-Off will not be accepted. - When the PR is ready for review, new or existing tests cover these changes. - When the PR is ready for review, the documentation is up to date with these changes. Authors: - Will Killian (https://github.com/willkill07) Approvers: - Eric Evans II (https://github.com/ericevans-nv) URL: NVIDIA#917
WalkthroughExpands docs and CI to process notebooks; broadens path checks; parameterizes Dockerfiles; restructures Sphinx API tree; overhauls notebooks/examples; introduces MCP OAuth2 token storage and session-aware MCP client; changes public chat data models (roles enum, choices split, usage handling); adds workflow run/trace IDs and events; updates FastAPI/OpenAI endpoint handling; multiple minor doc/docstring edits. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Client as MCP Client
participant Auth as MCPOAuth2Provider
participant Store as TokenStorage (InMemory/ObjectStore)
participant Server as MCP Server
Note over Client,Auth: Session-aware auth with per-user token storage
User->>Client: call_tool(request, user_id)
Client->>Auth: get_auth_headers(user_id)
alt Token exists
Auth->>Store: retrieve(user_id)
Store-->>Auth: AuthResult
else No token
Auth->>Server: OAuth2 code flow
Server-->>Auth: AuthResult (access/refresh)
Auth->>Store: store(user_id, AuthResult)
end
Auth-->>Client: Authorization header
Client->>Server: Tool invocation (authorized)
Server-->>Client: Result
Client-->>User: Response
sequenceDiagram
autonumber
actor Caller
participant Runner as NAT Runtime
participant Ctx as Context
participant Obs as SpanExporter
Note over Runner,Ctx: Workflow run/trace lifecycle
Caller->>Runner: run(workflow, input)
Runner->>Ctx: set workflow_run_id, workflow_trace_id
Runner->>Obs: WORKFLOW_START (ids, metadata)
Runner->>Runner: execute entry function
Runner->>Obs: WORKFLOW_END (result/summary)
Runner->>Ctx: reset workflow ids
Runner-->>Caller: result/stream
sequenceDiagram
autonumber
actor User
participant NAT as MCPFunctionGroup
participant Sess as SessionManager
participant MClient as Per-Session MCP Client
participant Srv as MCP Server
Note over NAT,Sess: Session-aware tool routing
User->>NAT: invoke tool
NAT->>Sess: get_session_id()
NAT->>Sess: _get_session_client(session_id)
Sess->>MClient: create if missing (limit/cleanup)
NAT->>MClient: call_tool()
MClient->>Srv: request
Srv-->>MClient: response
MClient-->>NAT: tool result
NAT-->>User: result
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120+ minutes Possibly related PRs
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
/ok to test fb2d93c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 21
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (15)
packages/nvidia_nat_agno/src/nat/plugins/agno/tool_wrapper.py (1)
142-156: Switch the docstring to Google style for compliance.
Per the repo’s coding guidelines, public functions must use Google-style docstrings. This block still follows the old NumPy-style “Parameters/Returns” format. Please reformat it into Google style so we stay aligned with the documented standards. As per coding guidelinespackages/nvidia_nat_data_flywheel/src/nat/plugins/data_flywheel/observability/exporter/dfw_elasticsearch_exporter.py (1)
34-34: Add type hint for**elasticsearch_kwargsparameter.The
**elasticsearch_kwargsparameter lacks a type hint, violating the coding guidelines that require "All public APIs must have Python 3.11+ type hints on parameters and return values."Apply this diff to add a type hint:
+from typing import Any + ... - **elasticsearch_kwargs): + **elasticsearch_kwargs: Any):Alternatively, for more precise typing, consider defining a
TypedDictthat matches the documented structure (endpoint, index, elasticsearch_auth, headers) and useUnpack[ElasticsearchKwargsDict](Python 3.11+).As per coding guidelines.
src/nat/experimental/test_time_compute/functions/execute_score_select_function.py (2)
42-43: Add return type hint and docstring.The function is missing:
- A return type hint: Since this is an async generator, it should be annotated as
AsyncGenerator[FunctionInfo, None]- A Google-style docstring explaining the function's purpose, parameters, and return value
Apply this diff to add the missing return type hint:
+from typing import AsyncGenerator + @register_function(config_type=ExecuteScoreSelectFunctionConfig) -async def execute_score_select_function(config: ExecuteScoreSelectFunctionConfig, builder: Builder): +async def execute_score_select_function( + config: ExecuteScoreSelectFunctionConfig, + builder: Builder +) -> AsyncGenerator[FunctionInfo, None]: + """Execute a function multiple times and select the best output. + + Executes the configured function num_executions times concurrently, optionally + scores the outputs using a scoring strategy, and selects the best result using + a selection strategy. + + Args: + config: Configuration specifying the function to execute, scoring strategy, + selection strategy, and number of executions. + builder: Builder instance for retrieving functions and strategies. + + Yields: + FunctionInfo: Metadata about the wrapped execution function. + """ import asyncioAs per coding guidelines.
91-99: Type safety issue in fallback return path.If the selected output is not found in
its_items(resulting inselected_index == -1), line 99 returnsselected_outputwhich is a string (from line 92). However, the return type annotation on line 71 specifiesexecutable_fn.single_output_type, which may not be compatible withstr.This type mismatch could cause runtime errors if the calling code expects a properly typed result rather than a raw string.
Consider one of these solutions:
- Log an error and raise an exception if no match is found:
- return results[selected_index] if selected_index != -1 else selected_output + if selected_index == -1: + logger.error("Selected output not found in results. This should not happen.") + raise RuntimeError("Failed to match selected output with original results") + return results[selected_index]
- Parse
selected_outputback to the expected type (if feasible based on the type):- return results[selected_index] if selected_index != -1 else selected_output + if selected_index == -1: + logger.warning("Selected output not found in results, returning first result as fallback") + return results[0] + return results[selected_index]packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/otlp_span_adapter_exporter.py (1)
70-70: Wrap extra OTLP parameters inotlp_kwargsfor all OTLPSpanAdapterExporter instantiations. Change calls like:OTLPSpanAdapterExporter(endpoint=…, batch_size=1, flush_interval=0.1, headers=…, resource_attributes=…)to:
OTLPSpanAdapterExporter(endpoint=…, otlp_kwargs={"batch_size": 1, "flush_interval": 0.1, "headers": …, "resource_attributes": …})packages/nvidia_nat_opentelemetry/src/nat/plugins/opentelemetry/otlp_span_redaction_adapter_exporter.py (1)
99-99: Update all instantiations to pass OTLP-specific args viaotlp_kwargs. Replace direct keyword args (batch_size, flush_interval, max_queue_size, timeout, compression, resource_attributes, etc.) withOTLPSpanHeaderRedactionAdapterExporter( endpoint=…, otlp_kwargs={ "batch_size": …, "flush_interval": …, … } )in every call site (including all tests).
src/nat/experimental/test_time_compute/functions/ttc_tool_wrapper_function.py (2)
86-90: Remove duplicate validation check.Lines 86-87 and 89-90 contain identical validation logic that checks
has_single_outputand raises the same error. This is redundant code duplication.Apply this diff to remove the duplicate:
if not augmented_function.has_single_output: raise ValueError("TTCToolWrapperFunction only supports functions with a single output.") - if not augmented_function.has_single_output: - raise ValueError("TTCToolWrapperFunction only supports functions with a single output.") - if augmented_function.description and augmented_function.description != "":
116-144: Return type annotation is inconsistent with actual return values.The function signature declares
-> fn_output_schema:, but the function returns:
- Line 139:
"Not enough information"(astr)- Line 144:
resultfromaugmented_function.acall_invoke(presumably aBaseModelinstance)Additionally, if
fn_output_schemacould betype[None](per line 102), using it directly as a return type annotation is semantically unclear.Consider these options:
Option 1: Use a proper union type annotation if the function can return different types:
+ ReturnType = fn_output_schema if fn_output_schema else str + - async def single_inner(input_message: str) -> fn_output_schema: + async def single_inner(input_message: str) -> BaseModel | str:Option 2: Change the error case to raise an exception instead of returning a string:
async def single_inner(input_message: str) -> fn_output_schema: ... if not llm_parsed: logger.warning("TTCToolWrapperFunction: LLM parsing error") - return "Not enough information" + raise ValueError("Not enough information to generate structured input")src/nat/data_models/api_server.py (1)
39-206: Restore support fortool/functionroles.OpenAI-compatible chat payloads legitimately use roles like
"tool"(and legacy"function"). ConstrainingMessage.role,ChoiceMessage.role, andChoiceDelta.roletoUSER|ASSISTANT|SYSTEMwill now reject those requests/responses, breaking function/tool call scenarios that previously worked. Expand the enum (or revert to plainstr) so existing integrations still accept the full OpenAI role set.src/nat/agent/rewoo_agent/register.py (1)
169-171: Preserve stack trace and avoid double-logging on errorsUse bare
raise(orraise … from ex) and log withlogger.error()when re-raising to keep the original traceback and avoid duplicate stack traces. As per coding guidelines.Apply:
- except Exception as ex: - logger.exception("ReWOO Agent failed with exception: %s", ex) - raise RuntimeError + except Exception as ex: + logger.error("ReWOO Agent failed with exception: %s", ex) + raiseAs per coding guidelines
docs/source/quick-start/installing.md (1)
18-18: Align product name with style guideUse “NVIDIA NeMo Agent toolkit” (lowercase “toolkit”) for the first mention.
-# Installing NVIDIA NeMo Agent Toolkit +# Installing NVIDIA NeMo Agent toolkitAs per coding guidelines
src/nat/front_ends/fastapi/fastapi_front_end_plugin_worker.py (1)
690-710: Add authentication callback to session and handle non-streaming in streaming-only workflows
- Pass
user_authentication_callback=self._http_flow_handler.authenticatetosession():- async with session_manager.session(http_connection=request): + async with session_manager.session( + http_connection=request, + user_authentication_callback=self._http_flow_handler.authenticate, + ):generate_single_responsenow raises ifworkflow.has_single_outputis false. Either reintroduce a fallback aggregation viagenerate_streaming_response_as_strfor non-streaming clients, or enforce/validate single-output workflows and return a clear error whenstream=Falseon streaming-only endpoints.src/nat/cli/commands/workflow/workflow_commands.py (1)
373-377: Non-interactive uninstall for uv.uv uninstall likely prompts; add -y for parity with pip.
- uninstall_cmd = ['uv', 'pip', 'uninstall', package_name] + uninstall_cmd = ['uv', 'pip', 'uninstall', '-y', package_name]packages/nvidia_nat_mcp/src/nat/plugins/mcp/client_base.py (2)
37-39: Incorrect imports; module doesn’t export these types.Import AuthenticatedContext and AuthFlowType from nat.data_models.authentication, not nat.authentication.interfaces.
-from nat.authentication.interfaces import AuthenticatedContext -from nat.authentication.interfaces import AuthFlowType -from nat.authentication.interfaces import AuthProviderBase +from nat.data_models.authentication import AuthenticatedContext, AuthFlowType +from nat.authentication.interfaces import AuthProviderBase
394-398: Fix callback signature mismatch; wrap to match provider’s awaitable (config, flow) callable.Current signature Callable[[AuthFlowType], AuthenticatedContext] conflicts with OAuth2 provider which awaits a (config, flow) callable. Wrap provided callback to adapt.
- def set_user_auth_callback(self, auth_callback: Callable[[AuthFlowType], AuthenticatedContext]): - """Set the user authentication callback.""" - if self._auth_provider and hasattr(self._auth_provider, "_set_custom_auth_callback"): - self._auth_provider._set_custom_auth_callback(auth_callback) + def set_user_auth_callback(self, auth_callback: Callable[[AuthFlowType], AuthenticatedContext | Awaitable[AuthenticatedContext]]): + """Set the user authentication callback.""" + if self._auth_provider and hasattr(self._auth_provider, "_set_custom_auth_callback"): + async def _wrapped(config, flow: AuthFlowType) -> AuthenticatedContext: + # Support sync or async 1‑arg callbacks + result = auth_callback(flow) + if asyncio.iscoroutine(result): + return await result # type: ignore[no-any-return] + return result # type: ignore[return-value] + self._auth_provider._set_custom_auth_callback(_wrapped)
🧹 Nitpick comments (34)
packages/nvidia_nat_mcp/src/nat/plugins/mcp/tool.py (1)
113-116: Enhance deprecation notice withreplacementandremoval_versionparameters.The deprecation decorator is functional but could be more informative. Consider adding:
replacement: Specify the exact function or configuration to use instead (e.g., "mcp_client function group" or a specific function name)removal_version: Provide a target version when this will be removed to help users plan migrationApply this diff to enhance the deprecation notice:
@deprecated( + removal_version="2.0", + replacement="mcp_client function group", reason= "This function is being replaced with the new mcp_client function group that supports additional MCP features", feature_name="mcp_tool_wrapper")packages/nvidia_nat_mcp/src/nat/plugins/mcp/utils.py (1)
24-38: LGTM! Well-documented utility function.The implementation is clear and correctly documented. The function appropriately truncates session IDs for logging purposes.
Optional: Consider input validation for edge cases.
For additional robustness, you could validate that
max_lengthis positive:def truncate_session_id(session_id: str, max_length: int = 10) -> str: """ Truncate a session ID for logging purposes. Args: session_id: The session ID to truncate max_length: Maximum length before truncation (default: 10) Returns: Truncated session ID with "..." if longer than max_length, otherwise full ID """ + if max_length <= 0: + raise ValueError("max_length must be positive") if len(session_id) > max_length: return session_id[:max_length] + "..." return session_idpackages/nvidia_nat_data_flywheel/src/nat/plugins/data_flywheel/observability/schema/sink/elasticsearch/dfw_es_record.py (1)
139-152: Consider improving the docstring for clarity.The class rename from
RequesttoESRequestis good—it's more descriptive and avoids potential naming conflicts. However, the docstring could be more specific about its purpose.Consider this more descriptive docstring:
class ESRequest(BaseModel): - """Request structure used in requests.""" + """Elasticsearch-specific request structure for OpenAI chat completion requests."""packages/nvidia_nat_data_flywheel/src/nat/plugins/data_flywheel/observability/exporter/dfw_elasticsearch_exporter.py (1)
46-50: Consider using standard Google-style docstring format for nested kwargs.The nested bullet list format for documenting
elasticsearch_kwargscontents is unconventional for Google-style docstrings. While clear, a more standard approach would improve consistency.Consider one of these alternatives:
Option 1: Note section
- elasticsearch_kwargs: Additional arguments for ElasticsearchMixin: - - endpoint: The elasticsearch endpoint. - - index: The elasticsearch index name. - - elasticsearch_auth: The elasticsearch authentication credentials. - - headers: The elasticsearch headers. + **elasticsearch_kwargs: Additional keyword arguments for ElasticsearchMixin. + + Note: + Expected elasticsearch_kwargs keys include: + + - endpoint (str): The elasticsearch endpoint + - index (str): The elasticsearch index name + - elasticsearch_auth: The elasticsearch authentication credentials + - headers (dict): The elasticsearch headersOption 2: Reference the mixin documentation
- elasticsearch_kwargs: Additional arguments for ElasticsearchMixin: - - endpoint: The elasticsearch endpoint. - - index: The elasticsearch index name. - - elasticsearch_auth: The elasticsearch authentication credentials. - - headers: The elasticsearch headers. + **elasticsearch_kwargs: Additional keyword arguments for ElasticsearchMixin. + See `ElasticsearchMixin.__init__` for supported parameters.As per coding guidelines.
examples/frameworks/haystack_deep_research_agent/tests/test_haystack_deep_research_agent.py (1)
50-51: Consider simplifying the dynamic import pattern.The dynamic import pattern using
importlib.import_moduleandgetattrcan be simplified to a direct import for better readability and static analysis support.Apply this diff to simplify the import:
- loader_mod = importlib.import_module("nat.runtime.loader") - load_workflow = getattr(loader_mod, "load_workflow") + from nat.runtime.loader import load_workflowNote: If the dynamic import is intentional (e.g., to handle optional dependencies or make the test more flexible), you can ignore this suggestion.
examples/frameworks/adk_demo/src/nat_adk_demo/register.py (1)
19-20: Consider adding__all__to make the registration pattern explicit.For a registration module using import side effects, defining
__all__can help document which tools are being registered and improve code clarity.Apply this diff to add
__all__:from . import nat_time_mcp_tool from . import weather_update_tool + +__all__ = [ + "nat_time_mcp_tool", + "weather_update_tool", +]src/nat/data_models/span.py (4)
142-146: Fix typos in field descriptions ("OTel-style").Both descriptions say "OTel-syle". Correct to "OTel-style".
- trace_id: int = Field(default_factory=_generate_nonzero_trace_id, - description="The OTel-syle 128-bit trace ID of the span.") - span_id: int = Field(default_factory=_generate_nonzero_span_id, - description="The OTel-syle 64-bit span ID of the span.") + trace_id: int = Field(default_factory=_generate_nonzero_trace_id, + description="The OTel-style 128-bit trace ID of the span.") + span_id: int = Field(default_factory=_generate_nonzero_span_id, + description="The OTel-style 64-bit span ID of the span.")
131-139: Ensure generators actually return non-zero IDs (align with docstrings).Current implementation can (extremely rarely) return 0. Loop until non-zero.
def _generate_nonzero_trace_id() -> int: - """Generate a non-zero 128-bit trace ID.""" - return uuid.uuid4().int + """Generate a non-zero 128-bit trace ID.""" + tid = 0 + while tid == 0: + tid = uuid.uuid4().int # 128-bit + return tid def _generate_nonzero_span_id() -> int: - """Generate a non-zero 64-bit span ID.""" - return uuid.uuid4().int >> 64 + """Generate a non-zero 64-bit span ID.""" + sid = 0 + while sid == 0: + sid = uuid.uuid4().int >> 64 # upper 64 bits + return sid
147-158: Validator cleanups: idiomatic None check; guard UUID parsing; optional TRY003 fix.
- Prefer
v is Noneoverisinstance(v, type(None)).- Wrap UUID parsing to raise a clearer error; use
from Noneto satisfy Ruff B904.- Optionally assign error messages to variables to appease TRY003.
@field_validator("trace_id", mode="before") @classmethod def _validate_trace_id(cls, v: int | str | None) -> int: """Regenerate if trace_id is None; raise an exception if trace_id is invalid;""" - if isinstance(v, str): - v = uuid.UUID(v).int - if isinstance(v, type(None)): - v = _generate_nonzero_trace_id() - if v <= 0 or v >> 128: - raise ValueError(f"Invalid trace_id: must be a non-zero 128-bit integer, got {v}") + if isinstance(v, str): + try: + v = uuid.UUID(v).int + except ValueError as err: + msg = f"Invalid trace_id string: {v!r}" # noqa: TRY003 + raise ValueError(msg) from None + if v is None: + v = _generate_nonzero_trace_id() + if v <= 0 or (v >> 128): + msg = "Invalid trace_id: must be a non-zero 128-bit integer" # noqa: TRY003 + raise ValueError(msg) return vAs per coding guidelines.
159-172: Useraise ... from Noneon parse failure; idiomatic None check; optional TRY003.
- Satisfies Ruff B904, removes broad message inline (TRY003) by assigning to variable.
@field_validator("span_id", mode="before") @classmethod def _validate_span_id(cls, v: int | str | None) -> int: """Regenerate if span_id is None; raise an exception if span_id is invalid;""" if isinstance(v, str): - try: - v = int(v, 16) - except ValueError: - raise ValueError(f"span_id unable to be parsed: {v}") - if isinstance(v, type(None)): + try: + v = int(v, 16) + except ValueError as err: + msg = f"Invalid span_id hex string: {v!r}" # noqa: TRY003 + raise ValueError(msg) from None + if v is None: v = _generate_nonzero_span_id() - if v <= 0 or v >> 64: - raise ValueError(f"Invalid span_id: must be a non-zero 64-bit integer, got {v}") + if v <= 0 or (v >> 64): + msg = "Invalid span_id: must be a non-zero 64-bit integer" # noqa: TRY003 + raise ValueError(msg) return vBased on hints from static analysis.
src/nat/runtime/session.py (2)
165-177: Avoid bareexcept+pass; log and narrow exceptions for traceparent parsing.Add a module logger and catch
ValueErroronly; log the failure instead of silently swallowing.@@ -import typing +import typing +import logging @@ from contextlib import nullcontext @@ -from nat.data_models.interactive import InteractionPrompt +from nat.data_models.interactive import InteractionPrompt @@ -_T = typing.TypeVar("_T") +_T = typing.TypeVar("_T") +logger = logging.getLogger(__name__) @@ - traceparent = request.headers.get("traceparent") + traceparent = request.headers.get("traceparent") if traceparent: try: parts = traceparent.split("-") if len(parts) >= 4: trace_id_hex = parts[1] if len(trace_id_hex) == 32: trace_id_int = uuid.UUID(trace_id_hex).int self._context_state.workflow_trace_id.set(trace_id_int) - except Exception: - pass + except ValueError: + logger.exception("Invalid traceparent header; ignoring: %r", traceparent)As per coding guidelines.
178-189: Same here: narrow exception and log when parsing workflow-trace-id.Use
ValueErrorand log instead of silent pass.- if not self._context_state.workflow_trace_id.get(): + if not self._context_state.workflow_trace_id.get(): workflow_trace_id = request.headers.get("workflow-trace-id") if workflow_trace_id: try: self._context_state.workflow_trace_id.set(uuid.UUID(workflow_trace_id).int) - except Exception: - pass + except ValueError: + logger.exception("Invalid workflow-trace-id header; ignoring: %r", workflow_trace_id)As per coding guidelines.
src/nat/agent/react_agent/register.py (1)
153-160: Consider more accurate token counting.The current token counting uses simple whitespace splitting, which may not align with actual LLM tokenization. While this provides approximate usage statistics, consider using a tokenizer library (e.g.,
tiktokenfor OpenAI models) for more accurate token counts in the future.For now, the implementation is acceptable for approximate tracking and maintains consistency with the pattern used in related files (rewoo_agent, retry_react_agent).
examples/notebooks/3_adding_tools_and_agents.ipynb (1)
1683-1717: Model selection for OpenAI client may break
llm.model_namemay not exist on the LangChain wrapper. Prefer deriving model from config or fallback attributes.- response = client.responses.create( - model=llm.model_name, + model_name = getattr(llm, "model", getattr(llm, "model_name", None)) or "gpt-4o" + response = client.responses.create( + model=model_name, input=[{Please confirm whether the LangChain LLM wrapper exposes
modelormodel_name. If not, read fromconfig.llm_nameaccordingly. Based on learningsdocs/source/workflows/mcp/mcp-auth.md (1)
18-19: Fix product name casing in docs heading.Use “NVIDIA NeMo Agent toolkit” (lowercase “toolkit”) in docs. As per naming rules.
As per coding guidelines
examples/notebooks/README.md (2)
35-35: Improve Colab links.Optional: add per‑notebook “Open in Colab” badges that point directly to each notebook path for 1‑click launch.
40-44: Clarify uv prerequisite or offer fallback.Note that uv must be installed, or provide a pure-Python fallback.
-uv venv --seed .venv -source .venv/bin/activate -uv pip install jupyterlab +# Option A (recommended): uv +uv venv --seed .venv && source .venv/bin/activate && uv pip install jupyterlab +# If uv is not installed: +# python -m venv .venv && source .venv/bin/activate && pip install --upgrade pip && pip install jupyterlabdocs/source/workflows/mcp/mcp-auth-token-storage.md (2)
20-20: Fix first-use naming.Per docs guidance, first mention should read “NVIDIA NeMo Agent toolkit”.
-The NeMo Agent toolkit provides a configurable, secure token storage mechanism +The NVIDIA NeMo Agent toolkit provides a configurable, secure token storage mechanismAs per coding guidelines
118-121: Avoid key collisions across providers.Hashing only user_id can collide across different auth providers/servers. Include provider/server into the key.
-- **Key format**: `tokens/{sha256_hash}` where the hash is computed from the `user_id` to ensure S3 compatibility +- **Key format**: `tokens/{sha256_hash}` where the hash is computed from `provider_id + ":" + user_id` (or server URL + user_id) to avoid cross‑provider collisionsdocs/source/reference/cli.md (4)
22-26: Fix first-use naming.Use “NVIDIA NeMo Agent toolkit” on first mention in docs.
-While the NeMo Agent toolkit library provides the capability +While the NVIDIA NeMo Agent toolkit library provides the capabilityAs per coding guidelines
1019-1022: Align wording with available commands.The group offers upload and delete (no download). Update description.
-The `nat object-store` command group provides utilities to interact with object stores. This command group is used to -upload and download files to and from object stores. +The `nat object-store` command group provides utilities to interact with object stores. This command group is used to +upload files to, and delete files from, object stores.
352-359: Example consistency.Consider adding explicit transport in example or note default (streamable-http) to match preceding docs.
150-159: Fix typo in help text
Replace “submit the the workflow” with “submit to the workflow” in:
- src/nat/front_ends/console/console_front_end_config.py:30
- docs/source/reference/cli.md:155, 380
src/nat/cli/commands/workflow/workflow_commands.py (5)
63-72: Use robust prerelease detection.Use packaging.version to detect prereleases instead of segment count.
-def _is_nat_version_prerelease() -> bool: - """ - Check if the NAT version is a prerelease. - """ - version = _get_nat_version() - if version is None: - return False - - return len(version.split(".")) >= 3 +def _is_nat_version_prerelease() -> bool: + """ + Check if the NAT version is a prerelease. + """ + from packaging.version import Version + from nat.cli.entrypoint import get_version + v = get_version() + if not v or v == "unknown": + return False + try: + return Version(v).is_prerelease + except Exception: + return False
299-301: Avoid symlink issues on Windows; fallback to copy.Symlinks often require elevation on Windows and can fail. Fallback to copying if symlink creation fails or on Windows.
- os.symlink(config_dir_source, config_dir_link) - os.symlink(data_dir_source, data_dir_link) + def _safe_link(src: Path, dst: Path) -> None: + try: + os.symlink(src, dst) + except Exception: + if dst.exists(): + return + if src.is_dir(): + shutil.copytree(src, dst) + else: + shutil.copy2(src, dst) + _safe_link(config_dir_source, config_dir_link) + _safe_link(data_dir_source, data_dir_link)
305-311: subprocess.run misuse: check=True makes returncode check dead code.Either set check=False and test returncode, or keep check=True and rely on exceptions. Prefer consistent pattern.
- result = subprocess.run(install_cmd, capture_output=True, text=True, check=True) - - if result.returncode != 0: - click.echo(f"An error occurred during installation:\n{result.stderr}") - return + result = subprocess.run(install_cmd, capture_output=True, text=True, check=False) + if result.returncode != 0: + click.echo(f"An error occurred during installation:\n{result.stderr}") + returnApply similarly in reinstall_command (Line 343) and delete_command (Line 381).
343-349: Align with subprocess pattern above.Make reinstall consistent: set check=False and handle nonzero return code.
- result = subprocess.run(reinstall_cmd, capture_output=True, text=True, check=True) + result = subprocess.run(reinstall_cmd, capture_output=True, text=True, check=False) if result.returncode != 0: click.echo(f"An error occurred during installation:\n{result.stderr}") return
208-213: Fix minor typo in docstring.“pre-popluate” → “pre-populate”.
- description (str): Description to pre-popluate the workflow docstring. + description (str): Description to pre-populate the workflow docstring.src/nat/authentication/oauth2/oauth2_auth_code_flow_provider.py (2)
86-86: Silence Ruff ARG002: rename unused kwargs.Change to avoid the unused-arg warning while keeping signature compatibility:
- async def authenticate(self, user_id: str | None = None, **kwargs) -> AuthResult: + async def authenticate(self, user_id: str | None = None, **_kwargs) -> AuthResult:
129-135: Be explicit about expires_at type.AuthenticatedContext.metadata["expires_at"] might be a string (ISO) from frontends. Consider normalizing to datetime for clarity:
- auth_result = AuthResult( + expires_at = metadata.get("expires_at") + if isinstance(expires_at, str): + try: + from datetime import datetime + expires_at = datetime.fromisoformat(expires_at) + except Exception: + expires_at = None + auth_result = AuthResult( credentials=[BearerTokenCred(token=SecretStr(token))], - token_expires_at=metadata.get("expires_at"), + token_expires_at=expires_at, raw=metadata.get("raw_token") or {}, )src/nat/cli/commands/workflow/templates/workflow.py.j2 (1)
31-33: Docstring nit: use “Yields” not “Returns”.The function yields a FunctionInfo. Update for accuracy:
- Returns: - FunctionInfo: The function info object for the function. + Yields: + FunctionInfo: The function info object for the function.packages/nvidia_nat_mcp/src/nat/plugins/mcp/client_base.py (2)
292-316: Token cache check uses legacy in‑memory attribute; consider token_storage awareness._with_reconnect() chooses timeout based on _has_cached_auth_token(), but this checks provider._authenticated_tokens which no longer exists with token_storage. Improve to consult storage when available:
- If self._auth_provider has _auth_code_provider with _token_storage and an effective user_id is known, attempt retrieve(user_id) and check not expired.
This preserves extended timeout only when interactive auth is likely needed.
635-639: Avoid logging full tool arguments at info level.Tool args may contain PII/secrets. Log at debug or redact.
- logger.info("Calling tool %s with arguments %s", self._tool_name, tool_args) + logger.debug("Calling tool %s", self._tool_name)packages/nvidia_nat_mcp/src/nat/plugins/mcp/client_impl.py (1)
200-236: Session limit pre-check outside writer lock may race.Minor: compute and enforce the max_sessions check while holding the writer lock (you already re-check later). Consider dropping the pre-check or keep as soft-trigger to run cleanup only.
Description
This is a manual forward merge of #895 due to merge conflicts
Closes #895
By Submitting this PR I confirm:
Summary by CodeRabbit
New Features
Documentation
Refactor