Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

GTC Berlin side quest: one import hid 7 NVIDIA agent tools, so I made it lazy

Описание и применение

В чистой установке NVIDIA NeMo Agent Toolkit семь встроенных инструментов не регистрировались из‑за импорта LangChain при загрузке модуля. Переместив импорт внутрь метода, все инструменты теперь регистрируются, и валидатор проходит без ошибок.

Задача

On a plain install of NVIDIA’s NeMo Agent Toolkit, seven built‑in tools were not registered because a module imported a LangChain class at import time, causing a ModuleNotFoundError that stopped the plugin loader.

Результат

The fix moved a LangChain import from module level to a method, allowing all built‑in tools to register on a plain install. Validation now succeeds and the warning disappears.

Рабочий процесс

  • 1. Build a fresh virtual environment with only nvidia-nat-core and nvidia-nat-atif.
  • 2. Run nat validate on a workflow using the code_execution tool.
  • 3. Observe the validator error and the warning about missing langchain_core.
  • 4. Inspect nat/tool/register.py to see the import order.
  • 5. Identify that nvidia_rag.py imports langchain_core.Document at module level.
  • 6. Move the import inside the to_document() method.
  • 7. Add a regression test that mocks sys.modules to block langchain_core and verifies registration.
  • 8. Run the full test suite; all tests pass.
  • 9. Merge PR #2474, approved within 19 hours.
  • 10. Verify that nat validate now succeeds and no warning is logged.

Доказательства

Seven of the library's 12 built-in tools never registered, and the error message pointed somewhere else entirely.

Источник

The toolkit registers its built-in tools by importing a list of modules, one after another. One of those modules asked for a LangChain class the moment it was imported.

Источник

Move the import to the moment it is needed. Document is only used inside one method, the one that turns a RAG result into a LangChain document, so the import now lives inside that method.

Источник

The regression test plays the plain install on any machine: it blocks every langchain_core entry in sys.modules, imports nat.tool.nvidia_rag fresh against a mocked registry, and checks that the tool registers.

Источник

  • Дата записи: 2026-11-01T18:59:21.799Z