Recognize context overflow from a pattern table (413, context_length_exceeded, prompt-too-long, Chinese, MiniMax/Z.AI wording).
Honor Retry-After (seconds or HTTP date, capped) and otherwise back off with jitter. Retry 408, 429, 5xx, 529, and in-stream capacity errors.
Forward stream events immediately. Retry only when no delta has been forwarded.
Do not execute a tool call cut off by length or an unclean end. Reject a call whose name or arguments JSON is incomplete and write a paired error.
Split usage into the last request (context) and the cumulative sum (billing).
Test plan
GOWORK=off go test -race -count=1 ./runtime/llm/ ./runtime/
## Summary
- Recognize context overflow from a pattern table (413, context_length_exceeded, prompt-too-long, Chinese, MiniMax/Z.AI wording).
- Honor Retry-After (seconds or HTTP date, capped) and otherwise back off with jitter. Retry 408, 429, 5xx, 529, and in-stream capacity errors.
- Forward stream events immediately. Retry only when no delta has been forwarded.
- Do not execute a tool call cut off by length or an unclean end. Reject a call whose name or arguments JSON is incomplete and write a paired error.
- Split usage into the last request (context) and the cumulative sum (billing).
## Test plan
- [x] GOWORK=off go test -race -count=1 ./runtime/llm/ ./runtime/
Why: Buffering a whole attempt hid live output, overflow detection missed common provider errors, and a cut-off tool call could still run.
Evidence: GOWORK=off go test -race -count=1 ./runtime/llm/ ./runtime/ passed.
Impact: WithRetry forwards events immediately and retries only when nothing has been forwarded. Length or an unclean end drops unfinished tool calls. Loop usage keeps a billing sum and the last request separately.
Refs: feature/llm-robustness
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen
merged commit 9335fd40e6 into main2026-10-03 15:56:15 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Test plan