[Station][Inference] TUI token counter shows ? after successful ollama-local inference instead of actual token usage
Description
Description
When using the ollama-local provider, the OpenClaw TUI status bar always shows "tokens ?/131k" — the used-token count never updates from ? even after a confirmed successful inference round-trip. Cloud providers (openai, anthropic, nvidia) update the counter correctly after each response.Environment
Device: Station OS: Ubuntu 24.04.4 LTS Architecture: aarch64 Node.js: v22.22.2 npm: 10.9.7 Docker: Docker version 29.2.1, build a5c7197 OpenShell CLI: openshell 0.0.36 NemoClaw: v0.0.31 OpenClaw: 2026.4.24 (cbcfdf6) Ollama: latest (installed via https://ollama.com/install.sh) Model: qwen2.5:7bSteps to Reproduce
1. Install NemoClaw and onboard with ollama-local provider (ollama must be running on host) 2. nemoclawExpected Resultconnect 3. Inside sandbox: openclaw tui 4. Send any prompt, e.g. "say hello in one sentence" 5. Wait for inference to complete (status bar shows "idle") 6. Observe the token count in the status bar
Status bar shows actual token usage after inference completes, e.g.: agent main | session main | inference/qwen2.5:7b | tokens 142/131kActual Result
Status bar shows ? indefinitely regardless of how many prompts are sent: agent main | session main | inference/qwen2.5:7b | tokens ?/131k The ? never resolves to a number for ollama-local. Inference itself succeeds — gateway log confirms: [ws] res chat.history 8983ms [sandbox] NET:OPEN ALLOWED inference.local:443 [sandbox] routing proxy inference request endpoint=http://host.openshell.internal:11435/v1 path=/v1/chat/completionsLogs
Captured from: nemoclaw my-assistant logs + openclaw tui session Host: galaxy-sku2-018, NemoClaw v0.0.31, provider: ollama-local, model: qwen2.5:7b Note: "tokens ?" also appears transiently before the first prompt is sent (expected / separate known state). This bug is specifically about the count remaining ? after inference completes successfully. Note: This issue does not affect cloud providers. Related upstream context: Ollama token count inconsistency for specific models tracked in Bug 5667866 (Gemma 3n), but the issue here is broader — ? for all models via ollama-local, not a count mismatch.
Bug Details
| Field | Value |
|---|---|
| Priority | Unprioritized |
| Action | Dev - Open - To fix |
| Disposition | Open issue |
| Module | Machine Learning - NemoClaw |
| Keyword | NemoClaw, NemoClaw_Agent&Skills, NEMOCLAW_GH_SYNC_APPROVAL, NemoClaw_Inference |
[NVB#6130030]
✨ Thanks for submitting this issue that identifies a bug where the TUI token counter shows ? after successful ollama-local inference instead of actual token usage. This proposes an investigation into the token counting mechanism, specifically when using the ollama-local provider on Linux.
PR #3678 opened for this.
Diagnosis summary. OpenClaw's openai-transport-stream.ts (upstream) only adds stream_options.include_usage: true to the request when the model's compat.supportsUsageInStreaming is set. OpenClaw's Ollama extension auto-sets that flag, but only when isOllamaCompatProvider(model) recognises the endpoint — which it can't, because NemoClaw routes ollama-local traffic via the standardised https://inference.local/v1 URL (the OpenShell gateway's loopback-equivalent), not via localhost:11434. Result: Ollama's /v1/chat/completions stream omits the trailing usage chunk, OpenClaw's parseTransportChunkUsage never runs, and the TUI's tokens X/Y field stays ? forever.
Fix. Force model.compat.supportsUsageInStreaming = true in scripts/generate-openclaw-config.py when NEMOCLAW_PROVIDER_KEY is one of ollama / ollama-local (the same set already tracked by _bundled_provider_plugins["ollama"]). This mirrors LM Studio's identical workaround (withLmstudioUsageCompat upstream).
Validation.
provider_key='ollama' compat.supportsUsageInStreaming=True PASS
provider_key='ollama-local' compat.supportsUsageInStreaming=True PASS
provider_key='openai' compat.supportsUsageInStreaming=None PASS
provider_key='anthropic' compat.supportsUsageInStreaming=None PASS
provider_key='vllm' compat.supportsUsageInStreaming=None PASS
provider_key='nim-local' compat.supportsUsageInStreaming=None PASS
npx vitest run test/generate-openclaw-config.test.ts — 70/70 pass, three new regression cases included.
Honest correction: PR #3678 shipped to main but did not actually fix this in production. The Python-side conditional in scripts/generate-openclaw-config.py checked NEMOCLAW_PROVIDER_KEY in {"ollama", "ollama-local"}, but getSandboxInferenceConfig("model", "ollama-local") falls through to the default switch arm and returns providerKey = "inference" — the same value all managed-inference providers use — so the conditional was dead code. The regression tests passed only because they injected NEMOCLAW_PROVIDER_KEY=ollama directly, an env shape no real onboard produces.
Verified by running the script standalone with the env values an ollama-local docker build actually receives on current main: model.compat = null (no flag).
PR #3683 moves the supportsUsageInStreaming: true wiring to the proper layer — an explicit "ollama-local" case in getSandboxInferenceConfig that sets inferenceCompat = { supportsUsageInStreaming: true }. The existing NEMOCLAW_INFERENCE_COMPAT_B64 round-trip carries the flag into model.compat for real this time, and drops the redundant Python conditional plus the three unrealistic vitest cases #3678 added.
Re-opening this until #3683 merges. Sorry for the noise.
Closing as fixed by #4204 (merged 2026-06-02, shipped in v0.0.57 and v0.0.58).
This is the production gap I called out earlier on this issue: NemoClaw routes ollama-local through the managed inference/<model> provider, so inside the sandbox OpenClaw never sees an ollama/ollama-local provider key and can't apply its own streaming-usage fallback — leaving the TUI stuck on tokens ?/131k. PR #3678's config-script conditional keyed on the provider name and therefore silently no-op'd on this Express path.
#4204 fixes it at the source-of-truth boundary, and I verified the full host→sandbox chain on current main (f65321b6a):
- Host —
getSandboxInferenceConfig(model, "ollama-local")now seedsinferenceCompat = { supportsUsageInStreaming: true }even though the route still points at the managed provider (src/lib/inference/config.ts:225-238). - Serialization —
patchDockerfilewrites that compat dict intoARG NEMOCLAW_INFERENCE_COMPAT_B64(src/lib/onboard/dockerfile-patch.ts:57-115). - Sandbox —
generate-openclaw-config.mtsdecodes the env var back intoinferenceCompat(with a redundant??= truefallback for the directollama/ollama-localkeys at line 832-833), so OpenClaw emitsstream_options.include_usage=trueand the counter resolves.
Regression tests for this path pass on main (config.test.ts ollama/supportsUsageInStreaming cases + the dockerfile-patch compat assertions). I don't have Station/aarch64 + local-Ollama hardware to re-run the live TUI repro, so flagging for QA to confirm tokens N/131k resolves on the Station path against a v0.0.57+ build — but the code path that produced the ? is now closed end-to-end.