Commit 605e7bf
committed
fix(inference): wire ollama-local supportsUsageInStreaming via getSandboxInferenceConfig (#2747)
Follow-up to #3678. That PR added a Python-side conditional in
`generate-openclaw-config.py` that toggled `supportsUsageInStreaming`
when `NEMOCLAW_PROVIDER_KEY` was `"ollama"` or `"ollama-local"`. However,
in real onboard runs `getSandboxInferenceConfig("model", "ollama-local")`
hits the default switch arm and returns `providerKey = "inference"` —
the same value used by all managed-inference providers — so the
build-time `NEMOCLAW_PROVIDER_KEY` is never `"ollama"` and the
conditional was dead code. The earlier regression tests in
`test/generate-openclaw-config.test.ts` passed only because they set
`NEMOCLAW_PROVIDER_KEY=ollama` directly, which never happens in
production.
Verified locally with the python script and the real env values
NemoClaw passes through at docker build time
(`NEMOCLAW_PROVIDER_KEY=inference`,
`NEMOCLAW_INFERENCE_BASE_URL=https://inference.local/v1`,
`NEMOCLAW_INFERENCE_COMPAT_B64=e30=` for an empty compat): the
generated `openclaw.json` has `model.compat = null`, confirming the
flag never landed.
Move the wiring to the proper layer: add an explicit `"ollama-local"`
case in `getSandboxInferenceConfig` that sets
`inferenceCompat = { supportsUsageInStreaming: true }`. The existing
encode-into-`NEMOCLAW_INFERENCE_COMPAT_B64` path then carries the flag
into the python script's `inference_compat` dict, which writes it onto
`model.compat` exactly as before — except now it actually fires for
ollama-local builds. Cloud providers and other local backends keep
their existing `inferenceCompat` (or absence thereof).
Drop the now-redundant python conditional, drop the three
unrealistic-fixture vitest cases from `test/generate-openclaw-config.test.ts`,
and add two new ones in `src/lib/inference/config.test.ts` that
exercise `getSandboxInferenceConfig` with realistic provider names.
Test plan
- `npx vitest run src/lib/inference/config.test.ts` — 24/24 pass,
including the two new ones
(`forces supportsUsageInStreaming for ollama-local`,
`does not force supportsUsageInStreaming for non-ollama providers`)
- `npx vitest run test/generate-openclaw-config.test.ts` — 67/67 pass
(was 70/70 with the three deleted unrealistic cases)
- Direct script run with prod-shaped env values:
`NEMOCLAW_INFERENCE_COMPAT_B64={"supportsUsageInStreaming":true}`
(the shape TypeScript will emit for ollama-local) →
`model.compat = {'supportsUsageInStreaming': True}` in generated
openclaw.json ✓
Signed-off-by: Shawn Xie <shaxie@nvidia.com>1 parent 50ad764 commit 605e7bf
4 files changed
Lines changed: 54 additions & 82 deletions
File tree
- scripts
- src/lib/inference
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | 426 | | |
445 | 427 | | |
446 | 428 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
285 | 322 | | |
286 | 323 | | |
287 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
221 | 238 | | |
222 | 239 | | |
223 | 240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | 417 | | |
482 | 418 | | |
483 | 419 | | |
| |||
0 commit comments