Call tool shutdown hooks after generation#1468
Conversation
Signed-off-by: tamohannes <hovhannes.tamoyan@gmail.com>
|
Actionable comments posted: 0 |
|
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 (5)
📝 WalkthroughWalkthroughThis PR adds explicit shutdown lifecycle management to three inference classes. ChangesShutdown Lifecycle for Inference Components
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
Adds shutdown hooks for tool/code execution wrappers and ensures
GenerationTask.generate()calls them from afinallyblock. This covers normal completion, errors, and early exits.Why
Tool sessions, sandbox clients, or subprocess-backed providers should be closed before process exit. Without a guaranteed shutdown path, cleanup can hang or leak resources after outputs are already produced.
Tests
python -m pytest tests/test_mcp_clients.py::test_tool_calling_wrapper_shutdown_calls_registered_tools tests/test_generation.py::test_generation_task_shutdown_awaits_async_llm_shutdown -qpython -m ruff check nemo_skills/inference/generate.py nemo_skills/inference/model/code_execution.py nemo_skills/inference/model/tool_call.py tests/test_generation.py tests/test_mcp_clients.pySummary by CodeRabbit
Bug Fixes
Tests