NVIDIA NIM reasoning models: chat_template_kwargs never injected, breaking streamed reasoning_content and causing inconsistent latency #1888
opassoca
started this conversation in
Show and tell
Replies: 1 comment
|
please report this issue in a issue ticket not here, thank you. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Root cause and fix for inconsistent streaming and missing reasoning traces when running NIM backed reasoning models (deepseek-ai/deepseek-v4-pro, z-ai/glm-5.2) through OpenClaude.
Symptom: response text arrives in irregular bursts, sometimes near instant, sometimes stalling for a second or more, and the reasoning or thinking block that NIM is capable of streaming never renders in the CLI, even on models where it should.
I reverse engineered the shipped bundle (@gitlawb/openclaude, dist/cli.mjs, npm build dated Jul 7 2026, 21MB minified) rather than guessing. chat_template_kwargs and enable_thinking have zero occurrences anywhere in that file. Both wire formats that cover NIM routed models, deepseek_compatible and zai_compatible, only ever populate body.thinking or body.reasoning_effort in the OpenAI compatible request shim. Neither path ever sets chat_template_kwargs, which is the parameter the NIM template layer actually reads to gate bounded, streamed reasoning_content. Absent that signal, the upstream model still reasons, just without a budget or streaming contract on the NIM side, which lines up exactly with the erratic delivery and the silent drop of the reasoning trace.
The fix is a single conditional inserted immediately after the existing reasoning_effort handling in both wire format branches: when request.baseUrl contains integrate.api.nvidia.com, set body.chat_template_kwargs equal to thinking true and enable_thinking true, before the request is dispatched. Verified against deepseek-ai/deepseek-v4-pro on NIM: streaming is now continuous and the reasoning trace renders correctly, matching the documented contract for the DeepSeek and GLM builds on NIM.
This is currently a runtime patch against the minified dist bundle only, since the npm package ships without the matching TypeScript source for the provider shim. It needs to land in the actual openai-compat shim source to survive the next release. The exact patch, anchor string and injected snippet, is ready to hand off if a maintainer wants to take it from here.
All reactions