Skip to content

feat(api): enrich provider.list with usage freshness and recent token signals#18439

Open
LucasSantana-Dev wants to merge 1 commit into
anomalyco:devfrom
LucasSantana-Dev:feature/provider-usage-freshness-signals
Open

feat(api): enrich provider.list with usage freshness and recent token signals#18439
LucasSantana-Dev wants to merge 1 commit into
anomalyco:devfrom
LucasSantana-Dev:feature/provider-usage-freshness-signals

Conversation

@LucasSantana-Dev
Copy link
Copy Markdown

@LucasSantana-Dev LucasSantana-Dev commented Mar 20, 2026

Issue for this PR

Closes #9281

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This extends provider.list with server-derived usage freshness and recent token signals so clients can render provider usage state without duplicating inference logic.

Added fields per provider:

  • usage.state: fresh | stale | missing
  • usage.observedAt
  • usage.ageMinutes
  • usage.recentInputTokens
  • usage.recentOutputTokens

Why this works: values are computed from recent assistant message usage on the server, so all clients consume one canonical classification path.

How did you verify your code works?

  • cd packages/opencode && bun run typecheck
  • cd packages/opencode && bun test test/provider/usage.test.ts

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 20, 2026
@LucasSantana-Dev LucasSantana-Dev changed the title feat: add provider usage freshness signals to provider list feat(api): enrich provider.list with usage freshness and recent token signals Mar 20, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@LucasSantana-Dev
Copy link
Copy Markdown
Author

Rebased on upstream/dev (HEAD: 11e7dae). CI re-running.

@LucasSantana-Dev LucasSantana-Dev force-pushed the feature/provider-usage-freshness-signals branch from d46899c to 11e7dae Compare April 19, 2026 17:41
@LucasSantana-Dev
Copy link
Copy Markdown
Author

Already on upstream/dev. HEAD: 11e7dae

@CasualDeveloper
Copy link
Copy Markdown
Contributor

hey @LucasSantana-Dev, did you mean to attach this pr to #9281? it doesn't seem to match the feature requested there.

#9281 is specifically about showing actual provider plan usage/limits in the tui, e.g. remaining quota, reset windows, and provider-specific limits for openai/codex, claude, and copilot.

from the diff, this pr seems to add an isolated helper that summarizes recent local assistant-message token counts by provider and marks them fresh/stale/missing. that could maybe be useful as provider activity metadata, but it doesn't fetch provider quota/limit endpoints, expose /usage, render a tui dialog/sidebar, or show remaining plan usage/reset times. also, unless i'm missing something, ProviderUsage.list() doesn't appear to be wired into provider.list in this diff, despite the pr description saying provider.list is extended. so as submitted, i'm not sure this changes any user-visible behavior.

i think you should remove Closes #9281 from this pr? it attaches this work to an unrelated issue and would close it if merged. #9545 is currently covering the actual quota/usage tracking work for #9281.

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.

[FEATURE] Add unified usage tracking via /usage (#9545)

2 participants