# Intel agent stuck waiting on a rate-limited news API mid briefing

## TL;DR
Waiting on a rate-limited API stalls the briefing on nothing: the wait rarely ends in time to matter. The fix is a wait budget, after which the agent proceeds with cache and fallback sources. The briefing notes the degraded coverage and the next scheduled run picks up the missed items.

## The error
```text
(agent stuck)
intel agent stuck waiting on rate-limited news api mid briefing; 45 min wait, briefing late
```

## When this helps
- an agent stalls waiting on rate limits
- briefings run late on throttled APIs
- designing wait budgets
- building degraded briefing modes

## When it doesn't
- the limit clears in seconds; short waits are fine
- the API is the only source; then waiting may be the only option
- coverage must be complete; degraded briefings are a tradeoff

## Works with
python 3.8+ with json and time. Any rate-limited news API.

## Steps
### 1. Cap the wait with a budget
```python
import time
WAIT_BUDGET = 300
start = time.time()
print("waiting at most", WAIT_BUDGET, "seconds for the rate limit")
print("budget spent:", int(time.time() - start) not in range(0, WAIT_BUDGET))
```
Expected: A wait budget. Five minutes is generous; the briefing cannot wait longer.

### 2. Proceed with cache and fallback when the budget ends
```python
import json
print("budget ended: briefing continues from article cache plus rss fallback")
open("coverage_note.txt", "w").write("news api rate-limited; coverage from cache as of [date]")
print("coverage note written")
```
Expected: A degraded briefing path. The wait ends in a decision, not a stall.

### 3. Queue the missed queries for the next run
```python
import json
missed = ["[topic1]", "[topic2]"]
open("missed_queries.json", "w").write(json.dumps(missed))
print("missed queries queued for the next scheduled run")
```
Expected: A miss queue. Nothing is lost; it is deferred with a record.

### 4. Pace the next run to avoid the limit
```python
import json
plan = {"calls_per_minute": 5, "spread": True}
open("pace_plan.json", "w").write(json.dumps(plan, indent=2))
print("next run paces calls; the limit is a planning input now")
```
Expected: A pacing plan. The rate limit becomes a design parameter, not a surprise.

## Other ways people phrase this
### agent stuck waiting rate limit
Cap the wait. Proceed degraded. Queue the misses.

### rate-limited api briefing late
A wait budget turns a stall into a decision.

### news api throttle briefing stuck
Pace the next run; the limit is a planning input.

## Why it happens
Rate-limited APIs recover on their own schedule, not the briefing's. Agents that wait indefinitely trade a late briefing for a later one. A wait budget bounds the damage, and cache plus fallback plus a miss queue preserve everything the wait would have gained.

## Edge cases
- Wait budgets should match the briefing's lateness tolerance.
- Some limits clear in seconds; probe once before giving up.
- The miss queue needs its own budget on the next run.
- Log waits as events; chronic waiting means the pacing plan is wrong.
- A wait budget that always exhausts means the pacing plan is wrong; fix the plan, not the budget.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_2A66ex8kcsDobWYD4fibfw
