fix(runtime): use prependSystemContext to prevent runtime instructions leaking into chat UI#4037
Conversation
…s leaking into chat UI The <nemoclaw-runtime> context block was injected via prependContext, which prepends to the user-visible conversation prompt. On certain models (e.g. Nemotron 3 Super 120B via Ollama), this caused the sandbox policy instructions to appear in the chat UI on the third message. Switch to prependSystemContext, which injects into the system prompt (invisible to users), matching the intent of these instructions as system-level runtime context. Fixes NVIDIA#4019
|
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)
📝 WalkthroughWalkthroughThe PR renames the hook response field that carries runtime context from ChangesRuntime Context Field Migration
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
|
✨ Thanks for submitting this detailed PR about preventing system runtime instructions from leaking into the chat UI. This proposes a way to improve the security and usability of NemoClaw by ensuring that system-level runtime context is not displayed to the user. Related open issues: |
Summary
Fixes #4019 — system runtime instructions (
<nemoclaw-runtime>block) leaking into the chat UI on the third message.Root Cause
registerRuntimeContext()was usingprependContextin thebefore_prompt_buildhook return. In the OpenClaw host,prependContextprepends content to the user-visible conversation prompt, which means the sandbox policy instructions could appear in the chat UI — especially with models like Nemotron 3 Super 120B via Ollama that may echo prepended context.Fix
Switch from
prependContexttoprependSystemContext, which injects into the system prompt (invisible to users). This matches the intent of these instructions as system-level runtime context that should never be displayed to the user.Changes
nemoclaw/src/runtime-context.ts:prependContext→prependSystemContext(1 line)nemoclaw/src/runtime-context.test.ts: Updated test expectations to match (3 test assertions)Testing
Summary by CodeRabbit