feat: Capture Anthropic rate limit headers for heartbeat throttling #5
Reference in New Issue
Block a user
Delete Branch "feat/rate-limit-tracking"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements Task 1 of the rate limit monitoring plan: captures Anthropic's weekly usage headers on every API call and writes them to
/root/.nanobot/workspace/memory/rate_limits.json.Changes
AnthropicOAuthProvider._make_request()to parse 7 rate limit headers from API responsesVerification
Tested in-place:
rate_limits.jsoncorrectly populated after API call with:Next Steps
HEARTBEAT.mdto read this file and gate heartbeat frequency based onweekly_all_modelsthresholdRelated
Part of
/root/.nanobot/workspace/docs/plans/2026-02-14-rate-limit-monitoring.mdClosing this PR in favor of #6.
Why: This PR implemented the wrong approach - it throttles heartbeat frequency, but heartbeats already use Sonnet (separate budget pool). The real problem is Opus overuse in main conversation turns.
Solution: PR #6 implements dynamic model switching for the main agent based on rolling weekly quota. When burn rate exceeds target, main agent switches to Sonnet. When under quota, switches back to Opus.
The rate limit header capture from this PR is still valuable and will be used by #6.
Pull request closed