fix(agents): parse prompt_tokens/completion_tokens in CLI usage for llama.cpp compatibility (#77992)#78085
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep open: current main and the latest release still have the CLI parser alias gap, but this PR is not merge-ready because it duplicates shared usage-normalization logic and still lacks contributor real behavior proof. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main routes CLI JSON/JSONL usage payloads through Is this the best way to solve the issue? No: the PR fixes the immediate alias pair, but Security review: Security review cleared: The diff only changes TypeScript usage parsing and a focused unit test; no security or supply-chain surface is touched. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 010b61746379. |
byungskers
left a comment
There was a problem hiding this comment.
This is a great compatibility fix for llama.cpp and other OpenAI-compatible local providers. The fallback chain for usage fields is well-structured — prioritizing the modern input/output fields first while gracefully falling back to prompt/completion_tokens. The test case with the detailed comment explaining the issue is especially helpful for future maintainers.
…t for llama.cpp (openclaw#77992) llama.cpp and other OpenAI-compatible local providers return usage as { prompt_tokens, completion_tokens } instead of { input_tokens, output_tokens }. The toCliUsage() function in cli-output.ts only accepted input_tokens / output_tokens (and their camelCase aliases), so llama.cpp usage was silently dropped and context display showed "?/131k" for all llama.cpp users. Add prompt_tokens and completion_tokens as fallback keys for totalInput and output respectively in toCliUsage(). Both parseCliJson and parseCliJsonl go through this function, so the fix covers all CLI output parsing paths. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1eae9bc to
383946f
Compare
|
This pull request has been automatically marked as stale due to inactivity. |
|
@Beandon13 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(agents): parse prompt_tokens/completion_tokens in CLI usage for llama.cpp compatibility (#77992) This is item 1/1 in the current shard. Shard 8/22. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
Summary
toCliUsage()incli-output.tsonly recognizedinput_tokens/output_tokens(and camelCase aliases) from CLI runner output. llama.cpp and other OpenAI-compatible local providers returnprompt_tokens/completion_tokensinstead, which are the standard OpenAI field names.?/131kfor all llama.cpp, Ollama, and similar OpenAI-compatible users.prompt_tokens→ fallback fortotalInputandcompletion_tokens→ fallback foroutputintoCliUsage(). BothparseCliJsonandparseCliJsonlroute through this function, so all CLI output parsing paths are covered.Closes #77992
Testing
Real behavior proof
?/131kwith llama.cpp after upgrading to 2026.5.4 — field name mismatch causes usage to be silently droppedprompt_tokens,completion_tokens,total_tokens).proof:override or advise on evidence format.