fix: do not forward the unknown-model sentinel as a per-request model override - #2141
fix: do not forward the unknown-model sentinel as a per-request model override#2141knQzx wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe React agent adds an unknown-model sentinel and prevents it or ChangesModel override handling
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/nvidia_nat_langchain/src/nat/plugins/langchain/agent/react_agent/register.py (1)
46-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the sentinel comment and definition with the upstream contract.
ChatRequest.modeldefaults toNone; only the plain-string converter injects"unknown-model". This comment is misleading, and the sentinel literal is duplicated across packages. Prefer a shared constant or update the comment to document the converter behavior.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/nvidia_nat_langchain/src/nat/plugins/langchain/agent/react_agent/register.py` around lines 46 - 48, The _UNKNOWN_MODEL_SENTINEL definition and comment should reflect the upstream contract: ChatRequest.model defaults to None, while only the plain-string converter supplies "unknown-model". Reuse the existing shared sentinel constant if available; otherwise update the comment to describe the converter behavior without implying ChatRequest.model uses it by default.packages/nvidia_nat_langchain/tests/agent/test_react.py (1)
1809-1811: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winCover the unsupported-backend sentinel path.
Add an assertion using
supports_override=False; this ensures the sentinel is ignored before the backend capability check and can never raise an unsupported-override error.Proposed test addition
assert "configurable" not in _build_lc_config(5, sentinel_model) + assert "configurable" not in _build_lc_config(5, sentinel_model, supports_override=False) assert "configurable" not in _build_lc_config(5, None)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/nvidia_nat_langchain/tests/agent/test_react.py` around lines 1809 - 1811, Extend the sentinel-model assertions in the test covering _build_lc_config to pass supports_override=False, verifying the sentinel is ignored before backend capability validation and does not raise an unsupported-override error. Keep the existing assertions for the default behavior and None model unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/nvidia_nat_langchain/tests/agent/test_react.py`:
- Around line 1802-1803: Update the regression test docstring in the test
covering the `unknown-model` sentinel so its opening descriptive sentence is
concise, ends with a period on the same line, and uses backticks around code
entities such as `unknown-model` and `ChatRequest`.
---
Nitpick comments:
In
`@packages/nvidia_nat_langchain/src/nat/plugins/langchain/agent/react_agent/register.py`:
- Around line 46-48: The _UNKNOWN_MODEL_SENTINEL definition and comment should
reflect the upstream contract: ChatRequest.model defaults to None, while only
the plain-string converter supplies "unknown-model". Reuse the existing shared
sentinel constant if available; otherwise update the comment to describe the
converter behavior without implying ChatRequest.model uses it by default.
In `@packages/nvidia_nat_langchain/tests/agent/test_react.py`:
- Around line 1809-1811: Extend the sentinel-model assertions in the test
covering _build_lc_config to pass supports_override=False, verifying the
sentinel is ignored before backend capability validation and does not raise an
unsupported-override error. Keep the existing assertions for the default
behavior and None model unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 696a05f2-208f-4ea5-a669-d496745ff658
📒 Files selected for processing (2)
packages/nvidia_nat_langchain/src/nat/plugins/langchain/agent/react_agent/register.pypackages/nvidia_nat_langchain/tests/agent/test_react.py
…request override Signed-off-by: knQzx <75641500+knQzx@users.noreply.github.com>
f74768e to
b23575c
Compare
|
I verified this independently against The chain, link by link. def _string_to_nat_chat_request(data: str) -> ChatRequest:
return ChatRequest.from_string(data, model="unknown-model") # api_server.py:954-955
So on Fixing inside The one thing I'd change: the sentinel now has two independent definitions. This repo already has the pattern for the fix: Minor, and I think intentional: with the sentinel short-circuiting the whole block, it no longer reaches the AI-assisted review. The code paths above were read on |
Description
Closes #2110
when a model can't be resolved, the ReAct agent builder receives the sentinel
model="unknown-model"and forwards it straight through as a per-requestconfigurable.model_nameoverride, so every downstream LLM/NIM call is told to use a model literally namedunknown-modeland the provider returns 404. this is a regression from #2036, which introduced the sentinel but didn't guard against forwarding itthe fix treats the
unknown-modelsentinel the same as an unset model - the per-request model override is only applied when a real model name is presentreproduce: build a ReAct agent whose model resolves to the
unknown-modelsentinel (an unresolved model reference), then run it. on develop the request carriesconfigurable: {model_name: "unknown-model"}and the call 404s; with this change no model override is attached and the configured default is used. the addedtest_build_lc_config_ignores_unknown_model_sentinelasserts the sentinel is not forwardedBy Submitting this PR I confirm:
Summary by CodeRabbit