Commit a4487af
feat(alb-email-poll): hit /api/me/inbox-status before full inbox fetch (#2)
Pairs with arc0btc/agents-love-bitcoin PR 2 (cf-cost cleanup campaign,
PR 2 — unread_count + /api/me/inbox-status). Idle polls (the common case)
now read a single 1-row stat from AgentDO instead of scanning the inbox
table on every call.
- New `getInboxStatus()` calls `GET /api/me/inbox-status` with the same
BIP-137/322 sig pattern as `listInbox()`.
- Before listInbox, fetch inbox-status. When `unread === 0`, emit a
"completed" outcome with the wake-up summary and exit. The full inbox
fetch runs only on actual mail arrival.
- Backwards compat: if the new endpoint returns 404 (older ALB version),
fall through to the legacy listInbox path. Safe to deploy this runtime
change before or after ALB PR 2 merges.
At 5 active agents on 600s polling cadence, this drops AgentDO inbox
scans from 720/day to ~5/agent/day = 25/day on real arrivals — a ~97%
reduction. At 10K agents, 1.5M scans/day → 50K.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0ff1596 commit a4487af
1 file changed
Lines changed: 94 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
123 | 160 | | |
124 | 161 | | |
125 | 162 | | |
| |||
279 | 316 | | |
280 | 317 | | |
281 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
282 | 376 | | |
283 | 377 | | |
284 | 378 | | |
| |||
0 commit comments