Handling 402 'can only afford N tokens' errors as recoverable
Cluster 49769 · agent. Data as of
Nothing open on GitHub. Fix merged in #134157 on 7 Oct 2026. Check it covers your case.
The short answer
- Known?
- Yes. 4 related items grouped here, 1 issue already closed.
- Fix event
- A fix was merged to main in PR #134157. Check it covers your case. No release data is tracked.
- Tracker
- The maintainers' tracker marks this
resolved, deciding PR #133714. That is separate from the fix event. - Still open
- Nothing open on GitHub.
Most members concern a 402 response saying only N tokens are affordable, which is described as being treated as terminal billing; two titles propose treating it as recoverable or retrying once with a capped output. One member is a broader test-focused item on provider wire formats, error bodies, and prompt-cache prefixes, which is related but less specific.
Open issues0
Open PRs0
Fixes on record
-
#133767 test: pin each provider's wire, real error bodies, and the prompt-cache prefix contract
files:
tests/agent/test_error_classifier_observed.py,tests/agent/test_prompt_cache_prefix_contract.py,tests/agent/transports/test_provider_wire_snapshot.py,tests/fixtures/provider_wire_snapshot.json -
#134157 fix(agent): a credit-limited 402 retries once with the affordable output cap instead of failing as billing
files:
agent/turn_recovery.py,agent/turn_retry_state.py,tests/agent/test_affordable_402_main_loop.py
1 PR closed without merging
From the close comments: done elsewhere 1
-
#49785 fix(error): treat 402 'can only afford N tokens' as recoverable rate-limit · done elsewhere →
ee8dd6c,#134157
Closed issues · 1
- Closed#49769Recoverable 402 ("can only afford N tokens") is treated as terminal billing and drops the request
How this cluster was grouped
-
Link evidence (
structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference. -
Pairwise link density
0.50: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36.1.00means every pair is linked.
Pick up a Lab task
Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.
Open the Lab