fix(grok): preserve billing defaults in nonempty requests - #3805
Conversation
Encode exclude_legacy_monthly_usage=false explicitly so billing requests contain a protobuf message without changing legacy monthly semantics. Verify bearer, cookie, combined-auth, and retry request bytes. Add synthetic proof that an unavailable CLI billing method still permits proxy quota and local tokens to reach the dashboard and share payload. Usage JSON intentionally omits that live-only history; #3716 remains open. Refs #3336, #3716 Co-authored-by: charlielz <1540060247@qq.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 2:47 AM ET / 06:47 UTC. ClawSweeper reviewWhat this changesThe branch sends an explicitly false billing flag in a nonempty Grok request and adds tests and documentation for request encoding and local-token fallback behavior. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful, focused repair absent from current main and v0.63.0. No actionable correctness or security defect was found, and repository policy protects this owner-authored PR from automatic closure. Priority: P2 Review scores
Verification
How this fits togetherCodexBar’s Grok provider combines CLI and web billing results into usage snapshots for the menu and dashboard. The changed request feeds the existing web billing parser and fallback logic. flowchart LR
A[Grok credentials] --> B[Usage fetch strategy]
B --> C[CLI proxy billing]
B --> D[Nonempty web billing request]
D --> E[Billing response parser]
C --> F[Usage snapshot]
E --> F
G[Local session history] --> F
F --> H[Menu and dashboard]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Preserve the explicit-false request encoding and existing billing semantics, while keeping live dashboard diagnosis and dollar-spend work separate. Do we have a high-confidence way to reproduce the issue? No: source confirms the empty request on main, but the reported server rejection and affected-account recovery were not reproduced in this read-only review. Is this the best way to solve the issue? Yes: explicitly encoding the documented false default is a narrow way to supply a nonempty message without changing billing selection or response interpretation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7678afe828f1. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
steipete#3805 added a regression that keeps local Grok tokens through the RPC-to-proxy fallback, with a fixture that carries only `signals.json` and expects its context-window occupancy to surface as 42 tokens. This branch deliberately stops counting occupancy — `signals.json` is session metadata only, and local history comes from completed turns — so on the merged tree the fallback kept no history and the test failed. The fixture now records one completed 42-token turn beside the same `signals.json`, which keeps the test's subject (the fallback retains local history) and demonstrates the branch's contract (occupancy is not counted). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Grok's web billing request currently contains an empty protobuf message, which can be rejected with gRPC status 13 (
Missing request message.). Encode field 1,exclude_legacy_monthly_usage, explicitly as false:00 00 00 00 02 08 00. The public billing descriptor confirms the boolean contract;08 02would mean true. Authentication, the 15-second timeout, retries, response parsing, and unknown-usage semantics are unchanged. Thanks @CharlieLZ for the original request fix and report.The synthetic #3716 investigation also follows a CLI
-32601failure through proxy billing, real localsignals.jsonscanning, Usage & Spend, and the share payload. It passes on unchanged production code: 42 tokens survive in memory, while usage JSON intentionally omits live-onlycostUsage. This PR documents and tests that distinction; it does not claim to fix the reported dashboard state or introduce Grok dollar estimates. No authenticated provider probe, browser-cookie import, Keychain access, or running-app relaunch was performed.Validation
GrokWebBillingFetcherTestsran 49 tests with 4 failures, all detecting the empty request body on bearer, cookie, combined-auth, and retry paths.GrokAccountContextTestspassed 8 tests, including the new RPC-to-share proof.make checkpassed: 0/2,518 files require formatting; SwiftLint found 0 violations across 2,517 files. Parser hash remained current; no generated files changed.git diff --checkpassed. A merge-tree check against main7678afe828f1found no conflicts.Exact commands:
The first command records the intentional pre-fix failures; the third verifies the corrected implementation. The full sharded suite was not run; validation is limited to the focused suites above. Live recovery for the affected billing account remains unverified.
Closes #3336
Refs #3716
Refs #3135