Skip to content

feat: expose rate limits on usage updates - #334

Open
s-cork wants to merge 2 commits into
agentclientprotocol:mainfrom
anvil-works:stu-dev/usage-updates-main
Open

feat: expose rate limits on usage updates#334
s-cork wants to merge 2 commits into
agentclientprotocol:mainfrom
anvil-works:stu-dev/usage-updates-main

Conversation

@s-cork

@s-cork s-cork commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • Attach stored Codex rate-limit snapshots to ACP usage_update events under _meta["_codex/rateLimits"].
  • Emit a refreshed usage update when rate limits change and context usage is already known.
  • Retain rate limits received before token usage and include them in the next usage update.
  • Merge sparse rolling updates with known values, including updates which omit an ID or name.
  • Preserve the existing usage update when no rate-limit snapshot is available.

Why

codex-acp already stores account rate-limit snapshots for /status, but ACP clients cannot consume the structured values. This exposes the same snapshots without changing the standard ACP usage fields or making clients parse markdown.

Rate-limit notifications may omit unchanged values. Merging them with the previous snapshot prevents a rolling update from erasing windows, credits, plan metadata, or spend-control state.

Review the extension shape and event timing first, then the sparse-update merge.

Testing

Rebased onto current main at 50f69e57ca761ccafd2ca29de7fb591068277516.

  • npm run typecheck
  • npm test: 458 passed, 28 skipped
  • npm run build
  • git diff --check origin/main..HEAD

Tests cover deferred emission when rate limits arrive before token usage, immediate refresh after context usage is known, multiple independent limits, and complete-to-sparse updates which omit the ID or name.

Closes #227

AI assisted with implementation, rebase conflict resolution, tests, and PR text.

@s-cork
s-cork force-pushed the stu-dev/usage-updates-main branch from 4fa79d5 to b670a4e Compare August 25, 2026 09:27
@s-cork s-cork changed the title Expose rate limits on usage updates feat: expose rate limits on usage updates Aug 25, 2026
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.

Surface Codex RateLimitSnapshot (usage windows) over ACP, not just in /status text

1 participant