fix(examples-hitl): RetryReactAgent must work with function groups#1106
Conversation
Signed-off-by: Will Killian <wkillian@nvidia.com>
WalkthroughThe Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant get_temp_react_agent as get_temp_react_agent()
participant get_function_group_config as get_function_group_config()
participant get_function_config as get_function_config()
participant add_function_group as add_function_group()
participant add_function as add_function()
rect rgb(220, 240, 220)
Note over get_temp_react_agent: New Control Flow
end
loop for each tool in original_config.tool_names
Caller->>get_temp_react_agent: iterate tools
rect rgb(255, 245, 230)
Note over get_temp_react_agent,add_function_group: Try Function Group First
get_temp_react_agent->>get_function_group_config: fetch config
alt Function group exists
get_function_group_config-->>get_temp_react_agent: return config
get_temp_react_agent->>add_function_group: add to agent
add_function_group-->>get_temp_react_agent: success
else Exception raised
get_function_group_config-->>get_temp_react_agent: exception
rect rgb(245, 230, 230)
Note over get_temp_react_agent,add_function: Fallback to Individual Function
get_temp_react_agent->>get_function_config: fetch config
get_function_config-->>get_temp_react_agent: return config
get_temp_react_agent->>add_function: add to agent
add_function-->>get_temp_react_agent: success
end
end
end
end
get_temp_react_agent-->>Caller: return configured agent
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touchesImportant Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (1 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.py
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.py: In code comments use the abbreviations: nat (API namespace/CLI), nvidia-nat (package), NAT (env var prefixes); never use these abbreviations in documentation
Follow PEP 20 and PEP 8 for Python style
Run yapf with column_limit=120; yapf is used for formatting (run second)
Indent with 4 spaces (no tabs) and end each file with a single trailing newline
Use ruff (ruff check --fix) as a linter (not formatter) per pyproject.toml; fix warnings unless explicitly ignored
Respect Python naming schemes: snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants
When re-raising exceptions, use bare raise to preserve stack trace; log with logger.error(), not logger.exception()
When catching and logging without re-raising, use logger.exception() to capture full stack trace
Provide Google-style docstrings for every public module, class, function, and CLI command
Docstring first line must be a concise description ending with a period
Validate and sanitize all user input, especially in web or CLI interfaces
Prefer httpx with SSL verification enabled by default and follow OWASP Top-10 recommendations
Use async/await for I/O-bound work (HTTP, DB, file I/O)
Cache expensive computations with functools.lru_cache or an external cache when appropriate
Leverage NumPy vectorized operations when beneficial and feasible
Files:
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
{**/*.py,**/*.sh,**/*.md,**/*.toml,**/*.y?(a)ml,**/*.json,**/*.txt,**/*.ini,**/*.cfg,**/*.ipynb}: Every file must start with the standard SPDX Apache-2.0 header
Confirm copyright years are up to date when a file is changed
All source files must include the SPDX Apache-2.0 header template (copy from an existing file)
Files:
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py
**/*
⚙️ CodeRabbit configuration file
**/*: # Code Review Instructions
- Ensure the code follows best practices and coding standards. - For Python code, follow
PEP 20 and
PEP 8 for style guidelines.- Check for security vulnerabilities and potential issues. - Python methods should use type hints for all parameters and return values.
Example:def my_function(param1: int, param2: str) -> bool: pass- For Python exception handling, ensure proper stack trace preservation:
- When re-raising exceptions: use bare
raisestatements to maintain the original stack trace,
and uselogger.error()(notlogger.exception()) to avoid duplicate stack trace output.- When catching and logging exceptions without re-raising: always use
logger.exception()
to capture the full stack trace information.Documentation Review Instructions - Verify that documentation and comments are clear and comprehensive. - Verify that the documentation doesn't contain any TODOs, FIXMEs or placeholder text like "lorem ipsum". - Verify that the documentation doesn't contain any offensive or outdated terms. - Verify that documentation and comments are free of spelling mistakes, ensure the documentation doesn't contain any
words listed in the
ci/vale/styles/config/vocabularies/nat/reject.txtfile, words that might appear to be
spelling mistakes but are listed in theci/vale/styles/config/vocabularies/nat/accept.txtfile are OK.Misc. - All code (except .mdc files that contain Cursor rules) should be licensed under the Apache License 2.0,
and should contain an Apache License 2.0 header comment at the top of each file.
- Confirm that copyright years are up-to date whenever a file is changed.
Files:
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py
examples/**/*
⚙️ CodeRabbit configuration file
examples/**/*: - This directory contains example code and usage scenarios for the toolkit, at a minimum an example should
contain a README.md or file README.ipynb.
- If an example contains Python code, it should be placed in a subdirectory named
src/and should
contain apyproject.tomlfile. Optionally, it might also contain scripts in ascripts/directory.- If an example contains YAML files, they should be placed in a subdirectory named
configs/. - If an example contains sample data files, they should be placed in a subdirectory nameddata/, and should
be checked into git-lfs.
Files:
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py
🧬 Code graph analysis (1)
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py (2)
src/nat/builder/workflow_builder.py (8)
get_function_group_config(536-542)get_function_group_config(1203-1204)add_function_group(483-506)add_function_group(1177-1178)get_function_config(527-533)get_function_config(1199-1200)add_function(469-480)add_function(1173-1174)src/nat/builder/builder.py (4)
get_function_group_config(99-100)add_function_group(75-76)get_function_config(95-96)add_function(71-72)
🪛 Ruff (0.14.1)
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py
115-115: Do not catch blind exception: Exception
(BLE001)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: CI Pipeline / Check
examples/HITL/simple_calculator_hitl/src/nat_simple_calculator_hitl/retry_react_agent.py
Show resolved
Hide resolved
|
/merge |
Description
Since ReAct Agent accepts tool_names in the form of functions or function groups, ensure that the Retry ReAct Agent (part of the HITL example) can, too.
Closes
By Submitting this PR I confirm:
Summary by CodeRabbit