fix(gateway): preserve OpenAI usage aliases in chat history#85383
Conversation
|
Codex review: needs maintainer review before merge. Latest ClawSweeper review: 2026-05-22 13:59 UTC / May 22, 2026, 9:59 AM ET. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. for source reproduction: current main's sanitizer allowlist drops the exact OpenAI-compatible usage aliases reported by llama.cpp, and downstream usage normalization already knows how to consume them. I did not run a live llama.cpp server, so this is source-reproducible rather than fully reproduced end to end. PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the narrow sanitizer allowlist and regression test after maintainer review, then close the linked llama.cpp context-display bug once the PR is merged and CI or a focused live-provider check confirms the behavior. Do we have a high-confidence way to reproduce the issue? Yes for source reproduction: current main's sanitizer allowlist drops the exact OpenAI-compatible usage aliases reported by llama.cpp, and downstream usage normalization already knows how to consume them. I did not run a live llama.cpp server, so this is source-reproducible rather than fully reproduced end to end. Is this the best way to solve the issue? Yes, the PR appears to solve the issue in the right layer by preserving known numeric usage aliases while continuing to strip unrelated provider payload fields. A live provider smoke would improve confidence, but the code path and regression test are the narrow maintainable fix. Label changes:
Label justifications:
Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c21ca883b0cc. |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Pearl Branchling Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
Summary
prompt_tokens,completion_tokens, andtotal_tokensFixes #77992.
Verification
/Users/steipete/.local/share/fnm/node-versions/v24.13.0/installation/bin/node ./node_modules/.bin/tsx -e "...sanitizeChatHistoryMessages usage alias assertion..."git diff --check.agents/skills/autoreview/scripts/autoreview --mode localBehavior addressed: llama.cpp/OpenAI-compatible usage metadata no longer loses
prompt_tokens,completion_tokens, andtotal_tokensbefore chat/session display code can compute context usage.Real environment tested: local OpenClaw checkout on Node 24.13.0 with the gateway chat display sanitizer executed directly; GitHub CI will run the full repository gates.
Exact steps or command run after this patch: direct Node 24
tsxassertion forsanitizeChatHistoryMessages,git diff --check, and Codex autoreview local mode.Evidence after fix: the direct assertion verified sanitized assistant history preserves the three OpenAI-compatible numeric usage fields and still discards an unrelated provider payload field.
Observed result after fix: direct assertion printed
usage aliases ok; autoreview reported no accepted/actionable findings.What was not tested: a live llama.cpp server; this patch covers the deterministic projection path that was dropping the reported usage fields.