Skip to content

Update middleware to use FunctionGroup.SEPARATOR for function matching#1448

Merged
rapids-bot[bot] merged 2 commits intoNVIDIA:release/1.4from
ericevans-nv:fix/middleware-function-group-separator
Jan 22, 2026
Merged

Update middleware to use FunctionGroup.SEPARATOR for function matching#1448
rapids-bot[bot] merged 2 commits intoNVIDIA:release/1.4from
ericevans-nv:fix/middleware-function-group-separator

Conversation

@ericevans-nv
Copy link
Contributor

@ericevans-nv ericevans-nv commented Jan 22, 2026

Description

This PR updates the function separator used in red teaming and defense middleware from . to __ to align with FunctionGroup.SEPARATOR. This fixes a bug introduced when the function group separator was changed, which caused middleware to no longer match registered function names. This broke red teaming and defense middleware functionality since they could not intercept the target functions. Updated the middleware matching logic to use FunctionGroup.SEPARATOR and updated the example configuration files and tests to use the new separator format.

By Submitting this PR I confirm:

  • I am familiar with the Contributing Guidelines.
  • 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

Release Notes

  • Refactor
    • Standardized function naming conventions across middleware and configuration files using a consistent separator format.
    • Updated test fixtures and validation logic to align with the new naming scheme.
    • Updated example configurations and documentation to reflect the standardized naming format.

✏️ Tip: You can customize this high-level summary in your review settings.

@ericevans-nv ericevans-nv self-assigned this Jan 22, 2026
@ericevans-nv ericevans-nv requested review from a team as code owners January 22, 2026 03:55
@ericevans-nv ericevans-nv added improvement Improvement to existing functionality non-breaking Non-breaking change labels Jan 22, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Walkthrough

Configuration files, middleware logic, and test files are updated to replace dot-based function group naming with double-underscore separation using FunctionGroup.SEPARATOR constant. The middleware detection logic is updated to parse function groups using the centralized separator instead of hardcoded dots.

Changes

Cohort / File(s) Summary
Configuration Files
examples/safety_and_security/retail_agent/src/nat_retail_agent/configs/config-with-defenses.yml, examples/safety_and_security/retail_agent/src/nat_retail_agent/configs/red-teaming-with-defenses.yml, examples/safety_and_security/retail_agent/src/nat_retail_agent/configs/red-teaming.yml
Updated target_function_or_group references from retail_tools.get_product_info to retail_tools__get_product_info across all configuration files to align with new separator convention.
Middleware Logic
src/nat/middleware/defense/defense_middleware.py, src/nat/middleware/red_teaming/red_teaming_middleware.py
Modified group-target detection from dot-based heuristics to FunctionGroup.SEPARATOR constant. Added local imports of FunctionGroup and updated docstring examples to reflect new naming pattern (e.g., calculator__add).
Defense Middleware Tests
tests/nat/middleware/test_defense_middleware.py, tests/nat/middleware/test_defense_middleware_content_guard.py, tests/nat/middleware/test_defense_middleware_output_verifier.py, tests/nat/middleware/test_defense_middleware_pii.py
Introduced FunctionGroup.SEPARATOR import and refactored test fixtures and target configurations to construct function names using the centralized separator constant instead of hardcoded dots.
Red Teaming Tests
tests/nat/middleware/test_red_teaming_middleware.py
Added new test guard for separator constant value, imported FunctionGroup, and replaced hardcoded function name strings with dynamic construction using FunctionGroup.SEPARATOR.
Dynamic Middleware Tests
tests/nat/middleware/test_dynamic_middleware.py
Updated fake component method key from "fake.method" to "fake__method" and corresponding error message assertion.
Documentation
examples/safety_and_security/retail_agent/README.md
Updated target_function_or_group references from retail_tools.get_product_info to retail_tools__get_product_info in documentation examples and table entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: updating middleware to use FunctionGroup.SEPARATOR for function matching, which is the core change across all modified files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@mnajafian-nv mnajafian-nv left a comment

Choose a reason for hiding this comment

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

LGTM, I have 2 questions, otherwise this is good to go.

  • Fix: The retail agent README still has the old separator format in multiple places. Users will copy these examples and get broken configs: e.g. findretail_tools.get_product_info nd replace with retail_tools__get_product_info in examples/safety_and_security/retail_agent/README.md

  • Question: What's the deal with eval_dataset.json being added? It's not mentioned in the PR description and seems unrelated. Can you please add a quick note explaining why it's here (or remove if it snuck in accidentally).

Copy link
Member

@willkill07 willkill07 left a comment

Choose a reason for hiding this comment

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

If the existing tests failed to detect that functions weren't being intercepted, then we need to have an appropriate e2e test that does actually verify interception.

I also don't see any new test adequately ensuring that interception is occurring.

@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{"name":"HttpError","status":401,"request":{"method":"PATCH","url":"https://api.github.com/repos/NVIDIA/NeMo-Agent-Toolkit/issues/comments/3782381284","headers":{"accept":"application/vnd.github.v3+json","user-agent":"octokit.js/0.0.0-development octokit-core.js/7.0.6 Node.js/24","authorization":"token [REDACTED]","content-type":"application/json; charset=utf-8"},"body":{"body":"<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\n<!-- walkthrough_start -->\n\n## Walkthrough\n\nThe pull request updates function naming conventions across the codebase from dot-separated notation (e.g., `retail_tools.get_product_info`) to underscore-separated notation (e.g., `retail_tools__get_product_info`) using a centralized `FunctionGroup.SEPARATOR` constant. Middleware implementations, configuration files, and tests are updated consistently to support this new naming scheme.\n\n## Changes\n\n| Cohort / File(s) | Summary |\n|---|---|\n| **LFS Data File**<br>`examples/frameworks/nat_autogen_demo/src/nat_autogen_demo/data/eval_dataset.json` | New Git LFS pointer file added with metadata (version, oid, size) |\n| **Configuration Files**<br>`examples/safety_and_security/retail_agent/src/nat_retail_agent/configs/config-with-defenses.yml`, `red-teaming-with-defenses.yml`, `red-teaming.yml` | Three configuration files updated: all instances of `target_function_or_group` changed from `retail_tools.get_product_info` to `retail_tools__get_product_info` across multiple middleware and scenario definitions |\n| **Middleware Implementation**<br>`src/nat/middleware/defense/defense_middleware.py`, `src/nat/middleware/red_teaming/red_teaming_middleware.py` | Core middleware logic refactored to detect group-qualified functions using `FunctionGroup.SEPARATOR` instead of literal dot notation; updated context-name pattern matching for group extraction and comparison |\n| **Defense Middleware Tests**<br>`tests/nat/middleware/test_defense_middleware.py`, `test_defense_middleware_content_guard.py`, `test_defense_middleware_output_verifier.py`, `test_defense_middleware_pii.py` | Test fixtures and assertions updated to construct function names using `FunctionGroup.SEPARATOR` for consistent naming throughout all test cases |\n| **Other Middleware Tests**<br>`tests/nat/middleware/test_dynamic_middleware.py`, `test_red_teaming_middleware.py` | Test setup updated: registered component method keys and function context names refactored to use new separator-based naming convention |\n\n## Estimated code review effort\n\n🎯 3 (Moderate) | ⏱️ ~25 minutes\n\n<!-- walkthrough_end -->\n\n\n<!-- pre_merge_checks_walkthrough_start -->\n\n<details>\n<summary>🚥 Pre-merge checks | ✅ 3</summary>\n\n<details>\n<summary>✅ Passed checks (3 passed)</summary>\n\n|     Check name     | Status   | Explanation                                                                                                                                                                    |\n| :----------------: | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n|     Title check    | ✅ Passed | The title accurately and concisely describes the main change: updating middleware to use FunctionGroup.SEPARATOR for function matching, which is the core objective of the PR. |\n| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.                                                                                           |\n|  Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled.                                                                                                                    |\n\n</details>\n\n<sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub>\n\n</details>\n\n<!-- pre_merge_checks_walkthrough_end -->\n\n<!-- finishing_touch_checkbox_start -->\n\n<details>\n<summary>✨ Finishing touches</summary>\n\n- [ ] <!-- {\"checkboxId\": \"7962f53c-55bc-4827-bfbf-6a18da830691\"} --> 📝 Generate docstrings\n\n</details>\n\n<!-- finishing_touch_checkbox_end -->\n\n<!-- tips_start -->\n\n---\n\nThanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=NVIDIA/NeMo-Agent-Toolkit&utm_content=1448)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.\n\n<details>\n<summary>❤️ Share</summary>\n\n- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)\n- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)\n- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)\n- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)\n\n</details>\n\n<sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub>\n\n<!-- tips_end -->\n\n<!-- internal state start -->\n\n\n<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA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RVOMAQuMKZFgZu46YsoWQ45ERKym4ooR2G3Gjg9xAAh0IeNRSnjzx7+VYViMpzo42hN4sbouPOpf0rWtbd8VwDnHZDvxu448QAJGAHjYRgEs8SmAvGQiMJ+OCCVkK/EmsCmE3HetW1fHRBAW/EQBq4mFSITIAyE0AahN/GOgAJx43CbAHwlMM/x14iwdBMKaUTvC1Ev5jaw3FIStxv4H8ehI4nYSuJwEiEXxMdACSUJZExjsJLglUSymIHSpjCHZpMSWJnYNiXJMgD/iFJ2BICXhJAmXj+JxEqCRpPG770t6LHNjmJLupPMpJn40yVZIwmcSrJ3E3iUuwwlqTWJTkmCeawuoPiSyHkoydJJ3HsTIAkwAKRmGsk8TbJBErgBHwgnQ5CaBgfKY3y6jbgfClAUgPvyoFqJN++gIAA= -->\n\n<!-- internal state end -->"},"request":{}},"response":{"url":"https://api.github.com/repos/NVIDIA/NeMo-Agent-Toolkit/issues/comments/3782381284","status":401,"headers":{"access-control-allow-origin":"*","access-control-expose-headers":"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset","connection":"close","content-security-policy":"default-src 'none'","content-type":"application/json; charset=utf-8","date":"Thu, 22 Jan 2026 14:03:35 GMT","referrer-policy":"origin-when-cross-origin, strict-origin-when-cross-origin","server":"github.com","strict-transport-security":"max-age=31536000; includeSubdomains; preload","vary":"Accept-Encoding, Accept, X-Requested-With","x-content-type-options":"nosniff","x-frame-options":"deny","x-github-media-type":"github.v3; format=json","x-github-request-id":"403F:22EBD5:14D73:55E5F:69722E37","x-xss-protection":"0"},"data":{"message":"Requires authentication","documentation_url":"https://docs.github.com/rest","status":"401"}}}

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@tests/nat/middleware/test_defense_middleware.py`:
- Around line 612-615: The test contains a duplicated assertion asserting
middleware._last_field_info is None; remove the redundant line so only one
assert middleware._last_field_info is None remains (keep the surrounding
assertions for middleware._last_extracted_content and the single
_last_field_info check) to eliminate the duplicate check.

Signed-off-by: Eric Evans <194135482+ericevans-nv@users.noreply.github.com>
…s to the new seperator

Signed-off-by: Eric Evans <194135482+ericevans-nv@users.noreply.github.com>
@ericevans-nv ericevans-nv force-pushed the fix/middleware-function-group-separator branch from 6209078 to 1beeedb Compare January 22, 2026 14:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/nat/middleware/defense/defense_middleware.py (1)

74-78: Docstring examples use outdated separator format.

The target_function_or_group field docstring still shows examples with the old . separator ('my_calculator.divide', 'llm_agent.generate'), but the middleware now uses FunctionGroup.SEPARATOR (__). Update the examples to reflect the new format.

📝 Suggested fix
     target_function_or_group: str | None = Field(
         default=None,
         description="Optional function or function group to target. "
         "If None, defense applies to all functions. "
-        "Examples: 'my_calculator', 'my_calculator.divide', 'llm_agent.generate'")
+        "Examples: 'my_calculator', 'my_calculator__divide', 'llm_agent__generate'")

Copy link
Contributor

@mnajafian-nv mnajafian-nv left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for addressing the comments :)

@willkill07 willkill07 removed the request for review from a team January 22, 2026 15:10
@willkill07
Copy link
Member

I removed dep-approvers because they own no files on this PR

@ericevans-nv
Copy link
Contributor Author

/merge

@rapids-bot rapids-bot bot merged commit aba5228 into NVIDIA:release/1.4 Jan 22, 2026
32 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement to existing functionality non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants