Cursor request timeout: measure before you raise the limit
Three different failures look identical from the editor: nothing comes back. They need three different fixes, and the default response (raise the timeout) only helps one of them.
- Connection timeout. Nothing was established. Network, DNS, or a proxy. Raising a request timeout does nothing.
- Read timeout. The connection was made and the response never finished. Either the request is genuinely slow or the client gave up too early.
- Rejected for length. The request arrived and was refused because it exceeded the context window. This is not a timeout at all, and it is the one most often misdiagnosed as one.
https://aicomp.ai/v1).
Create one free →
One command separates them
Ask the endpoint how long a comparable request actually takes, from the same machine:
# -w prints the breakdown: how long to connect, and how long to first byte
curl -s -o /dev/null --max-time 120 \
-w "dns %{time_namelookup}s connect %{time_connect}s ttfb %{time_starttransfer}s total %{time_total}s\n" \
https://aicomp.ai/v1/chat/completions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"claude-sonnet-5","messages":[{"role":"user","content":"Say ok"}],"max_tokens":16}'
Read the shape of the numbers:
connectnear zero andttfblarge, the server accepted you and is slow. Raising the client timeout is legitimate here.connectlarge or failing The network is the problem. Raising a request timeout will not help.- An immediate refusal with a length error, no amount of waiting will fix it.
Why agent sessions time out and chat does not
Agent mode sends a bigger request every turn. The conversation, every file it read, and the output of every command it ran all go back with the next call. By turn fifteen, the request is many times the size of the one you typed.
So the failure is rarely "the server is slow". It is that the request grew past what finishes inside the client's patience And it will keep growing unless you change the shape of the session, not the timeout value.
Cut the session, not the wait. Ending a task in eight turns instead of twenty removes more latency than any timeout setting, because it removes tokens from every subsequent request rather than extending the deadline on a request that should not be that large.
Cap the output when you can. A request that is allowed to generate a very long response takes proportionally longer to finish. If you are waiting on a summary rather than a file rewrite, a lower max_tokens returns sooner and costs less.
The context limit hiding behind a timeout
This is the misdiagnosis worth calling out. A request over the model's context window is refused rather than processed. Depending on the client, that refusal can surface as a failure that looks like the request never completed.
Check it before you raise anything:
# What does this model actually accept?
curl -s https://aicomp.ai/v1/models -H "Authorization: Bearer $OPENAI_API_KEY" \
| jq -r '.data[] | select(.id=="claude-sonnet-5") | "context \(.context_length) max_out \(.max_output_tokens)"'
If your session is near that number, you are not looking at a timeout. You are looking at a request that will never succeed at that size, and the fix is a shorter session or a larger-window model, not a longer wait.
When raising the timeout is correct
Sometimes the server genuinely is slow: long reasoning, a large file rewrite, a model under load. In that case raising the client timeout is the right fix, with one caveat (set it to a value you are willing to wait), not to a large number that turns a failure into a five-minute freeze. A request that has not produced a first byte in ninety seconds is rarely going to finish usefully.
FAQ
FAQ
Is a timeout the same as a rate limit?
No. A rate limit is a 429, the server answered and declined. A timeout means no answer finished. They need opposite responses: a 429 means send less, while a read timeout on a genuinely slow request means wait longer or send something smaller.
Why does it only happen in agent mode?
Because agent requests grow. Every turn re-sends the conversation plus accumulated tool output, so the request you are waiting on is far larger than the message you typed. Chat sessions do not compound, which is why the same key times out in one mode and not the other.
Should I just set a very long timeout?
Only after you have confirmed the request is valid. A long timeout on a request that exceeds the context window converts an instant refusal into a long wait for the same failure. Measure first: if the request is near the context limit, shorten it instead.
Does streaming help?
It helps perceived latency, not throughput. Streaming delivers the first token sooner, so a slow response feels responsive, but the total time and the total tokens are unchanged. It will not rescue a request that is too large.
Can I tell whether it is my network or the endpoint?
Yes, with the timing breakdown above. DNS and connect times are yours; time-to-first-byte is mostly the endpoint's. A large connect time with a fast first byte points at your network or proxy configuration.
Related
- Cursor 429 rate limit — the error that looks like slowness and is not
- Context length exceeded — the refusal that masquerades as a timeout
- What hitting the context limit costs — why large sessions cost twice
- Cursor agent tool call errors — failures inside the loop
- LiteLLM retries and timeouts — timeout settings when you own the client
- Cursor with an OpenAI-compatible endpoint — the base setup