-
Notifications
You must be signed in to change notification settings - Fork 481
Improve input normalization of ReAct agent
#730
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
Improve input normalization of ReAct agent
#730
Conversation
Signed-off-by: Yuchen Zhang <[email protected]>
WalkthroughAdds a configurable flag Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User/Input
participant Agent as ReActAgentGraph
participant Tool as Tool
U->>Agent: agent_thoughts.tool_input (string)
Agent->>Agent: strip input, try json.loads(input)
alt JSON parse success
Agent->>Tool: _call_tool(parsed object) %%#88CCEE%%
else JSON parse fails
alt normalize_tool_input_quotes = True
Agent->>Agent: replace '\'' with '"' then try json.loads()
alt retry parse success
Agent->>Tool: _call_tool(parsed object) %%#88CCEE%%
else retry parse fails
Agent->>Tool: _call_tool(raw string) %%#DDDDDD%%
end
else normalize_tool_input_quotes = False
Agent->>Tool: _call_tool(raw string) %%#DDDDDD%%
end
end
Tool-->>Agent: response (may indicate error)
alt error and pass_tool_call_errors_to_agent = False
Agent->>Agent: raise error
else
Agent-->>U: continue agent flow with response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
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: 1
🧹 Nitpick comments (5)
docs/source/workflows/about/react-agent.md (1)
94-95: Fix markdownlint violation and capitalize JSON; clarify opt-out behavior.Use dash-style bullets per markdownlint and capitalize “JSON”. Also clarify that False passes the raw string through unchanged.
-* `replace_single_quotes_with_double_quotes_in_tool_input`: Defaults to `True`. If set to `True`, the agent will replace single quotes with double quotes in the tool input. This is useful for tools that expect structured json input. +- `replace_single_quotes_with_double_quotes_in_tool_input`: Defaults to `True`. If `True`, the agent replaces single quotes with double quotes in the tool input. This is useful for tools that expect structured JSON input. Set to `False` to pass the raw string to the tool unchanged.src/nat/agent/react_agent/agent.py (1)
80-82: Add return type to init and simplify assignment.Annotate return type and avoid backslash continuation for readability.
- pass_tool_call_errors_to_agent: bool = True, - replace_single_quotes_with_double_quotes_in_tool_input: bool = True): + pass_tool_call_errors_to_agent: bool = True, + replace_single_quotes_with_double_quotes_in_tool_input: bool = True) -> None: @@ - self.replace_single_quotes_with_double_quotes_in_tool_input = \ - replace_single_quotes_with_double_quotes_in_tool_input + self.replace_single_quotes_with_double_quotes_in_tool_input = ( + replace_single_quotes_with_double_quotes_in_tool_input + )Also applies to: 91-93
src/nat/agent/react_agent/register.py (1)
65-68: Capitalize JSON in the config field description.Aligns with documentation style and clarity.
- replace_single_quotes_with_double_quotes_in_tool_input: bool = Field( - default=True, - description="Whether to replace single quotes with double quotes in the tool input. " - "This is useful for tools that expect structured json input.") + replace_single_quotes_with_double_quotes_in_tool_input: bool = Field( + default=True, + description="Whether to replace single quotes with double quotes in the tool input. " + "This is useful for tools that expect structured JSON input.")tests/nat/agent/test_react.py (2)
675-676: Clarify test intent in docstring.Parsing is attempted; this test asserts fallback-to-string behavior when parsing fails. Reword for precision.
-async def test_tool_node_string_input_no_json_parsing(mock_react_agent): - """Test that plain string input is used as-is without attempting JSON parsing.""" +async def test_tool_node_string_input_falls_back_to_raw(mock_react_agent): + """Test that a plain string input results in a raw pass-through when JSON parsing fails."""
712-717: Make assertion robust to list-wrapping of dict responses.ToolMessage may wrap dict responses into a list upstream; include list in the type check to avoid flakiness.
- # Since this JSON doesn't have a "query" field, the mock tool receives the full dict - # and LangChain can't extract a "query" parameter, so it falls back to default behavior - assert "John" in str(response.content) or isinstance(response.content, dict) + # Since this JSON doesn't have a "query" field, the tool likely receives the full structure. + # Content may be a dict or list-wrapped dict; accept either and also allow stringified content. + assert ("John" in str(response.content)) or isinstance(response.content, (dict, list))
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
docs/source/workflows/about/react-agent.md(1 hunks)src/nat/agent/react_agent/agent.py(3 hunks)src/nat/agent/react_agent/register.py(2 hunks)tests/nat/agent/test_react.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
docs/source/**/*.md
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
docs/source/**/*.md: Use the official naming: first use “NVIDIA NeMo Agent toolkit”; subsequent uses “NeMo Agent toolkit”; never use deprecated names in documentation
Documentation sources must be Markdown under docs/source; keep docs in sync and fix Sphinx errors/broken links
Documentation must be clear, comprehensive, free of TODO/FIXME/placeholders/offensive/outdated terms; fix spelling; adhere to Vale vocab allow/reject lists
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}: Every file must start with the standard SPDX Apache-2.0 header; keep copyright years up‑to‑date
All source files must include the SPDX Apache‑2.0 header; do not bypass CI header checks
Files:
docs/source/workflows/about/react-agent.mdtests/nat/agent/test_react.pysrc/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/agent.py
**/*.{py,md}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Never hard‑code version numbers in code or docs; versions are derived by setuptools‑scm
Files:
docs/source/workflows/about/react-agent.mdtests/nat/agent/test_react.pysrc/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/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:
docs/source/workflows/about/react-agent.mdtests/nat/agent/test_react.pysrc/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/agent.py
docs/source/**/*
⚙️ CodeRabbit configuration file
This directory contains the source code for the documentation. All documentation should be written in Markdown format. Any image files should be placed in the
docs/source/_staticdirectory.
Files:
docs/source/workflows/about/react-agent.md
tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Unit tests must live under tests/ and use configured markers (e2e, integration, etc.)
Files:
tests/nat/agent/test_react.py
⚙️ CodeRabbit configuration file
tests/**/*.py: - Ensure that tests are comprehensive, cover edge cases, and validate the functionality of the code. - Test functions should be named using thetest_prefix, using snake_case. - Any frequently repeated code should be extracted into pytest fixtures. - Pytest fixtures should define the name argument when applying the pytest.fixture decorator. The fixture
function being decorated should be named using thefixture_prefix, using snake_case. Example:
@pytest.fixture(name="my_fixture")
def fixture_my_fixture():
pass
Files:
tests/nat/agent/test_react.py
**/*.py
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.py: Follow PEP 8/20 style; format with yapf (column_limit=120) and use 4-space indentation; end files with a single newline
Run ruff (ruff check --fix) per pyproject.toml; fix warnings unless explicitly ignored; ruff is linter-only
Use snake_case for functions/variables, PascalCase for classes, and UPPER_CASE for constants
Treat pyright warnings as errors during development
Exception handling: preserve stack traces and avoid duplicate logging
When re-raising exceptions, use bareraiseand log with logger.error(), not logger.exception()
When catching and not re-raising, log with logger.exception() to capture stack trace
Validate and sanitize all user input; prefer httpx with SSL verification and follow OWASP Top‑10
Use async/await for I/O-bound work; profile CPU-heavy paths with cProfile/mprof; cache with functools.lru_cache or external cache; leverage NumPy vectorization when beneficial
Files:
tests/nat/agent/test_react.pysrc/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/agent.py
**/tests/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/tests/**/*.py: Test functions must use the test_ prefix and snake_case
Extract repeated test code into pytest fixtures; fixtures should set name=... in @pytest.fixture and functions named with fixture_ prefix
Mark expensive tests with @pytest.mark.slow or @pytest.mark.integration
Use pytest with pytest-asyncio for async code; mock external services with pytest_httpserver or unittest.mock
Files:
tests/nat/agent/test_react.py
src/**/*.py
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
src/**/*.py: All importable Python code must live under src/
All public APIs in src/ require Python 3.11+ type hints on parameters and return values; prefer typing/collections.abc abstractions; use typing.Annotated when useful
Provide Google-style docstrings for every public module, class, function, and CLI command; first line concise with a period; surround code entities with backticks
Files:
src/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/agent.py
src/nat/**/*
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Core functionality under src/nat should prioritize backward compatibility when changed
Files:
src/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/agent.py
⚙️ CodeRabbit configuration file
This directory contains the core functionality of the toolkit. Changes should prioritize backward compatibility.
Files:
src/nat/agent/react_agent/register.pysrc/nat/agent/react_agent/agent.py
🧬 Code graph analysis (2)
tests/nat/agent/test_react.py (4)
src/nat/agent/react_agent/agent.py (3)
ReActGraphState(57-61)tool_node(263-338)ReActAgentGraph(64-365)packages/nvidia_nat_data_flywheel/src/nat/plugins/data_flywheel/observability/schema/sink/elasticsearch/dfw_es_record.py (1)
ToolMessage(88-93)tests/conftest.py (1)
mock_tool(336-358)src/nat/agent/react_agent/register.py (1)
ReActAgentWorkflowConfig(36-79)
src/nat/agent/react_agent/agent.py (1)
src/nat/agent/base.py (2)
_call_tool(127-192)_log_tool_response(194-216)
🪛 markdownlint-cli2 (0.17.2)
docs/source/workflows/about/react-agent.md
94-94: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
⏰ 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
🔇 Additional comments (1)
tests/nat/agent/test_react.py (1)
596-608: Good addition: validates happy-path JSON parsing.Covers the core case with double-quoted JSON and verifies tool receives the expected argument.
Signed-off-by: Yuchen Zhang <[email protected]>
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: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
docs/source/workflows/about/react-agent.md (3)
49-58: Show how to use the new option in the workflow example.Add the option to the sample to make the feature discoverable.
parse_agent_response_max_retries: 2 + replace_single_quotes_with_double_quotes_in_tool_input: false # disable normalization when inputs are quote‑sensitive
60-75: Include the option in the function example as well.Mirror the workflow example so both usage modes are covered.
math_agent: _type: react_agent tool_names: - calculator_multiply - calculator_inequality - calculator_divide + replace_single_quotes_with_double_quotes_in_tool_input: false description: 'Useful for performing simple mathematical calculations.'
144-158: Fix typo: “Djikstra” → “Dijkstra”.Spelling error in examples; user-facing doc per guidelines.
-Thought: To answer this question, I need to find information about Djikstra. +Thought: To answer this question, I need to find information about Dijkstra. @@ -Action Input: Djikstra +Action Input: Dijkstra @@ -Final Answer: Djikstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist. He is best known for his work on the shortest path problem and the development of Dijkstra's algorithm, which is used to find the shortest path between nodes in a weighted graph. +Final Answer: Dijkstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist. He is best known for his work on the shortest path problem and the development of Dijkstra's algorithm, which is used to find the shortest path between nodes in a weighted graph.
🧹 Nitpick comments (1)
docs/source/workflows/about/react-agent.md (1)
78-108: Fix mixed bullet styles and blockquote punctuation (markdownlint MD004).Standardize bullets to dashes in this list and remove the stray dot after the blockquote marker.
-* `tool_names`: A list of tools that the agent can call. The tools must be functions configured in the YAML file. +- `tool_names`: A list of tools that the agent can call. The tools must be functions configured in the YAML file. -* `llm_name`: The LLM the agent should use. The LLM must be configured in the YAML file. +- `llm_name`: The LLM the agent should use. The LLM must be configured in the YAML file. -* `verbose`: Defaults to `False` (useful to prevent logging of sensitive data). If set to `True`, the agent will log input, output, and intermediate steps. +- `verbose`: Defaults to `False` (useful to prevent logging of sensitive data). If set to `True`, the agent will log input, output, and intermediate steps. -* `retry_agent_response_parsing_errors`: Defaults to `True`. If set to `True`, the agent will retry parsing errors. If set to `False`, the agent will raise an exception. +- `retry_agent_response_parsing_errors`: Defaults to `True`. If set to `True`, the agent will retry parsing errors. If set to `False`, the agent will raise an exception. -* `parse_agent_response_max_retries`: Defaults to `1`. Maximum amount of times the agent may retry parsing errors. Prevents the agent from getting into infinite hallucination loops. +- `parse_agent_response_max_retries`: Defaults to `1`. Maximum amount of times the agent may retry parsing errors. Prevents the agent from getting into infinite hallucination loops. -* `tool_call_max_retries`: Defaults to `1`. Maximum amount of times the agent may retry tool call errors. Prevents the agent from getting into infinite tool call loops. +- `tool_call_max_retries`: Defaults to `1`. Maximum amount of times the agent may retry tool call errors. Prevents the agent from getting into infinite tool call loops. -* `max_tool_calls`: Defaults to `15`. The ReAct agent may reason between tool calls, and might use multiple tools to answer the question; the maximum amount of tool calls the agent may take before answering the original question. +- `max_tool_calls`: Defaults to `15`. The ReAct agent may reason between tool calls, and might use multiple tools to answer the question; the maximum amount of tool calls the agent may take before answering the original question. -* `pass_tool_call_errors_to_agent`: Defaults to `True`. If set to `True`, the agent will pass tool call errors to the agent. If set to `False`, the agent will raise an exception. +- `pass_tool_call_errors_to_agent`: Defaults to `True`. If set to `True`, the agent will pass tool call errors to the agent. If set to `False`, the agent will raise an exception. -* `replace_single_quotes_with_double_quotes_in_tool_input`: Defaults to `True`. If set to `True`, the agent will replace single quotes with double quotes in the tool input. This is useful for tools that expect structured input. +- `replace_single_quotes_with_double_quotes_in_tool_input`: Defaults to `True`. When JSON parsing of the tool input fails and this is `True`, the agent attempts a fallback that replaces single quotes with double quotes and retries parsing. Set to `False` to bypass normalization and pass the raw string to the tool (useful when inputs contain SQL or other quote‑sensitive content). -* `description`: Defaults to `"ReAct Agent Workflow"`. When the ReAct agent is configured as a function, this config option allows us to control the tool description (for example, when used as a tool within another agent). +- `description`: Defaults to `"ReAct Agent Workflow"`. When the ReAct agent is configured as a function, this config option allows us to control the tool description (for example, when used as a tool within another agent). -* `system_prompt`: Optional. Allows us to override the system prompt for the ReAct agent. +- `system_prompt`: Optional. Allows us to override the system prompt for the ReAct agent. If modifying the prompt, see the limitations section below. The prompt must have variables for tools, and must instruct the LLM to output in the ReAct output format. -* `max_history`: Defaults to `15`. Maximum number of messages to keep in the conversation history. +- `max_history`: Defaults to `15`. Maximum number of messages to keep in the conversation history. -* `use_openai_api`: Defaults to `False`. If set to `True`, the ReAct agent will output in OpenAI API spec. If set to `False`, strings will be used. +- `use_openai_api`: Defaults to `False`. If set to `True`, the ReAct agent will output in OpenAI API spec. If set to `False`, strings will be used. -* `include_tool_input_schema_in_tool_description`: Defaults to `True`. If set to `True`, the ReAct agent will inspect its tools' input schemas, and append the following to each tool description: - >. Arguments must be provided as a valid JSON object following this format: {tool_schema} +- `include_tool_input_schema_in_tool_description`: Defaults to `True`. If set to `True`, the ReAct agent will inspect its tools' input schemas, and append the following to each tool description: + > Arguments must be provided as a valid JSON object following this format: {tool_schema} -* `additional_instructions`: Optional. Additional instructions to provide to the agent in addition to the base prompt. +- `additional_instructions`: Optional. Additional instructions to provide to the agent in addition to the base prompt.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
docs/source/workflows/about/react-agent.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
docs/source/**/*.md
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
docs/source/**/*.md: Use the official naming: first use “NVIDIA NeMo Agent toolkit”; subsequent uses “NeMo Agent toolkit”; never use deprecated names in documentation
Documentation sources must be Markdown under docs/source; keep docs in sync and fix Sphinx errors/broken links
Documentation must be clear, comprehensive, free of TODO/FIXME/placeholders/offensive/outdated terms; fix spelling; adhere to Vale vocab allow/reject lists
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}: Every file must start with the standard SPDX Apache-2.0 header; keep copyright years up‑to‑date
All source files must include the SPDX Apache‑2.0 header; do not bypass CI header checks
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,md}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Never hard‑code version numbers in code or docs; versions are derived by setuptools‑scm
Files:
docs/source/workflows/about/react-agent.md
**/*
⚙️ 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:
docs/source/workflows/about/react-agent.md
docs/source/**/*
⚙️ CodeRabbit configuration file
This directory contains the source code for the documentation. All documentation should be written in Markdown format. Any image files should be placed in the
docs/source/_staticdirectory.
Files:
docs/source/workflows/about/react-agent.md
🪛 markdownlint-cli2 (0.17.2)
docs/source/workflows/about/react-agent.md
94-94: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
⏰ 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
Signed-off-by: Yuchen Zhang <[email protected]>
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: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/source/workflows/about/react-agent.md (1)
144-158: Fix spelling: “Djikstra” → “Dijkstra”.User-facing typo in two examples.
-Thought: To answer this question, I need to find information about Djikstra. +Thought: To answer this question, I need to find information about Dijkstra. @@ -Final Answer: Djikstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist. He is best known for his work on the shortest path problem and the development of Dijkstra's algorithm, which is used to find the shortest path between nodes in a weighted graph. +Final Answer: Dijkstra was a Dutch computer scientist, programmer, software engineer, mathematician, and science essayist. He is best known for his work on the shortest path problem and the development of Dijkstra's algorithm, which is used to find the shortest path between nodes in a weighted graph.
♻️ Duplicate comments (1)
docs/source/workflows/about/react-agent.md (1)
94-95: Clarification looks correct and aligns with fallback behavior.Accurately documents the conditional normalization (post-parse-failure) and the opt-out for quote-sensitive inputs.
🧹 Nitpick comments (2)
docs/source/workflows/about/react-agent.md (2)
94-95: Fix markdownlint MD004: use dashes for list items.The doc uses “*”; the style expects “-”. Update these lines (and preferably the whole list) to dashes.
-* `replace_single_quotes_with_double_quotes_in_tool_input`: Defaults to `True`. When JSON parsing of the tool input fails and this is `True`, the agent attempts a fallback that replaces single quotes with double quotes and retries parsing. Set to `False` to bypass normalization and pass the raw string to the tool (useful when inputs contain SQL or other quote‑sensitive content). + - `replace_single_quotes_with_double_quotes_in_tool_input`: Defaults to `True`. When JSON parsing of the tool input fails and this is `True`, the agent attempts a fallback that replaces single quotes with double quotes and retries parsing. Set to `False` to bypass normalization and pass the raw string to the tool (useful when inputs contain SQL or other quote‑sensitive content).
105-107: Clean up blockquote formatting.Remove the stray period after “>” for proper rendering.
- >. Arguments must be provided as a valid JSON object following this format: {tool_schema} + > Arguments must be provided as a valid JSON object following this format: {tool_schema}
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
docs/source/workflows/about/react-agent.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
docs/source/**/*.md
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
docs/source/**/*.md: Use the official naming: first use “NVIDIA NeMo Agent toolkit”; subsequent uses “NeMo Agent toolkit”; never use deprecated names in documentation
Documentation sources must be Markdown under docs/source; keep docs in sync and fix Sphinx errors/broken links
Documentation must be clear, comprehensive, free of TODO/FIXME/placeholders/offensive/outdated terms; fix spelling; adhere to Vale vocab allow/reject lists
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}: Every file must start with the standard SPDX Apache-2.0 header; keep copyright years up‑to‑date
All source files must include the SPDX Apache‑2.0 header; do not bypass CI header checks
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,md}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Never hard‑code version numbers in code or docs; versions are derived by setuptools‑scm
Files:
docs/source/workflows/about/react-agent.md
**/*
⚙️ 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:
docs/source/workflows/about/react-agent.md
docs/source/**/*
⚙️ CodeRabbit configuration file
This directory contains the source code for the documentation. All documentation should be written in Markdown format. Any image files should be placed in the
docs/source/_staticdirectory.
Files:
docs/source/workflows/about/react-agent.md
🪛 markdownlint-cli2 (0.17.2)
docs/source/workflows/about/react-agent.md
94-94: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
⏰ 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
willkill07
left a comment
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.
Just one nit on naming. Otherwise LGTM!
Signed-off-by: Yuchen Zhang <[email protected]>
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: 0
♻️ Duplicate comments (1)
docs/source/workflows/about/react-agent.md (1)
94-95: Good fix: fallback behavior and opt‑out are now clear.This addresses the earlier feedback to document that normalization is attempted only after a JSON-parse failure, and to recommend disabling it for quote‑sensitive inputs.
🧹 Nitpick comments (1)
docs/source/workflows/about/react-agent.md (1)
94-95: Fix markdownlint MD004: use dash list marker.Project lint expects dashes, not asterisks, for unordered lists.
Apply:
-* `normalize_tool_input_quotes`: Defaults to `True`. When JSON parsing of the tool input fails and this is `True`, the agent attempts a fallback that replaces single quotes with double quotes and retries parsing. Set to `False` to bypass normalization and pass the raw string to the tool (useful when inputs contain SQL or other quote‑sensitive content). +- `normalize_tool_input_quotes`: Defaults to `True`. When JSON parsing of the tool input fails and this is `True`, the agent attempts a fallback that replaces single quotes with double quotes and retries parsing. Set to `False` to bypass normalization and pass the raw string to the tool (useful when inputs contain SQL or other quote‑sensitive content).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
docs/source/workflows/about/react-agent.md(1 hunks)src/nat/agent/react_agent/agent.py(3 hunks)src/nat/agent/react_agent/register.py(2 hunks)tests/nat/agent/test_react.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- tests/nat/agent/test_react.py
- src/nat/agent/react_agent/agent.py
- src/nat/agent/react_agent/register.py
🧰 Additional context used
📓 Path-based instructions (5)
docs/source/**/*.md
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
docs/source/**/*.md: Use the official naming: first use “NVIDIA NeMo Agent toolkit”; subsequent uses “NeMo Agent toolkit”; never use deprecated names in documentation
Documentation sources must be Markdown under docs/source; keep docs in sync and fix Sphinx errors/broken links
Documentation must be clear, comprehensive, free of TODO/FIXME/placeholders/offensive/outdated terms; fix spelling; adhere to Vale vocab allow/reject lists
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
**/*.{py,sh,md,yml,yaml,toml,ini,json,ipynb,txt,rst}: Every file must start with the standard SPDX Apache-2.0 header; keep copyright years up‑to‑date
All source files must include the SPDX Apache‑2.0 header; do not bypass CI header checks
Files:
docs/source/workflows/about/react-agent.md
**/*.{py,md}
📄 CodeRabbit inference engine (.cursor/rules/general.mdc)
Never hard‑code version numbers in code or docs; versions are derived by setuptools‑scm
Files:
docs/source/workflows/about/react-agent.md
**/*
⚙️ 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:
docs/source/workflows/about/react-agent.md
docs/source/**/*
⚙️ CodeRabbit configuration file
This directory contains the source code for the documentation. All documentation should be written in Markdown format. Any image files should be placed in the
docs/source/_staticdirectory.
Files:
docs/source/workflows/about/react-agent.md
🪛 markdownlint-cli2 (0.17.2)
docs/source/workflows/about/react-agent.md
94-94: Unordered list style
Expected: dash; Actual: asterisk
(MD004, ul-style)
⏰ 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
🔇 Additional comments (1)
docs/source/workflows/about/react-agent.md (1)
94-95: No changes needed—normalize_tool_input_quotesis used consistently
All code, tests, configs, and docs reference onlynormalize_tool_input_quotes; there are no instances ofreplace_single_quotes_with_double_quotes_in_tool_input.
|
/merge |
Description
The current logic of quote normalization is causing bugs on certain types of inputs (e.g. Complex SQL queries nested in JSON format). This PR added a
normalize_tool_input_quotesoption forReActagent to provide the option to directly use the raw string as tool input without quote normalization.Closes AIQ-1721
By Submitting this PR I confirm:
Summary by CodeRabbit
New Features
Documentation
Tests