Skip to content

Add reconciled token usage bridge - #1688

Open
QingJunXue wants to merge 1 commit into
BigPizzaV3:mainfrom
QingJunXue:feature/reconciled-token-usage
Open

Add reconciled token usage bridge#1688
QingJunXue wants to merge 1 commit into
BigPizzaV3:mainfrom
QingJunXue:feature/reconciled-token-usage

Conversation

@QingJunXue

Copy link
Copy Markdown

Summary

  • add a single local /token-usage/events bridge without a price endpoint or billing-provider dependency
  • reconcile MessagePort, rollout JSONL, subagent rollout files, and protocol-proxy Usage events
  • capture Input, Cached Input, Cache Write, Output, Reasoning, request status, retries, and Usage-missing responses
  • follow the dynamically selected Helper port and prevent local proxy URLs from becoming upstream URLs
  • add bounded stream lifetimes, downstream-disconnect resilience, ledger rotation, and diagnostic-log rotation

Disk and privacy behavior

  • rollout files are read fully once, then tailed incrementally
  • proxy ledger rotates at 20 MB and retains three archives
  • diagnostic logs rotate at 20 MB and retain three archives
  • high-frequency successful bridge events are not persisted
  • the Usage ledger stores no prompts, response text, API keys, or upstream URLs

Verification

  • cargo fmt --all -- --check
  • Token Usage tests: 13/13
  • Bridge route tests: 27/27
  • Protocol proxy tests: 48/48
  • Relay configuration tests: 103/103
  • Launcher tests: 74/74, with one unrelated Windows symlink-privilege test skipped
  • Diagnostic log tests: 3/3
  • scoped Clippy: 0 warnings in the new Token Usage implementation
  • cargo build --release -p codex-plus-launcher

The skipped launcher test requires Windows symbolic-link privilege and fails with OS error 1314 independently of this change.

Capture terminal Responses usage and retry attempts in a bounded local ledger, reconcile it with rollout tails through a single bridge route, follow the selected helper port, and rotate high-volume diagnostics. Includes privacy-focused documentation and regression coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant